/* ============================================================
   Sajil — سجل  ·  operations console
   Brand palette: deep teal #082C2B, signal turquoise #00EFD2.
   Turquoise is bright, so it carries dark text and is reserved
   for primary actions; amber and red stay owned by expiry.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
    --ink:        #082C2B;   /* brand deep teal */
    --ink-2:      #0E3F3D;
    --ink-3:      #17544F;
    --paper:      #F4F8F7;
    --surface:    #FFFFFF;
    --line:       #DCE6E4;
    --line-soft:  #EDF3F2;

    --text:       #0C1F1E;
    --text-2:     #536967;
    --text-3:     #859997;
    --on-ink:     #E6F7F4;
    --on-ink-dim: #86AEA9;

    --accent:      #00EFD2;  /* brand turquoise */
    --accent-dark: #00C4AD;
    --accent-deep: #0A6A5E;
    --accent-tint: #DEFBF6;
    --on-accent:   #052220;  /* text on turquoise */

    --amber:      #E0A21A;
    --amber-tint: #FDF3DC;
    --amber-text: #7A5406;

    --red:        #C0362C;
    --red-tint:   #FBE9E7;

    --blue-tint:  #E3EFEE;

    --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --sans-ar: 'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    --rail-w: 240px;
    --radius: 6px;
}

/* Arabic swaps the family and relaxes line-height for the script */
html[dir="rtl"] body { font-family: var(--sans-ar); line-height: 1.75; }
html[dir="rtl"] .mono, html[dir="rtl"] td.num,
html[dir="rtl"] .metric-value, html[dir="rtl"] .plate {
    direction: ltr; unicode-bidi: embed;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0; height: 100%;
    font-family: var(--sans);
    background: var(--paper);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
a { color: var(--accent-deep); }
button { font-family: inherit; font-size: inherit; cursor: pointer; }

/* numerals: plates, IDs, money, dates all read better tabular */
.mono, td.num, .metric-value, .plate {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------- sign in */
.signin-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    background: var(--ink);
}
.signin-brand {
    padding: 56px 60px;
    color: var(--on-ink);
    display: flex; flex-direction: column; justify-content: space-between;
    background:
        linear-gradient(180deg, rgba(0,239,210,.16) 0%, rgba(8,44,43,0) 55%),
        var(--ink);
}
.signin-brand h1 { font-size: 34px; line-height: 1.15; max-width: 15ch; }
.signin-brand .sub { color: var(--on-ink-dim); max-width: 46ch; margin-top: 16px; }
.brand-mark {
    display: inline-flex; align-items: center; gap: 10px;
    font-weight: 600; letter-spacing: .02em;
}
.brand-plate {
    font-family: var(--mono); font-weight: 600;
    background: var(--accent); color: var(--on-accent);
    padding: 3px 9px; border-radius: 3px; font-size: 13px;
}
.signin-stats { display: flex; gap: 36px; color: var(--on-ink-dim); font-size: 13px; }
.signin-stats b { display: block; color: var(--on-ink); font-size: 20px; font-family: var(--mono); }

.signin-panel {
    background: var(--surface);
    padding: 56px 60px;
    display: flex; flex-direction: column; justify-content: center;
}
.signin-panel h2 { font-size: 22px; margin-bottom: 6px; }
.signin-panel .hint { color: var(--text-2); margin-bottom: 28px; }
.signin-form { max-width: 360px; width: 100%; }
.demo-note {
    margin-top: 26px; padding: 14px 16px;
    background: var(--paper); border: 1px solid var(--line);
    border-radius: var(--radius); font-size: 13px; color: var(--text-2);
}
.demo-note b { color: var(--text); }
.demo-accounts { margin-top: 8px; display: grid; gap: 4px; }
.demo-accounts code {
    font-family: var(--mono); font-size: 12px;
    background: var(--surface); border: 1px solid var(--line);
    padding: 1px 5px; border-radius: 3px;
}

/* ---------------------------------------------------- controls */
label.field { display: block; margin-bottom: 16px; }
label.field > span {
    display: block; margin-bottom: 6px;
    font-weight: 500; color: var(--text-2); font-size: 13px;
}
input[type=text], input[type=password], input[type=date],
input[type=number], input[type=email], select, textarea {
    width: 100%; padding: 9px 11px;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); color: var(--text);
    font-family: inherit; font-size: 14px;
    transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent-deep);
    box-shadow: 0 0 0 3px rgba(0,239,210,.28);
}
input:disabled, select:disabled { background: var(--paper); color: var(--text-3); }
textarea { min-height: 76px; resize: vertical; }

