/* =====================================================================
   IT Asset Management System - stylesheet

   Organised as: tokens, reset, layout, navigation, components, utilities.
   No build step and no framework: one file, served directly by Apache.
   ===================================================================== */

/* ---------------------------------------------------------------- tokens */

:root {
    --bg:            #f4f6f9;
    --surface:       #ffffff;
    --surface-alt:   #f8fafc;
    --border:        #e2e8f0;
    --border-strong: #cbd5e1;

    --text:          #0f172a;
    --text-muted:    #64748b;
    --text-faint:    #94a3b8;
    --text-invert:   #f8fafc;

    --brand:         #1d4ed8;
    --brand-dark:    #1e40af;
    --brand-light:   #eff6ff;

    --ok:            #047857;
    --ok-bg:         #ecfdf5;
    --info:          #1d4ed8;
    --info-bg:       #eff6ff;
    --warn:          #b45309;
    --warn-bg:       #fffbeb;
    --danger:        #b91c1c;
    --danger-bg:     #fef2f2;
    --muted-bg:      #f1f5f9;

    --sidebar-bg:    #0f172a;
    --sidebar-text:  #cbd5e1;
    --sidebar-hover: #1e293b;

    --radius:        8px;
    --radius-sm:     6px;
    --radius-lg:     12px;

    --shadow-sm:     0 1px 2px rgba(15, 23, 42, .06);
    --shadow:        0 1px 3px rgba(15, 23, 42, .1), 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-lg:     0 10px 24px rgba(15, 23, 42, .12);

    --sidebar-w:     248px;
    --topbar-h:      60px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas,
            "Liberation Mono", monospace;
}

/* ----------------------------------------------------------------- reset */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { vertical-align: middle; }
.icon { flex-shrink: 0; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- layout */

.shell { display: flex; min-height: 100vh; }

.main {
    flex: 1;
    min-width: 0;             /* lets wide tables scroll instead of pushing */
    display: flex;
    flex-direction: column;
}

.content { padding: 22px 26px 60px; flex: 1; }

.page__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.page__lead { color: var(--text-muted); margin: 4px 0 0; }
.page__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* -------------------------------------------------------------- sidebar */

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar__logo {
    width: 34px; height: 34px; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--brand);
    color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 700; font-size: 13px; letter-spacing: .5px;
}

.sidebar__brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.sidebar__brand-text strong { color: #fff; font-size: 14px; }
.sidebar__brand-text small { color: var(--text-faint); font-size: 11px; }

.sidebar__nav { padding: 10px 10px 20px; flex: 1; }

.sidebar__section {
    padding: 14px 8px 6px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #64748b;
    font-weight: 600;
}

.navlink {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 13.5px;
    margin-bottom: 1px;
}

.navlink:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }

.navlink--active {
    background: var(--brand);
    color: #fff;
    font-weight: 500;
}

.sidebar__footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: 11px;
    color: #475569;
}

/* --------------------------------------------------------------- topbar */

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
    padding: 0 18px;
    position: sticky; top: 0; z-index: 40;
}

.topbar__spacer { flex: 1; }

.topbar__toggle {
    display: none;
    flex-direction: column; gap: 4px;
    background: none; border: 0; cursor: pointer; padding: 6px;
}
.topbar__toggle span { display: block; width: 18px; height: 2px; background: var(--text); }

.globalsearch { flex: 1; max-width: 520px; position: relative; }

.globalsearch input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-alt) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 10px center;
    font-size: 13.5px;
    font-family: inherit;
}

.globalsearch input:focus {
    outline: none;
    border-color: var(--brand);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}

.globalsearch__results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 60vh; overflow-y: auto;
    z-index: 60;
}

.globalsearch__group {
    padding: 7px 12px;
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px;
    color: var(--text-muted); font-weight: 600;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
}

.globalsearch__item {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.globalsearch__item:last-child { border-bottom: 0; }
.globalsearch__item:hover,
.globalsearch__item:focus { background: var(--brand-light); text-decoration: none; outline: none; }
.globalsearch__item strong { font-weight: 600; font-size: 13.5px; }
.globalsearch__item small { color: var(--text-muted); display: block; font-size: 12px; }
.globalsearch__empty { padding: 14px; color: var(--text-muted); text-align: center; }

/* ------------------------------------------------------------ user menu */

.topbar__user { margin-left: auto; }

.usermenu { position: relative; }
.usermenu summary {
    display: flex; align-items: center; gap: 9px;
    cursor: pointer; list-style: none; padding: 5px 8px;
    border-radius: var(--radius); user-select: none;
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--surface-alt); }

.avatar {
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 600;
}

