/* ==========================================================================
   نظام أرشفة المراسلات — واجهة "دفتر القيد"
   Design system for the correspondence archive.
   Loaded after Tailwind CDN; owns every visual decision in the app shell.
   RTL-first: logical properties only (inline-start/end), never left/right.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   Ink green is the house accent; the admin theme colour, when set, overrides it
   through --theme-* (see partials/theme-style.blade.php).
   -------------------------------------------------------------------------- */
:root {
    --ground: #f2f3ef;
    --surface: #ffffff;
    --raised: #f7f8f5;
    --active: #e6e8e1;

    --border: #dfe2da;
    --rule: #e9ebe5;
    --control: #c8cec3;

    --text: #14171a;
    --muted: #545b57;
    --faint: #6c736e;

    --accent: var(--theme-700, #0d5c4a);
    --accent-ink: var(--theme-800, #0a4739);
    --accent-wash: var(--theme-50, #eef3f1);
    --accent-line: var(--theme-200, #cfdcd7);

    --positive: #1f6f4a;
    --positive-bg: #e7f2ea;
    --positive-ink: #14522f;
    --negative: #a8281f;
    --negative-bg: #fbeceb;
    --negative-ink: #7d1c16;
    --notice: #8a5b12;
    --notice-bg: #fbf3e2;
    --notice-ink: #6d4610;
    --notice-line: #e8d5a8;

    --radius: 8px;
    --radius-sm: 6px;
    --radius-chip: 4px;

    --gap: 16px;
    --pad: 20px;
    --pad-page: 32px;
    --nav-w: 248px;
    --row: 48px;
    --control-h: 34px;

    --font: "IBM Plex Sans Arabic", "Tajawal", "Segoe UI", Tahoma, sans-serif;

    --fs-title: 22px;
    --fs-kpi: 26px;
    --fs-section: 15px;
    --fs-body: 14px;
    --fs-small: 12px;

    --ease: cubic-bezier(.2, .7, .3, 1);
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--app-bg, var(--ground));
    color: var(--text);
    font-family: var(--font);
    font-size: var(--fs-body);
    line-height: 1.55;
    font-feature-settings: "kern" 1;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.is-nav-open {
    overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0;
    margin: 0;
    color: var(--text);
}

a {
    color: var(--accent-ink);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

p { margin: 0 0 0.75em; }
p:last-child { margin-bottom: 0; }

hr {
    border: 0;
    border-top: 1px solid var(--rule);
    margin: 24px 0;
}

code, kbd, samp, pre {
    font-family: "Cascadia Mono", "Consolas", ui-monospace, monospace;
    font-size: 0.92em;
}

code {
    background: var(--raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius-chip);
    padding: 1px 5px;
    direction: ltr;
    display: inline-block;
}

::selection {
    background: var(--accent);
    color: #fff;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* utility for every figure that can be compared down a column */
.num, .tnum {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* --------------------------------------------------------------------------
   3. Shell
   Open plane: a labelled sidebar on the page ground, the canvas beside it.
   RTL: the sidebar is the first grid column, i.e. the right edge.
   -------------------------------------------------------------------------- */
.shell {
    display: grid;
    grid-template-columns: var(--nav-w) minmax(0, 1fr);
    min-height: 100vh;
}

.shell__nav {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(120,150,180,.72) transparent;
    display: flex;
    flex-direction: column;
    padding: 18px 14px 14px;
    border-inline-end: 1px solid var(--border);
    background: var(--app-bg, var(--ground));
}

.shell__main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 0;
    margin-block-end: 22px;
    color: var(--text);
}

.brand:hover { text-decoration: none; }

.brand__mark {
    width: 34px;
    height: 34px;
    flex: none;
    display: grid;
    place-items: center;
    border: 1.5px solid var(--accent);
    border-radius: 7px;
    color: var(--accent-ink);
    background: var(--surface);
}

.brand__mark svg { width: 20px; height: 20px; }

.brand__name {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    display: block;
}

.brand__scope {
    display: block;
    font-size: 11.5px;
    color: var(--muted);
    line-height: 1.5;
    margin-top: 2px;
}

/* nav groups */
.nav-group { margin-block-end: 18px; }

.nav-group__label {
    font-size: 11.5px;
    color: var(--muted);
    padding: 0 8px;
    margin-block-end: 6px;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.3;
}

.nav-link:hover {
    background: var(--active);
    text-decoration: none;
}

.nav-link svg {
    width: 16px;
    height: 16px;
    flex: none;
    stroke: var(--muted);
    stroke-width: 1.6;
    fill: none;
}

.nav-link.is-active {
    background: var(--active);
    color: var(--text);
    font-weight: 600;
}

.nav-link.is-active svg { stroke: var(--accent); }

.nav-link__count {
    margin-inline-start: auto;
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    color: var(--accent-ink);
    background: var(--accent-wash);
    border-radius: 999px;
    padding: 0 6px;
    line-height: 18px;
    min-width: 18px;
    text-align: center;
}

.shell__nav-foot {
    margin-block-start: auto;
    padding-block-start: 12px;
    border-block-start: 1px solid var(--border);
}

.user-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 6px 4px;
}

.user-row__avatar {
    width: 32px;
    height: 32px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent-wash);
    border: 1px solid var(--accent-line);
    color: var(--accent-ink);
    font-size: 12.5px;
    font-weight: 600;
}

.user-row__name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    display: block;
}

.user-row__meta {
    font-size: 11.5px;
    color: var(--muted);
    display: block;
    line-height: 1.4;
}

.nav-actions {
    display: flex;
    gap: 2px;
    padding: 2px 2px 0;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
}

.icon-btn:hover {
    background: var(--active);
    color: var(--text);
    text-decoration: none;
}

.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.6; fill: none; }

/* mobile bar + sheet */
.topbar {
    display: none;
    align-items: center;
    gap: 10px;
    height: 54px;
    padding: 0 16px;
    border-block-end: 1px solid var(--border);
    background: var(--app-bg, var(--ground));
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar__title {
    font-size: 14.5px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar__spacer { flex: 1; }

.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 23, 26, .38);
    z-index: 50;
}

/* --------------------------------------------------------------------------
   4. Canvas: title row + page body
   -------------------------------------------------------------------------- */
.page-wrap {
    width: 100%;
    max-width: 1360px;
    margin-inline: auto;
    padding: 28px var(--pad-page) 64px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-block-end: 20px;
}

.page-head__text { min-width: 0; }

.page-title {
    font-size: var(--fs-title);
    font-weight: 600;
    line-height: 1.25;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.page-sub {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--muted);
    max-width: 78ch;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-body { min-width: 0; }

/* Old per-page wrappers are neutralised so every page shares one frame. */
.page-body > .max-w-7xl,
.page-body > .max-w-5xl,
.page-body > .max-w-4xl,
.page-body > .max-w-3xl,
.page-body > .max-w-2xl {
    max-width: none;
    margin-inline: 0;
    margin-block: 0;
    padding-inline: 0;
}

.page-body > .py-12 { padding-block: 0; }

/* --------------------------------------------------------------------------
   5. Surfaces
   A panel is a tone step plus a 1px edge. No shadow unless it floats.
   -------------------------------------------------------------------------- */
.ui-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--pad);
    min-width: 0;
}

.ui-card--flush { padding: 0; }

.ui-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px var(--pad);
    border-block-end: 1px solid var(--rule);
    min-height: 48px;
}