/* `display` on a class beats the hidden attribute, so a button hidden
   with el.hidden = true still laid out - an empty pill appeared on every
   screen that sets no primary action. */
[hidden] { display: none !important; }

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; border-radius: var(--radius);
    border: 1px solid transparent; font-weight: 500;
    background: var(--accent); color: var(--on-accent); font-weight: 600;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; justify-content: center; padding: 11px; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.secondary:hover { background: var(--paper); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #8E1E17; }
.btn.small { padding: 6px 11px; font-size: 13px; }

.error-box {
    background: var(--red-tint); border: 1px solid #F1C6C2;
    color: var(--red); padding: 10px 13px;
    border-radius: var(--radius); margin-bottom: 16px; font-size: 13px;
}

/* ---------------------------------------------------- app shell */
.app { display: none; min-height: 100vh; }
.app.on { display: grid; grid-template-columns: var(--rail-w) 1fr; }

.rail {
    background: var(--ink); color: var(--on-ink);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.rail-head { padding: 20px 20px 16px; border-bottom: 1px solid var(--ink-3); }
.rail-nav { padding: 12px 10px; flex: 1; }
.rail-group { margin-bottom: 14px; }
.rail-group-label {
    font-size: 11px; color: var(--on-ink-dim);
    padding: 6px 10px; font-weight: 600; letter-spacing: .04em;
}
.rail-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px; border-radius: var(--radius);
    color: var(--on-ink); cursor: pointer; margin-bottom: 1px;
    border: none; background: none; width: 100%; text-align: left;
    transition: background .12s;
}
.rail-item:hover { background: var(--ink-2); }
.rail-item.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.rail-item .count {
    font-family: var(--mono); font-size: 12px;
    color: var(--on-ink-dim); background: var(--ink-2);
    padding: 1px 6px; border-radius: 9px;
}
.rail-item.active .count { background: rgba(5,34,32,.16); color: var(--on-accent); }

.rail-foot {
    padding: 14px 16px; border-top: 1px solid var(--ink-3);
    display: flex; align-items: center; gap: 10px;
}
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent); color: var(--on-accent);
    display: grid; place-items: center; font-weight: 600; font-size: 13px;
    flex-shrink: 0;
}
.rail-foot .who { flex: 1; min-width: 0; }
/* Both lines are clipped, not just the second: a long full name
   ("System Administrator") used to run under the language and
   sign-out buttons sitting beside it. */
.rail-foot .who b,
.rail-foot .who span {
    display: block;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-foot .who b { font-size: 13px; }
.rail-foot .who span { font-size: 12px; color: var(--on-ink-dim); }
.icon-btn {
    background: none; border: none; color: var(--on-ink-dim);
    padding: 5px; border-radius: 4px; line-height: 0;
}
.icon-btn:hover { background: var(--ink-2); color: var(--on-ink); }

/* ---------------------------------------------------- main */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: 0 26px; height: 60px;
    display: flex; align-items: center; gap: 18px;
    position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 17px; }
.topbar .ar { color: var(--text-3); font-size: 14px; margin-inline-start: 2px; }
.topbar .spacer { flex: 1; }
.search {
    position: relative; width: 300px;
}
.search input { padding-inline-start: 32px; }
.search svg {
    position: absolute; inset-inline-start: 10px; top: 50%;
    transform: translateY(-50%); color: var(--text-3);
}
.content { padding: 24px 26px 60px; flex: 1; }

/* ---------------------------------------------------- dashboard */
.watch-head {
    display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px;
}
.watch-head h3 { font-size: 16px; }
.watch-head p { margin: 0; color: var(--text-2); font-size: 13px; }

