/* Dashboards app — app-specific styles */

/* ── Full-width layout (sidebar used for all users) ─────────────── */
.app-main        { max-width: 100%; padding: 0; }
.header-inner    { max-width: 1400px; }
.admin-content   { max-width: none; flex: 1; min-width: 0; }
.admin-sidebar   { flex-shrink: 0; }

/* ── Collapsible department sections ────────────────────────────── */
.dept-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: .7rem 1rem;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    color: rgba(255,255,255,.8);
    font-size: .875rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background .15s, color .15s;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.dept-toggle:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}
.dept-toggle.open {
    color: #fff;
    background: rgba(255,255,255,.06);
}
.dept-chevron {
    font-size: .65rem;
    transition: transform .2s;
    flex-shrink: 0;
    margin-left: .5rem;
    opacity: .7;
}
.dept-toggle.open .dept-chevron {
    transform: rotate(180deg);
}

.dept-links {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
}
.dept-links.open {
    max-height: 600px;
}
.dept-links li a {
    display: block;
    padding: .55rem 1rem .55rem 1.75rem;
    color: rgba(255,255,255,.75);
    font-size: .875rem;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s;
}
.dept-links li a:hover,
.dept-links li a.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-left-color: var(--accent);
    text-decoration: none;
}
.dept-links .sidebar-empty {
    padding: .5rem 1rem .5rem 1.75rem;
    color: rgba(255,255,255,.35);
    font-size: .8rem;
    font-style: italic;
}

/* ── Sidebar admin section label ────────────────────────────────── */
.sidebar-admin-label {
    color: rgba(255,255,255,.4);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    padding: 1rem 1rem .4rem;
}

/* ── Hamburger (mobile sidebar toggle) ──────────────────────────── */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 38px; height: 38px;
    background: none; border: none; cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: background .15s;
}
.hamburger:hover { background: rgba(255,255,255,.15); }
.hamburger span {
    display: block; height: 2px; background: #fff; border-radius: 2px;
}

/* ── Sidebar overlay (mobile) ───────────────────────────────────── */
.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 99; cursor: pointer;
}

/* ── Mobile ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .hamburger { display: flex; }

    .admin-sidebar {
        display: block;
        position: fixed;
        top: var(--header-h); left: 0; bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform .25s ease;
        overflow-y: auto;
        width: 240px;
    }
    .admin-sidebar.sidebar-open {
        transform: translateX(0);
    }
    .admin-content { padding: .75rem; }
}

@media (min-width: 641px) {
    .hamburger       { display: none; }
    .sidebar-overlay { display: none !important; }
    .admin-sidebar   { transform: none !important; position: static; }
}

/* ── Dashboard home — department cards ──────────────────────────── */
.dept-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.dept-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1rem;
    border-left: 5px solid var(--brand);
    text-decoration: none;
    color: var(--text);
    transition: box-shadow .15s, transform .1s;
    display: block;
}
.dept-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
}
.dept-card__name {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: .25rem;
}
.dept-card__count {
    font-size: .82rem;
    color: var(--text-muted);
}

/* ── Admin pages ────────────────────────────────────────────────── */
.content-header { margin-bottom: 1.25rem; }
.content-header h1 { margin: 0 0 .25rem; font-size: 1.4rem; }
.content-header p  { margin: 0; color: var(--text-muted); font-size: .9rem; }

.perm-table th, .perm-table td { vertical-align: middle; }
.perm-table .col-name { min-width: 160px; }

.cb-cell { text-align: center; }
.cb-cell input[type="checkbox"] {
    width: 18px; height: 18px; cursor: pointer;
    accent-color: var(--brand);
}

.dept-tabs {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.dept-tab {
    padding: .45rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: .875rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}
.dept-tab:hover { background: var(--brand-light); border-color: var(--brand); text-decoration: none; }
.dept-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.save-status {
    font-size: .8rem;
    margin-left: .5rem;
    opacity: 0;
    transition: opacity .3s;
}
.save-status.show { opacity: 1; }
.save-status.ok   { color: var(--success); }
.save-status.err  { color: var(--danger); }

.col-row-actions { width: 1%; white-space: nowrap; padding-left: .75rem; }
.btn-row-all {
    padding: .2rem .55rem;
    font-size: .75rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: background .15s, color .15s, border-color .15s;
    margin-right: .2rem;
}
.btn-row-all:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-row-all:disabled { opacity: .45; cursor: not-allowed; }

.no-dashboards-msg {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════════════
   Business dashboard — toolbar, controls, live section, charts
   ══════════════════════════════════════════════════════════════════ */

/* ── Toolbar ──────────────────────────────────────────────────────── */
.dash-toolbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.dash-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    flex: 0 0 auto;
}
.dash-controls {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: nowrap;
}
.dash-controls.hidden { display: none; }
.dash-ctrl-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}
.form-control--sm {
    padding: .25rem .5rem;
    font-size: .875rem;
    height: auto;
    min-width: 0;
}
select.form-control--sm { min-width: 90px; }
input[type=date].form-control--sm { width: auto; }