.ui-card__head h2,
.ui-card__head h3 {
    font-size: var(--fs-section);
    font-weight: 600;
}

.ui-card__head .ui-card__meta {
    font-size: var(--fs-small);
    color: var(--muted);
}

.ui-card__body { padding: var(--pad); }

.ui-card__foot {
    padding: 12px var(--pad);
    border-block-start: 1px solid var(--rule);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack--sm { gap: 8px; }
.stack--lg { gap: 24px; }

.grid-panels {
    display: grid;
    gap: var(--gap);
}

@media (min-width: 900px) {
    .grid-panels--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-panels--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-panels--main-side { grid-template-columns: minmax(0, 1.9fr) minmax(280px, 1fr); }
    .grid-panels--side-main { grid-template-columns: minmax(280px, 1fr) minmax(0, 1.9fr); }
}

/* --------------------------------------------------------------------------
   6. KPI strip — one container split by rules, never a row of icon cards
   -------------------------------------------------------------------------- */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.kpi {
    padding: 14px 18px;
    border-inline-start: 1px solid var(--rule);
    min-width: 0;
}

.kpi:first-child { border-inline-start: 0; }

.kpi__label {
    display: block;
    font-size: var(--fs-small);
    color: var(--muted);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi__value {
    display: block;
    margin-block-start: 2px;
    font-size: var(--fs-kpi);
    font-weight: 500;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.kpi__value--lead { font-weight: 600; }
.kpi__note {
    display: block;
    font-size: 11.5px;
    color: var(--muted);
    margin-block-start: 2px;
    line-height: 1.4;
}

.kpi--alert .kpi__value { color: var(--negative); }
.kpi--calm .kpi__value { color: var(--positive); }

/* --------------------------------------------------------------------------
   7. Tables
   Rules and alignment. No zebra, no header band, tabular figures.
   -------------------------------------------------------------------------- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.ui-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.ui-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
    border-block-end: 1px solid var(--border);
    padding: 9px 12px;
    text-align: start;
    font-size: var(--fs-small);
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}

.ui-table tbody td {
    padding: 10px 12px;
    border-block-start: 1px solid var(--rule);
    vertical-align: middle;
    color: var(--text);
    transition: background-color .14s var(--ease);
}

.ui-table tbody tr:first-child td { border-block-start: 0; }

.ui-table tbody tr:hover td,
.ui-table tbody tr:focus-within td,
.ui-table tbody tr:active td { background: var(--accent-wash); }

.ui-table .cell-id { white-space: nowrap; }
.ui-table .cell-title { min-width: 200px; }
.ui-table .cell-actions { white-space: nowrap; text-align: end; }
.ui-table td.num,
.ui-table th.num { text-align: end; font-variant-numeric: tabular-nums; }

.ui-table .cell-sub {
    display: block;
    font-size: 11.5px;
    color: var(--muted);
    line-height: 1.45;
    margin-block-start: 1px;
}

.ui-table .ref {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    direction: ltr;
    display: inline-block;
    unicode-bidi: isolate;
}

.strong { font-weight: 600; }
.truncate-1 {
    display: block;
    max-width: 34ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

/* --------------------------------------------------------------------------
   8. Pills — one status mark per row, pale tint + dark ink of the same hue
   -------------------------------------------------------------------------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: none;
    white-space: nowrap;
    height: 20px;
    padding: 0 7px;
    border-radius: var(--radius-chip);
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1;
    background: var(--raised);
    color: var(--muted);
    border: 1px solid transparent;
}

.pill--ok { background: var(--positive-bg); color: var(--positive-ink); }
.pill--warn { background: var(--notice-bg); color: var(--notice-ink); }
.pill--bad { background: var(--negative-bg); color: var(--negative-ink); }
.pill--info { background: var(--accent-wash); color: var(--accent-ink); }

.pill__dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

/* --------------------------------------------------------------------------
   9. Buttons
   One filled action per screen. Everything else is an outline or a text action.
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: var(--control-h);
    padding: 0 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--control);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}

.btn:hover {
    background: var(--raised);
    text-decoration: none;
}

.btn:active { transform: translateY(.5px); }

.btn:disabled,
.btn[disabled] {
    opacity: .55;
    cursor: not-allowed;
}

.btn svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.7; fill: none; }

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn--primary:hover {
    background: var(--accent-ink);
    border-color: var(--accent-ink);
    color: #fff;
}

.btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}

.btn--ghost:hover {
    background: var(--accent-wash);
    color: var(--accent-ink);
}

.btn--danger {
    color: var(--negative-ink);
    border-color: #e6cfcc;
    background: var(--surface);
}

.btn--danger:hover { background: var(--negative-bg); }

.btn--sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: var(--radius-chip); }

.btn-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* text actions inside rows */
.link-action {
    color: var(--accent-ink);
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
}

.link-action:hover { text-decoration: underline; }
.link-action--muted { color: var(--muted); }
.link-action--danger { color: var(--negative-ink); }

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   10. Forms
   -------------------------------------------------------------------------- */
.field { margin-block-end: 14px; min-width: 0; }
.field:last-child { margin-block-end: 0; }

.field > label,
.label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text);
    margin-block-end: 5px;
    line-height: 1.4;
}

.label .req { color: var(--negative); margin-inline-start: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
input[type="url"],
input[type="tel"],
select,
textarea {
    width: 100%;
    min-height: var(--control-h);
    padding: 6px 10px;
    border: 1px solid var(--control);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.4;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
    max-width: 100%;
}

textarea { min-height: 84px; resize: vertical; }

select {
    appearance: none;
    padding-inline-end: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23545b57' stroke-width='1.6'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 9px center;
    background-size: 14px;
}

[dir="rtl"] select { background-position: left 9px center; }

input:hover, select:hover, textarea:hover { border-color: var(--accent-line); }

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

input::placeholder,
textarea::placeholder { color: var(--faint); opacity: 1; }

input[type="file"] {
    width: 100%;
    font-size: 13px;
    color: var(--muted);
    padding: 6px 8px;
    border: 1px dashed var(--control);
    border-radius: var(--radius-sm);
    background: var(--raised);
}

input[type="checkbox"],
input[type="radio"] {
    width: 15px;
    height: 15px;
    min-height: 0;
    padding: 0;
    accent-color: var(--accent);
    border-radius: 3px;
    flex: none;
}

input[type="color"] {
    width: 44px;
    height: 34px;
    min-height: 0;
    padding: 2px;
}

input[dir="ltr"],
input[type="email"],
input[type="date"],
input[type="number"] { text-align: start; }

.check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.4;
}

.hint {
    display: block;
    font-size: 11.5px;
    color: var(--muted);
    margin-block-start: 4px;
    line-height: 1.5;
}

.error-text {
    display: block;
    font-size: 11.5px;
    color: var(--negative-ink);
    margin-block-start: 4px;
    font-weight: 500;
}

.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid { border-color: var(--negative); }

/* filter bar: labels above fields, one row of controls */
.filters {
    display: grid;
    gap: 10px 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
}

.filters .field { margin: 0; }
.filters__search { grid-column: span 2; }
.filters__actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

/* field groups inside long forms */
.form-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    margin: 0 0 var(--gap);
    padding: 0;
}