.watch {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden; margin-bottom: 26px;
}
.watch-row {
    display: grid;
    grid-template-columns: 4px 150px 1fr 132px 120px;
    align-items: center; gap: 14px;
    padding: 11px 16px 11px 0; border-top: 1px solid var(--line-soft);
}
.watch-row:first-child { border-top: none; }
.watch-bar { height: 100%; min-height: 40px; align-self: stretch; }
.sev-expired  .watch-bar { background: var(--red); }
.sev-critical .watch-bar { background: var(--amber); }
.sev-soon     .watch-bar { background: #C9D3E0; }
.watch-kind { color: var(--text-2); font-size: 13px; }
.watch-label b { display: block; }
.watch-label span { color: var(--text-3); font-size: 12.5px; }
.watch-date { text-align: right; }
.watch-days { text-align: right; font-weight: 500; font-size: 13px; }
.sev-expired  .watch-days { color: var(--red); }
.sev-critical .watch-days { color: var(--amber-text); }

.metrics {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1px; background: var(--line);
    border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; margin-bottom: 26px;
}
.metric { background: var(--surface); padding: 16px 18px; }
.metric-label { color: var(--text-2); font-size: 13px; margin-bottom: 5px; }
.metric-value { font-size: 25px; font-weight: 600; letter-spacing: -0.02em; }
.metric-sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.metric.accent .metric-value { color: var(--accent-deep); }
.metric.warn   .metric-value { color: var(--amber-text); }
.metric.bad    .metric-value { color: var(--red); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

.panel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden;
}
.panel-head {
    padding: 13px 16px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 10px;
}
.panel-head h3 { font-size: 14px; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }

.bar-row { display: grid; grid-template-columns: 150px 1fr 44px; align-items: center; gap: 12px; margin-bottom: 9px; }
.bar-track { background: var(--line-soft); border-radius: 3px; height: 9px; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 3px; }
.bar-row .n { text-align: right; font-family: var(--mono); font-size: 13px; color: var(--text-2); }

/* ---------------------------------------------------- tables */
.toolbar {
    display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.toolbar select, .toolbar input { width: auto; min-width: 150px; }

.table-wrap {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: auto;
}
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; font-weight: 600; font-size: 12.5px; color: var(--text-2);
    padding: 10px 14px; border-bottom: 1px solid var(--line);
    background: var(--paper); white-space: nowrap; position: sticky; top: 0;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--paper); }
td.num { text-align: right; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }

.plate {
    display: inline-block; font-weight: 600; font-size: 13px;
    background: var(--surface); border: 1px solid var(--text-3);
    border-radius: 3px; padding: 1px 7px; letter-spacing: .04em;
}

.tag {
    display: inline-block; padding: 2px 8px; border-radius: 11px;
    font-size: 12px; font-weight: 500; white-space: nowrap;
}
.tag.green  { background: var(--accent-tint); color: var(--accent-dark); }
.tag.amber  { background: var(--amber-tint); color: var(--amber-text); }
.tag.red    { background: var(--red-tint);   color: var(--red); }
.tag.blue   { background: var(--blue-tint);  color: var(--ink-3); }
.tag.grey   { background: var(--line-soft);  color: var(--text-2); }

.pager {
    display: flex; align-items: center; gap: 12px; padding: 12px 4px;
    color: var(--text-2); font-size: 13px;
}
.pager .spacer { flex: 1; }

.empty { padding: 46px 20px; text-align: center; color: var(--text-2); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-size: 15px; }

.loading { padding: 40px; text-align: center; color: var(--text-3); }

/* ---------------------------------------------------- drawer */
.scrim {
    position: fixed; inset: 0; background: rgba(8,44,43,.45);
    opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 40;
}
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
    position: fixed; top: 0; inset-inline-end: 0; height: 100vh;
    width: min(620px, 94vw); background: var(--surface);
    box-shadow: -8px 0 28px rgba(8,44,43,.18);
    transform: translateX(100%); transition: transform .22s ease;
    z-index: 50; display: flex; flex-direction: column;
}
.drawer.on { transform: translateX(0); }
.drawer-head {
    padding: 18px 22px; border-bottom: 1px solid var(--line);
    display: flex; align-items: flex-start; gap: 12px;
}
.drawer-head h3 { font-size: 17px; }
.drawer-head .sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer-foot {
    padding: 14px 22px; border-top: 1px solid var(--line);
    display: flex; gap: 10px; justify-content: flex-end;
    flex-wrap: wrap;              /* never overflow the drawer */
}
@media (prefers-reduced-motion: reduce) {
    .drawer, .scrim { transition: none; }
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 620px) { .grid-2 { grid-template-columns: 1fr; } }