.dash-mode-switch {
    display: flex;
    gap: 0;
    margin-left: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.dash-mode-btn {
    padding: .3rem .8rem;
    font-size: .8rem;
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.dash-mode-btn:hover { background: var(--brand-light); color: var(--brand); }
.dash-mode-btn.active { background: var(--brand); color: #fff; }

/* ── Live income section ─────────────────────────────────────────── */
.dash-live-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .9rem 1.25rem 1.1rem;
    margin-bottom: 1rem;
}
.dash-section-label {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: .7rem;
}
.dash-today-cards {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    align-items: flex-start;
}
.dash-today-card {
    display: flex;
    flex-direction: column;
    min-width: 100px;
}
.dash-today-val {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--brand);
    line-height: 1.1;
}
.dash-today-lbl {
    font-size: .73rem;
    color: var(--text-muted);
    margin-top: .15rem;
}
.dash-today-card--inv .dash-today-val { color: #666; }

/* ── Card toolbar (title + legend row) ────────────────────────────── */
.card-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}
.card-toolbar h2 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

/* ── Loading state ────────────────────────────────────────────────── */
.dash-loading { opacity: .4; pointer-events: none; transition: opacity .2s; }

/* ── YTD stats panel ─────────────────────────────────────────────── */
.inc-ytd { padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
.inc-stats {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.inc-stat { display: flex; flex-direction: column; min-width: 110px; }
.inc-stat__value { font-size: 1.45rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.inc-stat--big .inc-stat__value { font-size: 2.3rem; color: var(--brand); }
.inc-stat__label {
    font-size: .72rem;
    color: var(--text-muted);
    margin-top: .2rem;
    line-height: 1.2;
}
.inc-good .inc-stat__value { color: var(--success); }
.inc-bad  .inc-stat__value { color: var(--danger); }

.inc-bars { display: flex; flex-direction: column; gap: .45rem; }
.inc-bar-row { display: flex; align-items: center; gap: .75rem; }
.inc-bar-label { flex: 0 0 170px; font-size: .8rem; color: var(--text-muted); text-align: right; }
.inc-bar-track {
    flex: 1;
    height: 10px;
    background: var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.inc-bar-fill { height: 100%; border-radius: var(--radius-sm); transition: width .4s; }
.inc-fill-actual { background: var(--brand); }
.inc-fill-target { background: #b9b9b9; }
.inc-fill-last   { background: #50617a; }
.inc-bar-value { flex: 0 0 110px; font-size: .85rem; font-weight: 700; }

/* ── SVG chart container ─────────────────────────────────────────── */
.inc-chart { width: 100%; }
.inc-svg { width: 100%; height: auto; display: block; }
.inc-grid { stroke: #eee; stroke-width: 1; }
.inc-axis { font-size: 11px; fill: var(--text-muted); }
.inc-axis--right { text-anchor: start; }

/* Chart bars */
.inc-b-actual  { fill: var(--brand); }
.inc-b-weekend { fill: #2b87c4; }
.inc-b-target  { fill: #c5c5c5; }
.inc-b-last    { fill: #50617a; }
.inc-mgroup--sel .inc-sel-bg { fill: rgba(0,0,0,.05); }

/* Chart lines */
.inc-l-cum    { fill: none; stroke: var(--success); stroke-width: 2.5; }
.inc-l-last   { fill: none; stroke: #50617a; stroke-width: 2; opacity: .85; }
.inc-l-target { fill: none; stroke: #aaa; stroke-width: 2; stroke-dasharray: 6 4; }
.inc-dot { fill: var(--success); }

/* ── Chart legend ────────────────────────────────────────────────── */
.inc-legend { display: flex; gap: 1.1rem; align-items: center; font-size: .78rem; color: var(--text-muted); flex-wrap: wrap; }
.inc-key { display: inline-flex; align-items: center; gap: .35rem; }
.inc-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.inc-sw-actual { background: var(--brand); }
.inc-sw-target { background: #c5c5c5; }
.inc-sw-last   { background: #50617a; }
.inc-line { width: 18px; height: 0; border-top: 3px solid; display: inline-block; }
.inc-ln-cum    { border-color: var(--success); }
.inc-ln-last   { border-color: #50617a; }
.inc-ln-target { border-color: #aaa; border-top-style: dashed; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .dash-mode-switch { margin-left: 0; }
    .dash-today-val   { font-size: 1.25rem; }
    .inc-bar-label    { flex: 0 0 100px; }
    .inc-bar-value    { flex: 0 0 70px; font-size: .75rem; }
}

/* ══════════════════════════════════════════════════════════════════
   Cash Flow dashboard
   ══════════════════════════════════════════════════════════════════ */

.cf-toggle-btn.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

/* Scrollable table container */
.cf-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--card-bg);
}

/* Table base */
.cf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .78rem;
    white-space: nowrap;
}
.cf-table thead th {
    position: sticky;
    top: 0;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    text-align: right;
    padding: .45rem .5rem;
    border-right: 1px solid rgba(255,255,255,.15);
    z-index: 2;
}
.cf-table thead th:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 160px;
}
.cf-table thead th.cf-ytd   { background: #1a6090; }
.cf-table thead th.cf-total { background: #154e73; }

/* Body cells */
.cf-table tbody tr { border-bottom: 1px solid var(--border); }
.cf-table tbody tr:last-child { border-bottom: none; }
.cf-table tbody td { padding: .3rem .5rem; }

.cf-label {
    position: sticky;
    left: 0;
    background: var(--card-bg);
    font-weight: 500;
    color: var(--text);
    padding-right: 1rem;
    z-index: 1;
    border-right: 1px solid var(--border);
}
.cf-num { text-align: right; color: var(--text); }
.cf-ytd   { background: rgba(26,96,144,.06); font-weight: 600; }
.cf-total { background: rgba(21,78,115,.08); font-weight: 700; }

/* Section headers */
.cf-section-header td {
    background: var(--brand-light, #e8f1f8);
    color: var(--brand);
    font-weight: 700;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .45rem .5rem;
}

/* Totals rows */
.cf-total-row .cf-label { font-weight: 700; }
.cf-total-row .cf-num   { font-weight: 700; border-top: 2px solid var(--border); }

/* Diff rows */
.cf-diff-row .cf-label { color: var(--text-muted); font-style: italic; }

/* Value states */
.cf-zero { color: var(--text-muted); }
.cf-neg  { color: var(--danger); }
.cf-pos  { color: var(--success); }

/* Alternating row tint */
.cf-table tbody tr:nth-child(even) .cf-label { background: #f9fafb; }
.cf-table tbody tr:nth-child(even) td        { background: #f9fafb; }
.cf-table tbody tr:nth-child(even) .cf-ytd   { background: rgba(26,96,144,.09); }
.cf-table tbody tr:nth-child(even) .cf-total { background: rgba(21,78,115,.11); }
/* Section headers always override stripe */

/* ── Staff Hours dashboard (sh-*) ───────────────────────────────────── */
.sh-date-range {
    font-size: .85rem;
    color: var(--text-muted);
    align-self: center;
    margin-left: 1rem;
}

.sh-table-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--brand);
    margin: 1.5rem 0 .6rem;
    padding: 0;
}

.sh-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

.sh-table {
    border-collapse: collapse;
    font-size: 12px;
    min-width: 100%;
    white-space: nowrap;
}

/* Rotated column headers */
.sh-table th {
    height: 120px;
    min-width: 34px;
    max-width: 34px;
    padding: 0;
    vertical-align: bottom;
    background: var(--bg-light, #f5f5f5);
    border-bottom: 2px solid var(--border);
    position: relative;
}

.sh-table th .sh-th-txt {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform-origin: left bottom;
    transform: translateX(-50%) rotate(-45deg);
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: .01em;
}

/* First column header — not rotated */
.sh-table th.sh-th-name {
    height: auto;
    min-width: 170px;
    max-width: 170px;
    vertical-align: middle;
    padding: 8px 10px;
    position: sticky;
    left: 0;
    z-index: 3;
}

.sh-table th.sh-th-name .sh-th-txt {
    position: static;
    transform: none;
    display: block;
    font-size: 12px;
}

/* Data cells */
.sh-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
    background: #fff;
}

.sh-table tbody tr:nth-child(even) td { background: #f9fafb; }
.sh-table tbody tr:hover td           { background: #eef4fb; }

/* Left-border group separators */
.sh-table th.sh-sep,
.sh-table td.sh-sep {
    border-left: 2px solid var(--border);
}

/* First sticky column */
.sh-table td.sh-name {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 170px;
    max-width: 170px;
    font-weight: 600;
    border-left: none;
    border-right: 2px solid var(--border);
    background: #fff;
}

.sh-table tbody tr:nth-child(even) td.sh-name { background: #f9fafb; }
.sh-table tbody tr:hover td.sh-name            { background: #eef4fb; }

.sh-contract {
    font-weight: 400;
    font-size: 11px;
    color: var(--text-muted);
}

.sh-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Warning: bold red */
.sh-warn {
    font-weight: 700;
    color: var(--danger, #c0392b);
}
.cf-section-header td { background: var(--brand-light, #e8f1f8) !important; }