.form-section > legend,
.form-section__head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px var(--pad) 0;
    font-size: var(--fs-section);
    font-weight: 600;
}

.form-section__hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
}

.form-section__body { padding: 12px var(--pad) var(--pad); }

.grid-2 { display: grid; gap: 0 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 0 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

.form-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-block-start: var(--gap);
    padding: 12px 0;
    background: var(--app-bg, var(--ground));
    border-block-start: 1px solid var(--border);
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2px 16px;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--raised);
    padding: 8px 10px;
}

.check-grid .check { padding: 3px 0; }

/* --------------------------------------------------------------------------
   11. Flash + notices + empty states
   -------------------------------------------------------------------------- */
.flash {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--positive-bg);
    background: var(--positive-bg);
    color: var(--positive-ink);
    font-size: 13px;
    margin-block-end: var(--gap);
}

.flash--error {
    background: var(--negative-bg);
    border-color: #f0d6d3;
    color: var(--negative-ink);
}

.flash--notice {
    background: var(--notice-bg);
    border-color: var(--notice-line);
    color: var(--notice-ink);
}

.flash svg { width: 16px; height: 16px; flex: none; margin-top: 1px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.notice {
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--notice-line);
    background: var(--notice-bg);
    color: var(--notice-ink);
    font-size: 12.5px;
    line-height: 1.6;
}

.empty {
    display: grid;
    gap: 6px;
    place-items: center;
    text-align: center;
    padding: 34px 16px;
    border: 1px dashed var(--control);
    border-radius: var(--radius-sm);
    background: var(--raised);
    color: var(--muted);
    font-size: 13px;
}

.empty strong { color: var(--text); font-weight: 600; }

.empty-cell {
    padding: 32px 16px !important;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* --------------------------------------------------------------------------
   12. Detail page: definition grid
   -------------------------------------------------------------------------- */
.dl-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin: 0;
}

.dl-grid > div {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 0;
    border-block-start: 1px solid var(--rule);
    min-width: 0;
}

.dl-grid > div:first-child,
.dl-grid > div:nth-child(2) { border-block-start: 0; }

.dl-grid dt {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.6;
}

.dl-grid dd {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.6;
    min-width: 0;
    overflow-wrap: anywhere;
}

.dl-single > div { grid-template-columns: 132px minmax(0, 1fr); }
.dl-single { grid-template-columns: minmax(0, 1fr); }
.dl-single > div:first-child { border-block-start: 0; }

/* tags for entities */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    border-radius: var(--radius-chip);
    background: var(--raised);
    border: 1px solid var(--rule);
    font-size: 12px;
    color: var(--text);
    margin: 2px 2px 2px 0;
    max-width: 100%;
}

.tag--accent { background: var(--accent-wash); border-color: var(--accent-line); color: var(--accent-ink); }

/* progress */
.progress {
    height: 6px;
    border-radius: 999px;
    background: var(--active);
    overflow: hidden;
}

.progress__bar {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width .3s var(--ease);
}

.progress__bar--done { background: var(--positive); }

.progress-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-block-end: 6px;
    font-size: 12.5px;
    color: var(--muted);
}

/* workflow list */
.flow-list { list-style: none; margin: 0; padding: 0; }

.flow-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 14px;
    padding: 12px 0;
    border-block-start: 1px solid var(--rule);
    align-items: start;
}

.flow-item:first-child { border-block-start: 0; }

.flow-item__name { font-size: 13.5px; font-weight: 600; }
.flow-item__kind { font-size: 11.5px; color: var(--muted); }
.flow-item__meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
    grid-column: 1 / -1;
}
.flow-item__meta b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.flow-item__note {
    grid-column: 1 / -1;
    font-size: 12px;
    color: var(--muted);
    background: var(--raised);
    border-radius: var(--radius-chip);
    padding: 6px 8px;
}

/* --------------------------------------------------------------------------
   13. Small data displays
   -------------------------------------------------------------------------- */
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.bar-list li { min-width: 0; }

.bar-list__top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    margin-block-end: 5px;
}

.bar-list__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-list__value {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    flex: none;
}

.bar-list__track {
    height: 3px;
    border-radius: 999px;
    background: var(--active);
    overflow: hidden;
}

.bar-list__fill {
    height: 100%;
    background: #b9c2b8;
    border-radius: 999px;
}

.bar-list li:first-child .bar-list__fill { background: var(--accent); }

.chart-box { width: 100%; height: 260px; min-height: 200px; }

.legend-table {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
}

.legend-table span { display: inline-flex; align-items: center; gap: 6px; }

.legend-table i {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: var(--accent);
    display: inline-block;
}

/* --------------------------------------------------------------------------
   14. Pagination (Laravel's Tailwind markup, restyled)
   -------------------------------------------------------------------------- */
nav[role="navigation"]:has(a[rel="prev"]),
nav[role="navigation"]:has(span[aria-current="page"]) {
    margin-block-start: var(--gap);
}

nav[role="navigation"] p {
    font-size: 12px;
    color: var(--muted);
    margin: 0;
}

nav[role="navigation"] a,
nav[role="navigation"] span[aria-current="page"] span,
nav[role="navigation"] span[aria-disabled="true"] span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-chip);
    background: var(--surface);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    margin-inline-start: 4px;
}

nav[role="navigation"] span[aria-current="page"] span {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

nav[role="navigation"] a:hover { background: var(--active); text-decoration: none; }

nav[role="navigation"] svg { width: 14px; height: 14px; }

/* --------------------------------------------------------------------------
   15. Settings: label column beside its panel
   -------------------------------------------------------------------------- */
.set-block {
    display: grid;
    gap: 8px 32px;
    padding-block: 24px;
    border-block-start: 1px solid var(--border);
}

.set-block:first-of-type { border-block-start: 0; padding-block-start: 0; }

@media (min-width: 1000px) {
    .set-block { grid-template-columns: minmax(220px, 320px) minmax(0, 1fr); }
    .set-block__head { position: sticky; top: 20px; align-self: start; }
}

.set-block__head h2 { font-size: var(--fs-section); margin-block-end: 4px; }
.set-block__head p { font-size: 12.5px; color: var(--muted); margin: 0; max-width: 42ch; }

.set-index {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-block-end: 4px;
}

.set-index a {
    font-size: 12.5px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
}

.set-index a:hover { background: var(--active); text-decoration: none; color: var(--text); }

/* --------------------------------------------------------------------------
   16. Guest (login) screen
   -------------------------------------------------------------------------- */
.guest {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    background: var(--app-bg, var(--ground));
}

@media (min-width: 900px) {
    .guest { grid-template-columns: minmax(0, 1fr) 460px; }
}

.guest__aside {
    display: none;
    padding: 48px;
    border-inline-end: 1px solid var(--border);
    background: var(--surface);
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
}

@media (min-width: 900px) {
    .guest__aside { display: flex; }
}

.guest__title {
    font-size: 30px;
    font-weight: 600;
    line-height: 1.25;
    max-width: 18ch;
    letter-spacing: -0.01em;
}

.guest__lede {
    font-size: 14px;
    color: var(--muted);
    max-width: 44ch;
    margin-block-start: 14px;
}

.guest__ledger {
    list-style: none;
    margin: 0;
    padding: 0;
    max-width: 42ch;
}

.guest__ledger li {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 14px;
    padding: 11px 0;
    border-block-start: 1px solid var(--rule);
    font-size: 13px;
    color: var(--muted);
}

.guest__ledger li:first-child { border-block-start: 0; }
.guest__ledger b {
    font-variant-numeric: tabular-nums;
    color: var(--text);
    font-weight: 600;
    direction: ltr;
    text-align: end;
}

.guest__main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
}