.dl { display: grid; grid-template-columns: 150px 1fr; gap: 9px 16px; }
.dl dt { color: var(--text-2); font-size: 13px; }
.dl dd { margin: 0; }
.section-title {
    font-size: 12.5px; font-weight: 600; color: var(--text-2);
    padding-bottom: 7px; margin: 22px 0 12px;
    border-bottom: 1px solid var(--line);
    /* the section's own action sits on the heading rather than the
       drawer footer, which otherwise fills up with a dozen buttons */
    display: flex; align-items: center; gap: 10px;
}
.section-title .sec-action {
    margin-inline-start: auto; font-weight: 500; font-size: 12px;
    padding: 3px 10px; border-radius: var(--radius);
    border: 1px solid var(--line); background: var(--surface);
    color: var(--accent-deep); cursor: pointer;
}
.section-title .sec-action:hover { background: var(--paper); }
.section-title:first-child { margin-top: 0; }

/* --------------------------------------------- permission matrix */
.perm-table td { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-table input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent-deep); cursor: pointer; }
.perm-cat td {
    background: var(--paper); font-weight: 600; font-size: 12.5px;
    color: var(--text-2); text-align: left !important;
}

/* ---------------------------------------------------- toast */
.toasts { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; }
.toast {
    background: var(--ink); color: var(--on-ink);
    padding: 11px 18px; border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(8,44,43,.3); font-size: 13.5px;
}
.toast.bad { background: var(--red); color: #fff; }

@media (max-width: 900px) {
    .app.on { grid-template-columns: 1fr; }
    .rail { position: fixed; z-index: 60; width: var(--rail-w); transform: translateX(-100%); transition: transform .2s; }
    .rail.open { transform: translateX(0); }
    .signin-wrap { grid-template-columns: 1fr; }
    .signin-brand { display: none; }
    .search { width: 160px; }
}
.menu-btn { display: none; }
@media (max-width: 900px) { .menu-btn { display: inline-flex; } }

/* ============================================================
   Right-to-left
   Most of the layout already uses logical properties. These are
   the physical-property leftovers that need mirroring.
   ============================================================ */
html[dir="rtl"] th { text-align: right; }
html[dir="rtl"] td.num, html[dir="rtl"] td.actions,
html[dir="rtl"] .watch-date, html[dir="rtl"] .watch-days,
html[dir="rtl"] .bar-row .n { text-align: left; }
html[dir="rtl"] .perm-table td:first-child,
html[dir="rtl"] .perm-table th:first-child { text-align: right; }
html[dir="rtl"] .perm-cat td { text-align: right !important; }
html[dir="rtl"] .rail-item { text-align: right; }
html[dir="rtl"] .drawer-foot { justify-content: flex-start; }
html[dir="rtl"] .drawer { transform: translateX(-100%); }
html[dir="rtl"] .drawer.on { transform: translateX(0); }
html[dir="rtl"] .watch-row { padding: 11px 0 11px 16px; }
html[dir="rtl"] .dl { grid-template-columns: 150px 1fr; }
@media (max-width: 900px) {
    html[dir="rtl"] .rail { transform: translateX(100%); }
    html[dir="rtl"] .rail.open { transform: translateX(0); }
}

/* language switch */
.lang-btn {
    background: none; border: 1px solid var(--line); color: var(--text-2);
    padding: 6px 12px; border-radius: var(--radius); font-weight: 500;
}
.lang-btn:hover { background: var(--paper); color: var(--text); }
.rail .lang-btn { border-color: var(--ink-3); color: var(--on-ink-dim); }
.rail .lang-btn:hover { background: var(--ink-2); color: var(--on-ink); }

/* brand lockup */
/* The logo sits in column flex containers, where the default
   align-items: stretch would pull it to the full width of the panel and
   distort it. align-self keeps it at its natural size. */
.brand-logo {
    height: 30px; width: auto; display: block;
    align-self: flex-start; flex: 0 0 auto;
    object-fit: contain; max-width: 100%;
}
.signin-brand .brand-logo { height: 52px; }
html[dir="rtl"] .brand-logo { align-self: flex-start; }
.print-only { display: none; }

/* ============================================================
   Print
   Screen chrome is dropped and the drawer becomes the page.
   Every printed sheet carries the Sajil mark, the document
   title in both languages, and who printed it when.
   ============================================================ */
@media print {
    @page { size: A4; margin: 14mm 12mm 16mm; }

    html, body {
        background: #fff !important; color: #000;
        font-size: 10.5pt; line-height: 1.45;
    }
    .rail, .topbar, .toasts, .scrim, .pager,
    .toolbar, .drawer-foot, .drawer-head .icon-btn,
    .btn, .icon-btn, .search, .menu-btn, .demo-note { display: none !important; }

    .app.on { display: block !important; }
    .main { display: block; }
    .content { padding: 0 !important; }
    .print-only { display: block; }

    /* when a drawer is open, print only the drawer */
    body.printing-drawer .content { display: none !important; }
    body.printing-drawer .drawer {
        position: static !important; transform: none !important;
        width: 100% !important; height: auto !important;
        box-shadow: none !important; display: block !important;
    }
    body.printing-drawer .drawer-body {
        overflow: visible !important; padding: 0 !important; height: auto !important;
    }
    body.printing-drawer .drawer-head {
        padding: 0 0 8pt; border-bottom: 1.5pt solid #082C2B; margin-bottom: 12pt;
    }

    /* sheet header, injected before printing */
    .print-header {
        display: flex !important; align-items: flex-start; gap: 12pt;
        border-bottom: 2pt solid #082C2B; padding-bottom: 8pt; margin-bottom: 12pt;
    }
    .print-header img { height: 34px; }
    .print-header .ph-title { flex: 1; }
    .print-header h1 { font-size: 15pt; margin: 0; color: #082C2B; }
    .print-header .ph-ar { font-size: 12pt; color: #333; }
    .print-header .ph-meta { font-size: 8.5pt; color: #444; text-align: right; }
    html[dir="rtl"] .print-header .ph-meta { text-align: left; }

    .print-footer {
        position: fixed; bottom: 0; left: 0; right: 0;
        font-size: 8pt; color: #555;
        border-top: .5pt solid #bbb; padding-top: 4pt;
        display: flex !important; justify-content: space-between;
    }

    /* flatten interactive styling into ink */
    .panel, .table-wrap, .watch, .metrics, .metric {
        border-color: #999 !important; box-shadow: none !important;
        break-inside: avoid;
    }
    .metrics { grid-template-columns: repeat(4, 1fr); }
    th { background: #EDF3F2 !important; color: #000 !important;
         -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    thead { display: table-header-group; }          /* repeat on every page */
    tr, .watch-row, .bar-row { break-inside: avoid; }
    .tag, .plate {
        border: .5pt solid #666 !important; background: #fff !important;
        color: #000 !important; border-radius: 2pt;
    }
    .watch-bar { background: #082C2B !important;
        -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .sev-expired .watch-bar { background: #C0362C !important; }
    .sev-critical .watch-bar { background: #E0A21A !important; }
    .section-title { break-after: avoid; color: #082C2B; }
    a { color: #000; text-decoration: none; }

    /* signature block for official copies */
    .print-signatures {
        display: grid !important; grid-template-columns: 1fr 1fr 1fr;
        gap: 20pt; margin-top: 28pt; break-inside: avoid;
    }
    .print-signatures div { border-top: .5pt solid #666; padding-top: 5pt; font-size: 9pt; }
}

/* ============================================================
   Fleet analytics charts.
   Drawn as inline SVG and flex bars rather than pulling in a
   charting library, so they inherit these variables directly
   and follow the light/dark and RTL rules like everything else.
   ============================================================ */
.chart-bars { display: grid; gap: 9px; }
.chart-bars .bar-row {
    display: grid; grid-template-columns: 130px 1fr 52px;
    align-items: center; gap: 12px;
}
.chart-bars .bar-label {
    font-size: 13px; color: var(--text-2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chart-bars .bar-track {
    background: var(--line-soft); border-radius: 3px; height: 10px; overflow: hidden;
}
.chart-bars .bar-fill { display: block; height: 100%; border-radius: 3px; }
.chart-bars .bar-value { text-align: right; font-size: 13px; color: var(--text-2); }

/* proportional status strip for one branch */
.stack {
    display: flex; height: 10px; border-radius: 3px;
    overflow: hidden; background: var(--line-soft);
}
.stack.empty { background: var(--line-soft); }
.stack-seg { display: block; height: 100%; }

.line-chart { width: 100%; height: auto; display: block; }
.legend {
    display: flex; flex-wrap: wrap; gap: 14px;
    margin-top: 10px; font-size: 12.5px; color: var(--text-2);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

@media (max-width: 720px) {
    .chart-bars .bar-row { grid-template-columns: 96px 1fr 44px; }
}

/* ============================================================
   Operations advisor findings.
   A coloured edge carries the urgency, so severity is readable
   at a glance without relying on colour alone — the count and
   the grouping heading say it too.
   ============================================================ */
.finding {
    background: var(--surface); border: 1px solid var(--line);
    border-inline-start: 3px solid var(--text-3);
    border-radius: var(--radius); margin-bottom: 10px; overflow: hidden;
}
.finding.crit { border-inline-start-color: var(--red); }
.finding.warn { border-inline-start-color: var(--amber); }
.finding.info { border-inline-start-color: var(--accent-dark); }

.finding-head {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.finding-count {
    min-width: 34px; text-align: center; font-weight: 600; font-size: 15px;
    padding: 2px 8px; border-radius: var(--radius);
    background: var(--paper); color: var(--text);
}
.finding.crit .finding-count { background: var(--red-tint);   color: var(--red); }
.finding.warn .finding-count { background: var(--amber-tint); color: var(--amber-text); }
.finding.info .finding-count { background: var(--accent-tint); color: var(--accent-deep); }
.finding-where { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

.finding-body { padding: 12px 16px; display: grid; gap: 7px; font-size: 13.5px; }
.finding-body code {
    font-family: var(--mono); font-size: 12px;
    background: var(--paper); border: 1px solid var(--line);
    padding: 1px 6px; border-radius: 3px;
}
.finding-label {
    display: inline-block; min-width: 108px;
    color: var(--text-2); font-weight: 500;
}
@media (max-width: 720px) {
    .finding-label { display: block; min-width: 0; }
}

/* ---------------------------------------------- advisor chat */
.chat-log {
    max-height: 260px; overflow-y: auto; display: grid; gap: 10px;
    margin-bottom: 12px;
}
.chat-log:empty { display: none; }
.chat-msg { display: grid; gap: 3px; }
.chat-who { font-size: 11.5px; color: var(--text-3); }
.chat-bubble {
    padding: 9px 13px; border-radius: var(--radius);
    background: var(--paper); border: 1px solid var(--line);
    font-size: 13.5px; line-height: 1.55; max-width: 80%;
}
.chat-msg.you  { justify-items: end; }
.chat-msg.you .chat-bubble { background: var(--accent-tint); border-color: var(--accent-tint); }
.chat-msg.bot  { justify-items: start; }

.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; }

.chat-suggest {
    display: flex; flex-wrap: wrap; gap: 7px; align-items: center;
    margin-top: 10px; font-size: 12.5px; color: var(--text-3);
}
.chip {
    border: 1px solid var(--line); background: var(--surface);
    color: var(--accent-deep); border-radius: 14px;
    padding: 4px 11px; font-size: 12.5px; cursor: pointer;
    font-family: inherit;
}
.chip:hover { background: var(--paper); }

/* a notification already seen recedes rather than disappearing */
.finding.read { opacity: .6; }
.finding.read .finding-count { background: var(--line-soft); color: var(--text-3); }

/* the selected tab in Finance Reports */
.chip.on {
    background: var(--accent-deep); color: #fff; border-color: var(--accent-deep);
}

/* money a finding puts at risk, shown beside its count */
.finding-amount {
    font-size: 13px; font-weight: 600; color: var(--red);
    background: var(--red-tint); border-radius: var(--radius);
    padding: 2px 9px; white-space: nowrap;
}
.finding.warn .finding-amount { color: var(--amber-text); background: var(--amber-tint); }
.finding.info .finding-amount { color: var(--text-2); background: var(--paper); }

/* ==================================================== attendance
   The clock card is the first thing most staff see. It holds one
   decision — in or out — so it is given the width of the page and a
   single button, and the rest of the card is what the button means.
   Logical properties throughout, so it mirrors under dir="rtl"
   without a second rule.
   ============================================================ */
.clock-card {
    display: grid; grid-template-columns: 1fr auto; gap: 24px;
    background: var(--ink); color: var(--on-ink);
    border-radius: var(--radius); padding: 22px 24px; margin-bottom: 26px;
    border-inline-start: 4px solid var(--accent);
}
.clock-card.open   { border-inline-start-color: var(--amber); }
.clock-card.blocked { border-inline-start-color: var(--line); }

.clock-label { color: var(--on-ink-dim); font-size: 13px; margin-bottom: 4px; }
.clock-date  { font-size: 25px; font-weight: 600; letter-spacing: -0.02em; }
.clock-note  { color: var(--on-ink-dim); font-size: 13px; margin-top: 8px; max-width: 46ch; }
.clock-flags { color: var(--accent); font-size: 12.5px; margin-top: 7px; }

.clock-side { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
.clock-btn {
    min-width: 190px; padding: 14px 22px; font-size: 15px; font-weight: 600;
    background: var(--accent); color: var(--on-accent); border: 0;
    border-radius: var(--radius); cursor: pointer;
}
.clock-btn:hover:not(:disabled) { background: var(--accent-dark); }
.clock-btn:disabled { opacity: 0.55; cursor: default; }
.clock-btn.out { background: var(--amber); color: #2A1D00; }
.clock-btn.out:hover:not(:disabled) { filter: brightness(0.94); }

.clock-stamps {
    display: grid; grid-template-columns: repeat(4, auto); gap: 4px 20px;
    padding-top: 12px; border-top: 1px solid rgba(230, 247, 244, 0.16);
}
.clock-stamps div { display: flex; flex-direction: column; gap: 3px; }
.clock-stamps span { color: var(--on-ink-dim); font-size: 11.5px; text-transform: uppercase;
                     letter-spacing: 0.04em; }
.clock-stamps b { font-size: 15px; font-weight: 600; }

@media (max-width: 760px) {
    .clock-card { grid-template-columns: 1fr; }
    .clock-stamps { grid-template-columns: repeat(2, 1fr); }
    .clock-btn { width: 100%; }
}

/* the working-week picker */
.day-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.day-chip {
    display: flex; align-items: center; gap: 7px;
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 7px 12px; font-size: 13px; cursor: pointer; background: var(--surface);
}
.day-chip input { width: 15px; height: 15px; accent-color: var(--accent-deep); }
.day-chip:has(input:checked) { border-color: var(--accent-deep); background: var(--accent-tint); }

/* a warning inside a drawer, for a condition the person must fix
   elsewhere before the controls beneath it can work */
.notice-warn {
    background: var(--amber-tint); color: var(--amber-text);
    border: 1px solid var(--amber); border-radius: var(--radius);
    padding: 10px 13px; font-size: 13px; margin: 0 0 14px;
}

/* ==================================================== roster
   A week grid: staff down the side, seven days across. The cells
   carry their own colour so a filled week can be read at a glance
   rather than by looking at every dropdown in turn.
   ============================================================ */
table.roster th.rst-day { text-align: center; white-space: nowrap; }
table.roster th.rst-day span { display: block; font-size: 12px; }
table.roster th.rst-day small { color: var(--text-3); font-weight: 400; }

.rst-who b { display: block; font-size: 13px; }
.rst-who span { display: block; color: var(--text-3); font-size: 12px; }

.rst-cell { padding: 5px 6px; text-align: center; }
.rst-cell select {
    width: 100%; min-width: 104px; font-size: 12.5px;
    padding: 5px 6px; border-radius: 5px;
}
/* set on the roster; the fallback is quieter, an explicit day off quieter still */
.rst-set select      { border-color: var(--accent-deep); background: var(--accent-tint); }
.rst-fallback select { color: var(--text-3); background: var(--paper); }
.rst-off select      { color: var(--text-3); background: var(--line-soft); font-style: italic; }

/* the live length readout on the shift form */
.shift-length { font-size: 13px; color: var(--text-2); margin: -4px 0 10px; }
.shift-length.over { color: var(--amber-text); font-weight: 500; }
.shift-length.bad  { color: var(--red); font-weight: 500; }

/* ==================================================== overtime */
.ot-sub { display: block; color: var(--text-3); font-size: 12px; }

/* the difference between what was claimed and what the day shows,
   called out only when it is big enough to be worth a second look */
.ot-gap {
    margin-inline-start: 6px; font-size: 12px; font-weight: 600;
    color: var(--amber-text); background: var(--amber-tint);
    border-radius: var(--radius); padding: 1px 6px;
}

.ot-measured { font-size: 13px; color: var(--text-2); margin: -4px 0 12px;
               display: flex; align-items: center; gap: 10px; }
.ot-measured.ok   { color: var(--accent-deep); }
.ot-measured.warn { color: var(--amber-text); }