.avatar--lg { width: 56px; height: 56px; font-size: 19px; }

.usermenu__meta { display: flex; flex-direction: column; line-height: 1.25; }
.usermenu__meta strong { font-size: 13px; font-weight: 600; }
.usermenu__meta small { font-size: 11.5px; color: var(--text-muted); }

.usermenu__panel {
    position: absolute; right: 0; top: calc(100% + 6px);
    min-width: 190px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 5px;
    z-index: 70;
}
.usermenu__panel a,
.usermenu__signout {
    display: block; width: 100%; text-align: left;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text); font-size: 13.5px;
    background: none; border: 0; cursor: pointer; font-family: inherit;
}
.usermenu__panel a:hover,
.usermenu__signout:hover { background: var(--surface-alt); text-decoration: none; }
.usermenu__signout { color: var(--danger); border-top: 1px solid var(--border); margin-top: 4px; }

/* -------------------------------------------------------------- flashes */

.flashes { padding: 14px 26px 0; display: flex; flex-direction: column; gap: 8px; }

.flash {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 13.5px;
}
.flash--success { background: var(--ok-bg);     color: var(--ok);     border-color: #a7f3d0; }
.flash--error   { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.flash--warning { background: var(--warn-bg);   color: var(--warn);   border-color: #fde68a; }
.flash--info    { background: var(--info-bg);   color: var(--info);   border-color: #bfdbfe; }

.flash__close {
    background: none; border: 0; cursor: pointer;
    font-size: 18px; line-height: 1; color: inherit; opacity: .6; padding: 0 2px;
}
.flash__close:hover { opacity: 1; }

/* ---------------------------------------------------------------- cards */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.card--narrow { max-width: 560px; }

.card__head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
}
.card__head h2 { font-size: 15px; }
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }
.card__foot {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --------------------------------------------------------------- stats */

.statgrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 15px 16px;
    box-shadow: var(--shadow-sm);
    display: block;
    color: inherit;
}
a.stat:hover { border-color: var(--brand); text-decoration: none; box-shadow: var(--shadow); }

.stat__label {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px;
    color: var(--text-muted); font-weight: 600;
}
.stat__value { font-size: 27px; font-weight: 650; line-height: 1.15; margin-top: 6px; }
.stat__hint  { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.stat--ok     .stat__value { color: var(--ok); }
.stat--info   .stat__value { color: var(--info); }
.stat--warn   .stat__value { color: var(--warn); }
.stat--danger .stat__value { color: var(--danger); }

/* --------------------------------------------------------------- tables */

.tablewrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table th, .table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table thead th {
    background: var(--surface-alt);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-muted); font-weight: 600;
    white-space: nowrap;
    position: sticky; top: 0; z-index: 1;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-alt); }

.table__sort { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table__sort:hover { color: var(--brand); text-decoration: none; }
.table__sort span { opacity: .45; font-size: 10px; }
.table__sort--active span { opacity: 1; color: var(--brand); }

.table__num { text-align: right; font-variant-numeric: tabular-nums; }
.table__actions { text-align: right; white-space: nowrap; }

.table--compact th, .table--compact td { padding: 7px 12px; }

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

/* --------------------------------------------------------- cell content */

.cell-primary { display: flex; align-items: center; gap: 10px; }
.cell-primary strong { font-weight: 600; }
.cell-sub { color: var(--text-muted); font-size: 12.5px; }

.mono { font-family: var(--mono); font-size: 12.5px; }

/* --------------------------------------------------------------- badges */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px; font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge--ok     { background: var(--ok-bg);     color: var(--ok);     border-color: #a7f3d0; }
.badge--info   { background: var(--info-bg);   color: var(--info);   border-color: #bfdbfe; }
.badge--warn   { background: var(--warn-bg);   color: var(--warn);   border-color: #fde68a; }
.badge--danger { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.badge--muted  { background: var(--muted-bg);  color: var(--text-muted); border-color: var(--border); }

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px;
    background: var(--brand-light);
    color: var(--brand-dark);
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    font-size: 12px;
}
.chip a { color: inherit; opacity: .65; font-weight: 700; }
.chip a:hover { opacity: 1; text-decoration: none; }

/* -------------------------------------------------------------- buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px; font-weight: 500; font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: #991b1b; border-color: #991b1b; }

.btn--ghost { background: none; border-color: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-alt); color: var(--text); }

.btn--sm { padding: 5px 10px; font-size: 12.5px; }
.btn--block { width: 100%; }

.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- forms */

.form { display: block; }

.field { margin-bottom: 15px; }

.field label {
    display: block;
    font-size: 12.5px; font-weight: 600;
    margin-bottom: 5px;
    color: var(--text);
}

.field label .req { color: var(--danger); margin-left: 2px; }

.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="number"],
.field input[type="date"],
.field input[type="search"],
.field input[type="tel"],
.field select,
.field textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
}

.field textarea { min-height: 84px; resize: vertical; }

.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}

.field input.is-invalid, .field select.is-invalid, .field textarea.is-invalid {
    border-color: var(--danger);
}

.field__hint  { display: block; color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.field__error { display: block; color: var(--danger);     font-size: 12px; margin-top: 4px; }

.field--check { display: flex; align-items: flex-start; gap: 9px; }
.field--check input { margin-top: 2px; }
.field--check label { margin: 0; font-weight: 500; }

.formgrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0 16px;
}
.formgrid--wide { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.formgrid .field--full { grid-column: 1 / -1; }

.fieldset {
    border: 0; padding: 0; margin: 0 0 8px;
}
.fieldset > legend {
    font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
    color: var(--text-muted); font-weight: 700;
    padding: 0 0 10px;
    width: 100%;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}

.form__actions {
    display: flex; gap: 8px; align-items: center;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    margin-top: 6px;
}

/* --------------------------------------------------- employee picker */

.picker { position: relative; }

.picker__results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 260px; overflow-y: auto;
    z-index: 50;
}

.picker__item {
    display: block; width: 100%; text-align: left;
    padding: 8px 11px;
    background: none; border: 0; border-bottom: 1px solid var(--border);
    cursor: pointer; font-family: inherit;
}
.picker__item:last-child { border-bottom: 0; }
.picker__item:hover, .picker__item:focus { background: var(--brand-light); outline: none; }
.picker__item strong { display: block; font-size: 13.5px; font-weight: 600; }
.picker__item small  { color: var(--text-muted); font-size: 12px; }

.picker__empty { padding: 12px; text-align: center; color: var(--text-muted); font-size: 13px; }

.picker__chosen { margin-top: 6px; }

.picker__pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 10px;
    background: var(--brand-light);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    width: 100%;
}
.picker__pill strong { font-size: 13.5px; }
.picker__pill small  { color: var(--text-muted); font-size: 12px; }
.picker__pill button {
    margin-left: auto;
    background: none; border: 0; cursor: pointer;
    font-size: 17px; line-height: 1; color: var(--text-muted);
}
.picker__pill button:hover { color: var(--danger); }

/* ------------------------------------------------ allocation widget */

.allocation {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 10px;
    background: var(--surface-alt);
}

.allocation__grid {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: 10px 14px;
    align-items: end;
}

.allocation__grid .field { margin-bottom: 0; }

.allocation__actions { padding-bottom: 2px; }

.allocation__result {
    margin-top: 10px;
    padding: 8px 11px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    border: 1px solid transparent;
}
.allocation__result--ok    { background: var(--ok-bg);     color: var(--ok);     border-color: #a7f3d0; }
.allocation__result--error { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.allocation__result--idle  { background: var(--muted-bg);  color: var(--text-muted); border-color: var(--border); }

@media (max-width: 700px) {
    .allocation__grid { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------------- filters */

.filters {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.filters__row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px 12px;
    align-items: end;
}

.filters__row .field { margin-bottom: 0; }

.filters__actions { display: flex; gap: 8px; align-items: end; }

.filters__active {
    display: flex; gap: 7px; flex-wrap: wrap;
    margin-top: 12px; padding-top: 12px;
    border-top: 1px dashed var(--border);
}

/* ----------------------------------------------------------- pagination */

.pagination {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}

.pagination__pages { display: flex; gap: 4px; align-items: center; }

.pagination__page {
    min-width: 32px; height: 32px;
    display: inline-grid; place-items: center;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: var(--surface);
}
.pagination__page:hover { background: var(--surface-alt); text-decoration: none; }
.pagination__page--active {
    background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600;
}
.pagination__gap { padding: 0 4px; color: var(--text-faint); }

/* --------------------------------------------------------------- detail */

.detailgrid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 16px;
    align-items: start;
}

.deflist { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 0; }
.deflist dt {
    padding: 8px 0;
    color: var(--text-muted);
    font-size: 12.5px;
    border-bottom: 1px solid var(--border);
}
.deflist dd {
    padding: 8px 0;
    margin: 0;
    border-bottom: 1px solid var(--border);
    word-break: break-word;
}
.deflist dt:last-of-type, .deflist dd:last-of-type { border-bottom: 0; }

.detailhead {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 18px;
}
.detailhead__meta { min-width: 0; flex: 1; }
.detailhead__meta h1 { font-size: 20px; }
.detailhead__sub { color: var(--text-muted); margin-top: 3px; }
.detailhead__tags { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 9px; }

/* ------------------------------------------------------------- timeline */

.timeline { list-style: none; margin: 0; padding: 4px 0; }

.timeline li {
    position: relative;
    padding: 0 0 18px 26px;
    border-left: 2px solid var(--border);
    margin-left: 7px;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 2px; }

.timeline li::before {
    content: "";
    position: absolute; left: -7px; top: 3px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border-strong);
}
.timeline li[data-event="assigned"]::before       { border-color: var(--info);   background: var(--info-bg); }
.timeline li[data-event="returned"]::before       { border-color: var(--ok);     background: var(--ok-bg); }
.timeline li[data-event="decommissioned"]::before { border-color: var(--danger); background: var(--danger-bg); }
.timeline li[data-event="created"]::before        { border-color: var(--brand);  background: var(--brand-light); }

.timeline__when { font-size: 12px; color: var(--text-muted); }
.timeline__what { font-weight: 600; margin-top: 1px; }
.timeline__note { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* ----------------------------------------------------------------- tabs */

.tabs {
    display: flex; gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
}

.tabs a {
    padding: 9px 14px;
    color: var(--text-muted);
    font-size: 13.5px; font-weight: 500;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ----------------------------------------------------------- auth pages */

.body--centered {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 55%, #1d4ed8 160%);
    padding: 24px;
}

.authshell { width: 100%; max-width: 400px; }

.authcard {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 28px;
}

.authcard__brand {
    display: flex; align-items: center; gap: 11px;
    margin-bottom: 22px;
}
.authcard__brand strong { display: block; font-size: 15px; }
.authcard__brand small  { color: var(--text-muted); font-size: 12px; }

.authcard__title { font-size: 19px; margin-bottom: 3px; }
.authcard__subtitle { color: var(--text-muted); margin-bottom: 20px; font-size: 13.5px; }
.authcard__note {
    margin-top: 18px; padding-top: 15px;
    border-top: 1px solid var(--border);
    font-size: 12.5px; color: var(--text-muted); text-align: center;
}

.authcard .flash { margin-bottom: 16px; }

.authshell__footer {
    text-align: center; margin-top: 16px;
    color: rgba(255, 255, 255, .5); font-size: 12px;
}

/* --------------------------------------------------------- error pages */

.errorpage { text-align: center; padding: 10px 0; }
.errorpage__code {
    font-size: 54px; font-weight: 700; line-height: 1;
    color: var(--brand); margin-bottom: 8px;
}
.errorpage__title { font-size: 18px; margin-bottom: 8px; }
.errorpage__text { color: var(--text-muted); margin-bottom: 20px; }
.errorpage pre {
    text-align: left; background: #0f172a; color: #e2e8f0;
    padding: 14px; border-radius: var(--radius);
    overflow-x: auto; font-size: 12px; font-family: var(--mono);
    max-height: 340px;
}

/* ------------------------------------------------------------- progress */

.meter {
    height: 7px;
    background: var(--muted-bg);
    border-radius: 999px;
    overflow: hidden;
}
.meter__fill { height: 100%; background: var(--brand); border-radius: 999px; }
.meter__fill--ok   { background: var(--ok); }
.meter__fill--warn { background: var(--warn); }

.breakdown { list-style: none; margin: 0; padding: 0; }
.breakdown li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    align-items: center;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}
.breakdown li:last-child { border-bottom: 0; }
.breakdown__bar { grid-column: 1 / -1; }
.breakdown__count { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ utilities */

.muted   { color: var(--text-muted); }
.faint   { color: var(--text-faint); }
.nowrap  { white-space: nowrap; }
.right   { text-align: right; }
.center  { text-align: center; }
.mt-0    { margin-top: 0; }
.mt-2    { margin-top: 16px; }
.mb-0    { margin-bottom: 0; }
.mb-2    { margin-bottom: 16px; }
.flexrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grow    { flex: 1; }

/* ----------------------------------------------------------- responsive */

@media (max-width: 1080px) {
    .detailgrid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed; z-index: 100; left: 0; top: 0;
        transform: translateX(-100%);
        transition: transform .18s ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: translateX(0); }

    .topbar__toggle { display: flex; }
    .content { padding: 16px 14px 50px; }
    .flashes { padding: 12px 14px 0; }
    .usermenu__meta { display: none; }
    .deflist { grid-template-columns: 1fr; }
    .deflist dt { border-bottom: 0; padding-bottom: 0; }
}

@media print {
    .sidebar, .topbar, .page__actions, .filters, .pagination { display: none !important; }
    .content { padding: 0; }
    .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
    body { background: #fff; }
}