.guest__card { width: 100%; max-width: 380px; }

.guest__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-block-end: 28px;
}

.guest__foot {
    margin-block-start: 22px;
    font-size: 12px;
    color: var(--muted);
}

/* auth helper classes used by Breeze components */
.auth-field { margin-block-end: 14px; }
.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-block: 6px 18px;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   17. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1180px) {
    :root { --nav-w: 224px; --pad-page: 24px; }
}

@media (max-width: 1023px) {
    .shell { grid-template-columns: minmax(0, 1fr); }

    .shell__nav {
        position: fixed;
        inset-block: 0;
        inset-inline-end: 0;
        width: 288px;
        max-width: 86vw;
        height: 100%;
        z-index: 60;
        background: var(--surface);
        border-inline-start: 1px solid var(--border);
        border-inline-end: 0;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform .22s var(--ease);
        visibility: hidden;
    }

    /* In RTL, inline-start is the physical right edge. Keep the drawer there. */
    [dir="rtl"] .shell__nav {
        inset-inline-start: 0;
        inset-inline-end: auto;
        border-inline-start: 0;
        border-inline-end: 1px solid var(--border);
        transform: translateX(100%);
    }

    body.is-nav-open .shell__nav {
        transform: translateX(0);
        visibility: visible;
    }

    body.is-nav-open .nav-backdrop { display: block; }

    .topbar { display: flex; }

    .page-wrap { padding: 20px 20px 56px; }

    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters__search { grid-column: span 2; }
    .filters__actions { grid-column: span 2; justify-content: stretch; }
    .filters__actions .btn { flex: 1; }
}

@media (max-width: 760px) {
    :root { --pad-page: 16px; --pad: 16px; }

    .page-title { font-size: 20px; }
    .page-head { margin-block-end: 16px; }

    .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi { border-block-start: 1px solid var(--rule); }
    .kpi:nth-child(1),
    .kpi:nth-child(2) { border-block-start: 0; }
    .kpi:nth-child(odd) { border-inline-start: 0; }
    .kpi__value { font-size: 22px; }

    .dl-grid { grid-template-columns: minmax(0, 1fr); }
    .dl-grid > div { grid-template-columns: 112px minmax(0, 1fr); }
    .dl-grid > div:nth-child(2) { border-block-start: 1px solid var(--rule); }

    .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .span-2, .span-3 { grid-column: span 1; }

    .ui-table { min-width: 640px; }
    .table-wrap { border-radius: var(--radius-sm); }

    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }

    .flow-item { grid-template-columns: minmax(0, 1fr); }

    .chart-box { height: 200px; }
}

/* phone: rows become two-line entries when the table is marked as such */
@media (max-width: 640px) {
    table.ui-table--cards { min-width: 0; }

    .ui-table--cards thead { display: none; }

    .ui-table--cards tbody tr {
        display: block;
        padding: 12px 0;
        border-block-start: 1px solid var(--rule);
    }

    .ui-table--cards tbody tr:first-child { border-block-start: 0; }

    .ui-table--cards tbody td {
        display: block;
        padding: 0;
        border: 0;
    }

    .ui-table--cards tbody td[data-label]::before {
        content: attr(data-label) " ";
        font-size: 11.5px;
        color: var(--muted);
    }

    .ui-table--cards .cell-actions { text-align: start; margin-block-start: 8px; }
}

/* --------------------------------------------------------------------------
   18. Motion — feedback only; nothing performs an entrance
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* --------------------------------------------------------------------------
   19. Print
   -------------------------------------------------------------------------- */
@media print {
    .shell__nav,
    .topbar,
    .nav-backdrop,
    .page-actions,
    .no-print,
    .form-actions,
    .set-index { display: none !important; }

    .shell { display: block; }
    .page-wrap { max-width: none; padding: 0; }
    body { background: #fff; font-size: 11.5px; }

    .ui-card { border: 0; padding: 0; }
    .ui-table { font-size: 10.5px; }
    .ui-card__head { padding-inline: 0; }

    a { color: #000; text-decoration: none; }

    @page { size: A4; margin: 14mm; }
}


/* --------------------------------------------------------------------------
   20. Framed-sheet refresh — Taste Skill / correspondence archive
   The work surface stays white; blue-green marks actions, selection, focus and workflow.
   -------------------------------------------------------------------------- */
:root {
    --ground: #f2f6f7;
    --surface: #ffffff;
    --raised: #f6f9fa;
    --active: #e9eff0;
    --border: #e1e8e9;
    --rule: #edf1f2;
    --control: #b9c9cb;
    --text: #172326;
    --muted: #536266;
    --faint: #68777a;
    --accent: var(--theme-700, #1b6c80);
    --accent-ink: var(--theme-800, #155668);
    --accent-wash: var(--theme-50, #eef6f7);
    --accent-line: var(--theme-200, #c9dfe2);
    --positive: #1e7b4f;
    --positive-bg: #e6f4eb;
    --positive-ink: #145b37;
    --negative: #b4232c;
    --negative-bg: #fff0ef;
    --negative-ink: #861b22;
    --notice: #8a5b12;
    --notice-bg: #fff7e6;
    --notice-ink: #70470c;
    --notice-line: #ecd9aa;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-chip: 4px;
    --gap: 20px;
    --pad: 20px;
    --pad-page: 28px;
    --nav-w: 228px;
    --row: 48px;
    --control-h: 36px;
    --fs-title: 24px;
    --fs-section: 16px;
}

body { background: var(--app-bg, var(--ground)); color: var(--text); }
.shell { grid-template-columns: var(--nav-w) minmax(0, 1fr); }
.shell__nav {
    padding: 22px 16px 16px;
    border: 0;
    background: var(--app-bg, var(--ground));
}
.shell__main {
    min-height: calc(100vh - 8px);
    margin-inline-start: 8px;
    margin-block-end: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}
.brand { gap: 11px; padding-inline: 8px; margin-block-end: 28px; }
.brand__mark {
    width: 38px;
    height: 38px;
    border: 1px solid var(--accent-line);
    border-radius: 8px;
    background: transparent;
    color: var(--accent-ink);
}
.brand__mark svg { width: 21px; height: 21px; }
.brand__name { font-size: 15px; }
.brand__scope { font-size: 12px; }
.nav-group { margin-block-end: 20px; }
.nav-group__label {
    margin-block-end: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}
.nav-list { gap: 3px; }
.nav-link {
    position: relative;
    min-height: 42px;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--muted);
    transition: color .16s var(--ease), background-color .16s var(--ease);
}
.nav-link:hover { background: var(--raised); color: var(--accent-ink); }
.nav-link svg { width: 17px; height: 17px; color: currentColor; }
.nav-link.is-active { background: var(--active); color: var(--text); font-weight: 600; }
.nav-link.is-active::before {
    position: absolute;
    inset-block: 9px;
    inset-inline-start: 0;
    width: 2px;
    border-radius: 2px;
    background: var(--accent);
    content: "";
}
.nav-link.is-active svg { stroke: var(--accent-ink); }
.nav-link__count {
    color: var(--accent-ink);
    background: var(--accent-wash);
    border: 1px solid var(--accent-line);
    font-weight: 600;
}
.shell__nav-foot { border-color: var(--border); }
.user-row__avatar { background: var(--surface); border-color: var(--border); }
.page-wrap { max-width: 1360px; padding: 28px var(--pad-page) 52px; }
.page-body > .page-wrap { max-width: none; margin: 0; padding: 0; }
.page-head { align-items: center; margin-block-end: 24px; }
.page-title { font-size: var(--fs-title); letter-spacing: -.01em; }
.page-sub { margin-block-start: 6px; font-size: 14px; }
.ui-card { border-color: var(--border); border-radius: var(--radius); }
.ui-card__head, .ui-card__foot { border-color: var(--rule); }
.btn { min-height: var(--control-h); border-radius: var(--radius-sm); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn--ghost:hover { background: var(--accent-wash); color: var(--accent-ink); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    border-color: var(--control);
    border-radius: var(--radius-sm);
    transition: border-color .16s var(--ease), background-color .16s var(--ease);
}
input:not([type="checkbox"]):not([type="radio"]):hover, select:hover, textarea:hover { border-color: #829da1; }
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus {
    border-color: var(--accent);

    outline: 0;
}
.ui-table thead th { color: var(--muted); background: transparent; }
.ui-table tbody tr:hover td,
.ui-table tbody tr:focus-within td,
.ui-table tbody tr:active td { background: var(--accent-wash); }
.ui-table .ref { color: var(--accent-ink); font-weight: 600; }
.tag--accent { background: var(--accent-wash); border-color: var(--accent-line); color: var(--accent-ink); }
.progress__bar { background: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:not([type="checkbox"]):not([type="radio"]):focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (max-width: 1023px) {
    .shell__nav { padding: 20px 16px 16px; }
    .shell__main {
        min-height: calc(100vh - 48px);
        margin: 0;
        border: 0;
        border-radius: 0;
    }
    .topbar { height: 48px; border: 0; background: var(--app-bg, var(--ground)); }
    .topbar .icon-btn { width: 40px; height: 40px; }
    .page-wrap { padding: 22px 24px 48px; }
}
@media (max-width: 760px) {
    :root { --pad-page: 16px; --pad: 16px; --gap: 16px; }
    .page-wrap { padding: 20px 16px 40px; }
    .page-title { font-size: 21px; }
    .nav-link { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
    .nav-link, .btn, input, select, textarea { transition: none; }
}

.dashboard-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px 20px;
    margin-block-end: 20px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--raised);
}
.dashboard-tools__period { display: flex; align-items: center; gap: 14px; min-width: 0; }
.dashboard-tools__label { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.range-tabs {
    display: flex;
    min-width: 0;
    border-block-end: 1px solid var(--border);
}
.range-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding-inline: 12px;
    border-block-end: 2px solid transparent;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    transition: color .16s var(--ease), border-color .16s var(--ease), background-color .16s var(--ease);
}
.range-tab:hover { background: var(--accent-wash); color: var(--accent-ink); text-decoration: none; }
.range-tab.is-active { border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.dashboard-range-form { display: flex; align-items: flex-end; gap: 8px; }
.dashboard-range-field { display: grid; gap: 4px; color: var(--muted); font-size: 11.5px; }
.dashboard-range-field input { width: 150px; min-height: 36px; padding-inline: 8px; background: var(--surface); color: var(--text); }
.dashboard-range-form .btn { flex: none; }

@media (max-width: 1180px) {
    .dashboard-tools { grid-template-columns: minmax(0, 1fr); }
    .dashboard-range-form { justify-content: flex-start; }
}
@media (max-width: 760px) {
    .dashboard-tools { gap: 12px; padding: 12px; }
    .dashboard-tools__period { display: grid; gap: 6px; }
    .range-tabs { overflow-x: auto; scrollbar-width: thin; }
    .range-tab { padding-inline: 10px; }
    .dashboard-range-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-range-field input { width: 100%; }
    .dashboard-range-form .btn { width: 100%; }
}

.letters-filter {
    margin-block-end: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.letters-filter__grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: end;
    gap: 14px 12px;
}
.letters-filter__field { display: grid; min-width: 0; gap: 5px; color: var(--muted); font-size: 12px; }
.letters-filter__field > span,
.letters-filter__field > label,
.letters-filter__field > label:first-child { line-height: 1.35; }
.letters-filter__field input,
.letters-filter__field select,
.letters-filter__field > .relative { width: 100%; min-width: 0; }
.letters-filter__field > .relative { display: block; }
.letters-filter__field .relative > input { width: 100%; }
.letters-filter__search { grid-column: span 4; }
.letters-filter__type,
.letters-filter__status,
.letters-filter__group,
.letters-filter__subject { grid-column: span 2; }
.letters-filter__entity { grid-column: span 4; }
.letters-filter__dates {
    grid-column: span 4;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.letters-filter__actions { grid-column: span 4; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.letters-filter .btn { min-height: 36px; }

@media (max-width: 1023px) {
    .letters-filter__grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .letters-filter__search, .letters-filter__entity, .letters-filter__dates, .letters-filter__actions { grid-column: span 6; }
    .letters-filter__type, .letters-filter__status, .letters-filter__group, .letters-filter__subject { grid-column: span 3; }
}
@media (max-width: 600px) {
    .letters-filter { padding: 12px; }
    .letters-filter__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .letters-filter__search, .letters-filter__entity, .letters-filter__dates, .letters-filter__actions { grid-column: span 2; }
    .letters-filter__type, .letters-filter__status, .letters-filter__group, .letters-filter__subject { grid-column: span 2; }
    .letters-filter__dates { grid-template-columns: minmax(0, 1fr); }
    .letters-filter__actions .btn { flex: 1; }
}

.reports-filter {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(280px, 1fr) auto;
    align-items: end;
    gap: 14px;
    margin-block-end: 20px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.reports-filter__field { display: grid; min-width: 0; gap: 5px; color: var(--muted); font-size: 12px; }
.reports-filter__field input, .reports-filter__field select { width: 100%; min-height: 36px; }
.reports-filter__actions { display: flex; gap: 8px; align-items: center; }
.reports-kpis { margin-block-end: 20px; }
.reports-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr);
    align-items: start;
    gap: 20px;
    margin-block-end: 20px;
}
.reports-card { min-width: 0; padding: 0; }
.reports-bars, .reports-rank-list { display: grid; gap: 10px; padding: 16px 20px 20px; }
.reports-legend { display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 12px; }
.reports-legend span { display: inline-flex; align-items: center; gap: 6px; }
.reports-legend i { width: 8px; height: 8px; border-radius: 2px; }
.reports-legend__incoming { background: var(--accent); }
.reports-legend__outgoing { background: #4a7eb2; }
.reports-bar-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 38px;
    gap: 10px;
    align-items: center;
    min-height: 22px;
    font-size: 12px;
}
.reports-bar-row__label { color: var(--muted); white-space: nowrap; }
.reports-bar-row__track, .reports-rank-item__track {
    display: flex;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--raised);
}
.reports-bar-row__segment { display: block; height: 100%; }
.reports-bar-row__segment--incoming { background: var(--accent); }
.reports-bar-row__segment--outgoing { background: #4a7eb2; }
.reports-bar-row__value, .reports-rank-item__value { color: var(--text); font-variant-numeric: tabular-nums; text-align: end; }
.reports-rank-list { gap: 14px; }
.reports-rank-item { display: grid; min-width: 0; gap: 6px; }
.reports-rank-item__top { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 12px; min-width: 0; font-size: 12.5px; }
.reports-rank-item__name { min-width: 0; overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.reports-rank-item__track > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.reports-subjects { padding: 0; }
.reports-subject-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 24px; padding: 16px 20px 20px; }
.reports-empty { margin: 0; color: var(--muted); font-size: 13px; }
@media (max-width: 1023px) {
    .reports-filter { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
    .reports-filter__actions { grid-column: span 2; }
    .reports-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
    .reports-filter { grid-template-columns: minmax(0, 1fr); padding: 12px; }
    .reports-filter__actions { grid-column: auto; }
    .reports-filter__actions .btn { flex: 1; }
    .reports-bars, .reports-rank-list, .reports-subject-list { padding: 14px; }
    .reports-subject-list { grid-template-columns: minmax(0, 1fr); }
}

.directory-search {
    display: grid;
    gap: 6px;
    margin-block-end: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
}
.directory-search__controls { display: flex; gap: 8px; align-items: center; }
.directory-search__controls input { width: min(100%, 480px); min-height: 38px; }
.directory-search__controls .btn { flex: none; }
@media (max-width: 600px) {
    .directory-search { padding: 12px; }
    .directory-search__controls { flex-wrap: wrap; }
    .directory-search__controls input { width: 100%; }
    .directory-search__controls .btn { flex: 1; }
}

/* Keep the content canvas full-width when the mobile navigation leaves grid flow. */
@media (max-width: 1023px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
}

/* Shared institutional visual system for operational pages. Dashboard keeps its approved page-specific system. */
body.institutional-app {
    font-family: "Cairo", Tahoma, sans-serif;
}

body.institutional-app:not(.dashboard-page) {
    --ground: #f4f7fb;
    --app-bg: #f4f7fb;
    --surface: #fff;
    --raised: #f7faff;
    --active: #eaf3fc;
    --border: #d7e5f3;
    --rule: #e8eff6;
    --control: #cbdcec;
    --text: #183650;
    --muted: #5f7892;
    --faint: #71879c;
    --accent: #185a9d;
    --accent-ink: #123f70;
    --accent-wash: #edf4fb;
    --accent-line: #cfdeec;
    --radius: 13px;
    --radius-sm: 9px;
    --radius-chip: 999px;
    --pad-page: clamp(14px, 2.2vw, 30px);
    --font: "Cairo", Tahoma, sans-serif;
    background: var(--ground);
    color: var(--text);
    font-family: var(--font);
}

body.institutional-app button,
body.institutional-app input,
body.institutional-app select,
body.institutional-app textarea,
body.guest-page button,
body.guest-page input,
body.guest-page select,
body.guest-page textarea { font-family: "Cairo", Tahoma, sans-serif; }

body.institutional-app:not(.dashboard-page) .topbar {
    border-color: #d9e6f3;
    background: rgba(255,255,255,.96);
    box-shadow: 0 4px 16px rgba(18,63,112,.055);
}

body.institutional-app:not(.dashboard-page) .topbar__title,
body.institutional-app:not(.dashboard-page) .topbar .icon-btn { color: #123f70; }

body.institutional-app:not(.dashboard-page) .shell__nav {
    border: 0;
    background: linear-gradient(180deg, #123f72 0%, #0a315e 70%, #0b3a6c 100%);
    color: #f5f9ff;
}

body.institutional-app:not(.dashboard-page) .shell__nav .brand { color: #fff; }
body.institutional-app:not(.dashboard-page) .shell__nav .brand__mark { border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.1); color: #fff; }
body.institutional-app:not(.dashboard-page) .shell__nav .brand__scope,
body.institutional-app:not(.dashboard-page) .shell__nav .nav-group__label,
body.institutional-app:not(.dashboard-page) .shell__nav .user-row__meta { color: #a9c8e8; }
body.institutional-app:not(.dashboard-page) .shell__nav .nav-link { color: #e7f1fc; }
body.institutional-app:not(.dashboard-page) .shell__nav .nav-link svg { color: #d1e5fa; stroke: currentColor; }
body.institutional-app:not(.dashboard-page) .shell__nav .nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
body.institutional-app:not(.dashboard-page) .shell__nav .nav-link.is-active { background: #176ac0; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }
body.institutional-app:not(.dashboard-page) .shell__nav .shell__nav-foot { border-color: rgba(226,240,255,.2); }
body.institutional-app:not(.dashboard-page) .shell__nav .user-row__name { color: #fff; }
body.institutional-app:not(.dashboard-page) .shell__nav .user-row__avatar { border-color: rgba(255,255,255,.22); background: rgba(255,255,255,.13); color: #fff; }
body.institutional-app:not(.dashboard-page) .shell__nav .nav-actions .icon-btn { border-color: rgba(255,255,255,.24); background: rgba(255,255,255,.09); color: #fff; }

body.institutional-app:not(.dashboard-page) .shell__main { background: #f4f7fb; }
body.institutional-app:not(.dashboard-page) .shell__main > .page-wrap { max-width: none; padding: 24px clamp(14px, 2vw, 28px) 40px; }
body.institutional-app:not(.dashboard-page) .page-body { min-width: 0; }
body.institutional-app:not(.dashboard-page) .page-body > .page-wrap { padding-top: 8px; }

.page-banner {
    position: relative;
    isolation: isolate;
    min-height: 138px;
    align-items: center;
    overflow: hidden;
    margin: 0 0 18px;
    padding: 22px clamp(18px, 2.5vw, 34px);
    border: 1px solid #d4e4f4;
    border-radius: 18px;
    background: linear-gradient(108deg, #fff 0%, #f6faff 56%, #e8f2fd 100%);
    box-shadow: 0 9px 24px rgba(20,74,126,.055);
}

.page-banner::before,
.page-banner::after {
    position: absolute;
    z-index: -1;
    content: "";
    pointer-events: none;
}

.page-banner::before {
    inset-block: -55%;
    inset-inline-end: 18%;
    width: 28%;
    transform: rotate(38deg);
    background: linear-gradient(90deg, transparent, rgba(173,208,241,.13), transparent);
}

.page-banner::after {
    inset-inline-start: 0;
    inset-block-end: 0;
    width: min(52%, 560px);
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(67,137,202,.4), transparent);
}

.page-banner__copy { position: relative; z-index: 2; min-width: 0; flex: 1 1 auto; }
.page-banner__eyebrow { display: block; margin-bottom: 4px; color: #3575b4; font-size: 11px; font-weight: 700; letter-spacing: .025em; }
.page-banner .page-head__text { max-width: 100%; }
.page-banner .page-head__text h1,
.page-banner .page-head__text h2 { margin: 0; color: #123f70; font-family: inherit; font-size: clamp(20px, 2vw, 27px); font-weight: 800; line-height: 1.35; }
.page-banner__description { max-width: 65ch; margin: 5px 0 0; color: #637d98; font-size: 12px; line-height: 1.7; }
.page-banner__art { position: relative; display: grid; width: clamp(110px, 17vw, 180px); height: 84px; flex: 0 0 auto; place-items: center; margin-inline-start: 14px; }
.page-banner__art img { position: relative; z-index: 1; display: block; width: auto; height: auto; max-width: 100%; max-height: 72px; object-fit: contain; filter: drop-shadow(0 8px 8px rgba(31,82,130,.14)); }
.page-banner__art-shape { position: absolute; display: block; border: 1px solid rgba(83,146,204,.13); transform: rotate(45deg); }
.page-banner__art-shape--one { width: 80px; height: 80px; border-radius: 20px; background: rgba(218,236,252,.25); }
.page-banner__art-shape--two { width: 128px; height: 50px; border-radius: 50%; background: rgba(228,241,253,.3); }
.page-banner .page-actions { position: relative; z-index: 2; }

body.institutional-app:not(.dashboard-page) .ui-card {
    border-color: #d9e6f3;
    border-radius: 14px;
    box-shadow: 0 7px 22px rgba(23,73,122,.045);
}
body.institutional-app:not(.dashboard-page) .ui-card__head { border-color: #e7eef6; }
body.institutional-app:not(.dashboard-page) .ui-card__head h2,
body.institutional-app:not(.dashboard-page) .ui-card__head h3 { color: #173f6b; }
body.institutional-app:not(.dashboard-page) .ui-table thead th { background: #eef5fc; color: #244f79; }
body.institutional-app:not(.dashboard-page) .ui-table tbody td { border-color: #e8eff6; }
body.institutional-app:not(.dashboard-page) input:not([type="checkbox"]):not([type="radio"]),
body.institutional-app:not(.dashboard-page) select,
body.institutional-app:not(.dashboard-page) textarea {
    min-height: 38px;
    border-color: #d1e0ee;
    border-radius: 9px;
    background-color: #f0f6fc;
    color: #183e67;
}
body.institutional-app:not(.dashboard-page) textarea { min-height: 96px; }
body.institutional-app:not(.dashboard-page) input:not([type="checkbox"]):not([type="radio"]):focus,
body.institutional-app:not(.dashboard-page) select:focus,
body.institutional-app:not(.dashboard-page) textarea:focus { border-color: #5c9fe0; background-color: #fff; box-shadow: 0 0 0 3px rgba(50,126,201,.13); }
body.institutional-app:not(.dashboard-page) :focus-visible { outline-color: #3883c4; }
body.institutional-app:not(.dashboard-page) .btn--primary { background: #185a9d; border-color: #185a9d; }
body.institutional-app:not(.dashboard-page) .btn--primary:hover { background: #123f70; border-color: #123f70; }

/* Guest authentication pages share the same Cairo and institutional blue identity. */
body.guest-page {
    --ground: #f4f7fb;
    --app-bg: #f4f7fb;
    --surface: #fff;
    --border: #d7e5f3;
    --control: #cbdcec;
    --text: #183650;
    --muted: #5f7892;
    --accent: #185a9d;
    --accent-ink: #123f70;
    --accent-wash: #edf4fb;
    --accent-line: #cfdeec;
    min-height: 100vh;
    background: #f3f7fb;
    color: #183650;
    font-family: "Cairo", Tahoma, sans-serif;
}
.guest--institutional { grid-template-columns: minmax(0, 1fr); place-items: center; min-height: 100vh; padding: clamp(16px, 3vw, 40px); }
.guest--institutional .guest__aside {
    position: relative;
    display: flex;
    min-height: 100vh;
    overflow: hidden;
    padding: clamp(28px, 5vw, 72px);
    border: 0;
    background: linear-gradient(145deg, #123f72 0%, #0d3766 55%, #0a315e 100%);
    color: #f4f8fd;
}
body.guest-page .guest--institutional .guest__aside { display: none; }
.guest--institutional .guest__aside::before,
.guest--institutional .guest__aside::after { position: absolute; content: ""; border: 1px solid rgba(201,227,250,.1); transform: rotate(45deg); pointer-events: none; }
.guest--institutional .guest__aside::before { width: 300px; height: 300px; inset-inline-end: -130px; inset-block-end: -110px; border-radius: 48px; background: rgba(255,255,255,.025); }
.guest--institutional .guest__aside::after { width: 160px; height: 160px; inset-inline-start: -80px; inset-block-start: 38%; border-radius: 32px; }
.guest__institution { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; }
.guest__institution img { width: 58px; height: 58px; padding: 7px; border-radius: 16px; background: #fff; object-fit: contain; }
.guest__institution strong,
.guest__institution small { display: block; }
.guest__institution strong { color: #fff; font-size: 16px; font-weight: 700; }
.guest__institution small { margin-top: 3px; color: #b8d2ed; font-size: 12px; }
.guest__hero { position: relative; z-index: 1; display: flex; flex: 1; flex-direction: column; justify-content: center; padding-block: 32px; }
.guest__eyebrow { color: #77b5ef; font-size: 12px; font-weight: 700; }
.guest__title { max-width: 17ch; margin: 8px 0 0; color: #fff; font-size: clamp(28px, 3.4vw, 43px); font-weight: 800; line-height: 1.45; }
.guest__lede { max-width: 46ch; margin: 12px 0 0; color: #c1d7ed; font-size: 14px; line-height: 1.9; }
.guest__visual { position: relative; display: grid; width: min(74%, 420px); height: clamp(170px, 25vw, 280px); place-items: center; margin: 12px auto 0; }
.guest__visual img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 18px 20px rgba(0,0,0,.25)); }
.guest__visual-shape { position: absolute; width: 74%; height: 68%; border: 1px solid rgba(186,218,248,.14); border-radius: 36px; background: rgba(201,226,249,.04); transform: rotate(-9deg); }
.guest__visual-shape--two { width: 54%; height: 80%; border-radius: 50%; transform: rotate(16deg); }
.guest__footnote { position: relative; z-index: 1; margin: 0; color: #a9c8e8; font-size: 11px; }
.guest--institutional .guest__main { display: grid; width: min(100%, 500px); min-height: 0; align-items: center; justify-items: center; padding: 0; background: transparent; }
.guest__card--institutional { width: min(100%, 440px); padding: clamp(24px, 3vw, 34px); border: 1px solid #dce8f4; border-radius: 20px; background: rgba(255,255,255,.97); box-shadow: 0 18px 48px rgba(18,63,112,.1); }
.guest__mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; color: #123f70; font-size: 13px; font-weight: 700; }
.guest__mobile-brand img { width: 42px; height: 42px; padding: 4px; border: 1px solid #deebf7; border-radius: 12px; object-fit: contain; }
.guest__form-heading { margin-bottom: 24px; }
.guest__form-heading h1 { margin: 3px 0 0; color: #123f70; font-size: 25px; font-weight: 800; }
.guest__form-heading p { margin: 5px 0 0; color: #71879c; font-size: 12px; }
.guest-form { display: grid; gap: 18px; }
.guest-form__field { display: grid; gap: 3px; }
.guest-form__options { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.guest-form__link { color: #185a9d; font-size: 12px; font-weight: 600; }
.guest-form__link:hover { color: #123f70; text-decoration: underline; }
.guest-form__submit .btn { width: 100%; min-height: 46px; border-radius: 11px; }
body.guest-page .label { color: #42617f; font-size: 12px; font-weight: 700; }
body.guest-page input:not([type="checkbox"]):not([type="radio"]),
body.guest-page select,
body.guest-page textarea { min-height: 44px; border: 1px solid #d1e0ee; border-radius: 10px; background: #f0f6fc; color: #183e67; }
body.guest-page input:focus { border-color: #5c9fe0; background: #fff; box-shadow: 0 0 0 3px rgba(50,126,201,.13); outline: 0; }

@media (max-width: 1023px) {
    .page-banner { min-height: 122px; }
    .page-banner__art { width: 132px; height: 78px; }
    .page-banner__art img { max-height: 66px; }
}
@media (max-width: 760px) {
    body.institutional-app:not(.dashboard-page) .shell__main > .page-wrap { padding: 14px 12px 28px; }
    .page-banner { min-height: 104px; gap: 6px; margin-bottom: 14px; padding: 16px; border-radius: 14px; }
    .page-banner__art { width: 92px; height: 62px; margin-inline-start: 0; }
    .page-banner__art img { max-height: 50px; }
    .page-banner .page-head__text h1,
    .page-banner .page-head__text h2 { font-size: 20px; }
    .page-banner__description { max-width: 36ch; font-size: 11px; }
    .page-banner__eyebrow { font-size: 10px; }
    body.guest-page .guest--institutional { padding: 16px; }
    body.guest-page .guest--institutional .guest__main { min-height: 0; padding: 0; }
    body.guest-page .guest__card--institutional { max-width: 440px; padding: 24px; border-radius: 18px; }
}

@media (max-width: 420px) {
    .page-banner { padding: 13px; }
    .page-banner__art { width: 68px; height: 52px; }
    .page-banner__art img { max-height: 42px; }
    .page-banner__description { max-width: 27ch; }
    .page-banner__copy .page-actions { gap: 6px; }
    .page-banner__copy .page-actions .btn { min-height: 34px; padding-inline: 9px; font-size: 11px; }
    body.guest-page .guest--institutional .guest__main { padding: 12px; }
    body.guest-page .guest__card--institutional { padding: 20px 17px; }
    body.guest-page .guest__form-heading h1 { font-size: 22px; }
}

body.institutional-app .shell__nav::-webkit-scrollbar { width: 8px; }
body.institutional-app .shell__nav::-webkit-scrollbar-track { background: transparent; }
body.institutional-app:not(.dashboard-page) .shell__nav::-webkit-scrollbar-thumb { border: 2px solid #123f72; border-radius: 8px; background: rgba(210,231,250,.55); }
body.institutional-app:not(.dashboard-page) .shell__nav { scrollbar-color: rgba(210,231,250,.55) #123f72; }

/* Login-only split panel: institutional branding on the right, sign-in on the left. */
body.guest-page .guest--institutional.guest--login {
    display: grid;
    grid-template-columns: minmax(390px, 360px) minmax(330px, 480px);
    align-items: stretch;
    justify-content: center;
    width: min(100%, 460px);
    min-height: 500px;
    margin: auto;
    padding: clamp(18px, 4vw, 48px);
    place-items: stretch;
    background: transparent;
}
body.guest-page .guest--institutional.guest--login .guest__aside {
    display: flex;
    grid-column: 1;
    grid-row: 1;
    min-height: 500px;
    align-items: center;
    justify-content: center;
    padding: 36px;
    border-radius: 0 22px 22px 0;
    box-shadow: 0 20px 52px rgba(13, 49, 91, .18);
}
body.guest-page .guest--institutional.guest--login .guest__hero,
body.guest-page .guest--institutional.guest--login .guest__footnote { display: none; }
body.guest-page .guest--institutional.guest--login .guest__institution { justify-content: center; gap: 16px; }
body.guest-page .guest--institutional.guest--login .guest__institution img { width: 82px; height: 82px; border-radius: 20px; }
body.guest-page .guest--institutional.guest--login .guest__institution strong { font-size: clamp(18px, 2vw, 23px); line-height: 1.6; }
body.guest-page .guest--institutional.guest--login .guest__institution small { font-size: 13px; }
body.guest-page .guest--institutional.guest--login .guest__main {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    min-height: 500px;
    padding: 0;
    border-radius: 22px 0 0 22px;
    background: #fff;
    box-shadow: 0 20px 52px rgba(18, 63, 112, .12);
}
body.guest-page .guest--institutional.guest--login .guest__card--institutional {
    width: 100%;
    max-width: 520px;
    padding: clamp(32px, 5vw, 58px);
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
body.guest-page .guest--institutional.guest--login .guest__mobile-brand { display: none; }

@media (max-width: 820px) {
    body.guest-page .guest--institutional.guest--login {
        grid-template-columns: minmax(0, 1fr);
        width: min(100%, 560px);
        min-height: 100vh;
        padding: 16px;
    }
    body.guest-page .guest--institutional.guest--login .guest__aside {
        grid-column: 1;
        grid-row: 1;
        min-height: 116px;
        padding: 18px;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 8px 24px rgba(13, 49, 91, .12);
    }
    body.guest-page .guest--institutional.guest--login .guest__institution img { width: 58px; height: 58px; border-radius: 15px; }
    body.guest-page .guest--institutional.guest--login .guest__institution strong { font-size: 16px; }
    body.guest-page .guest--institutional.guest--login .guest__institution small { font-size: 11px; }
    body.guest-page .guest--institutional.guest--login .guest__main {
        grid-column: 1;
        grid-row: 2;
        width: 100%;
        min-height: 0;
        border-radius: 0 0 18px 18px;
    }
    body.guest-page .guest--institutional.guest--login .guest__card--institutional { max-width: none; padding: 28px 24px; }
}
