/* ==========================================================================
   Brickyard — client portal & admin
   Light-first with a real dark mode. Collapsible sidebar, KPI tiles,
   data tables, kanban, charts.
   ========================================================================== */

:root {
  --bg:        #F4F6F9;
  --surface:   #FFFFFF;
  --surface-2: #FAFBFC;
  --surface-3: #F0F2F6;
  --line:      #E4E8EE;
  --line-2:    #D3D9E2;

  --text:      #10151D;
  --text-2:    #4A5464;
  --muted:     #7A8598;
  --dim:       #9AA3B2;

  --brand:     #C8452D;
  --brand-lt:  #E45C3E;
  --brand-dk:  #A5361F;
  --brand-soft:#FDEDE9;
  --gold:      #C08A3E;
  --gold-soft: #FBF2E3;
  --teal:      #2F7D8F;
  --teal-soft: #E6F3F6;

  --ok:        #167F52;
  --ok-soft:   #E4F5ED;
  --warn:      #9A6205;
  --warn-soft: #FCF2DE;
  --bad:       #B3261E;
  --bad-soft:  #FCEAE8;
  --info:      #1F5FA8;
  --info-soft: #E8F1FB;

  --sidebar-w:  256px;
  --sidebar-mini: 74px;
  --topbar-h:   62px;

  --r-sm: 7px;
  --r:    11px;
  --r-lg: 16px;

  --shadow-xs: 0 1px 2px rgba(16, 21, 29, .06);
  --shadow-sm: 0 1px 3px rgba(16, 21, 29, .09), 0 1px 2px rgba(16, 21, 29, .05);
  --shadow:    0 4px 14px -4px rgba(16, 21, 29, .13);
  --shadow-lg: 0 22px 48px -20px rgba(16, 21, 29, .32);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.22, .68, .38, 1);
}

[data-theme="dark"] {
  --bg:        #0C1017;
  --surface:   #141A23;
  --surface-2: #1A212C;
  --surface-3: #212936;
  --line:      #262F3C;
  --line-2:    #35405021;

  --text:      #E8ECF2;
  --text-2:    #B3BCCA;
  --muted:     #8791A2;
  --dim:       #6B7484;

  --brand:     #E45C3E;
  --brand-lt:  #F2735A;
  --brand-dk:  #C8452D;
  --brand-soft:#2A1712;
  --gold:      #E0A458;
  --gold-soft: #2A2113;
  --teal:      #4FA9BD;
  --teal-soft: #12262B;

  --ok:        #4ECB8F;  --ok-soft:   #10241B;
  --warn:      #E4B061;  --warn-soft: #2A2113;
  --bad:       #FF7A6B;  --bad-soft:  #2C1512;
  --info:      #6FA8E8;  --info-soft: #111E2D;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.5);
  --shadow:    0 6px 18px -6px rgba(0,0,0,.65);
  --shadow-lg: 0 26px 60px -24px rgba(0,0,0,.85);
}

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

body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14.5px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0; line-height: 1.25; letter-spacing: -0.022em; font-weight: 650; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.18rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .85rem; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.icon { flex: none; }

/* --- Layout --------------------------------------------------------------- */

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

.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  transition: width .22s var(--ease);
  z-index: 40;
}
body.nav-mini .sidebar { width: var(--sidebar-mini); }

.sidebar__brand {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 10px;
  padding: 0 18px; border-bottom: 1px solid var(--line); overflow: hidden;
}
.sidebar__mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand-lt), var(--brand-dk));
  color: #fff; font-weight: 800; font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.24);
}
.sidebar__name { font-weight: 700; letter-spacing: -0.028em; font-size: .97rem; white-space: nowrap; }
.sidebar__name small { display: block; font-size: .66rem; color: var(--muted); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
body.nav-mini .sidebar__name { display: none; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

.nav-group { margin-bottom: 20px; }
.nav-group__label {
  font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--dim); padding: 0 10px 8px;
}
body.nav-mini .nav-group__label { text-align: center; font-size: 0; padding-bottom: 4px; }
body.nav-mini .nav-group__label::after { content: "•"; font-size: 12px; letter-spacing: 0; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r); margin-bottom: 2px;
  color: var(--text-2); font-size: .9rem; font-weight: 500;
  transition: background .16s, color .16s;
  position: relative; white-space: nowrap;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav-item__label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
body.nav-mini .nav-item { justify-content: center; padding: 11px; }
body.nav-mini .nav-item__label, body.nav-mini .nav-item .pill { display: none; }

.nav-item .pill {
  background: var(--brand); color: #fff; font-size: .68rem; font-weight: 700;
  padding: 1px 7px; border-radius: 999px; line-height: 1.55;
}
.nav-item .pill--quiet { background: var(--surface-3); color: var(--muted); }

.sidebar__foot { flex: none; padding: 12px; border-top: 1px solid var(--line); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex: none; background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  position: sticky; top: 0; z-index: 30;
}
.topbar__title { font-weight: 650; font-size: 1.02rem; letter-spacing: -0.02em; }
.topbar__crumb { color: var(--muted); font-size: .82rem; }
.topbar__spacer { flex: 1; }

.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r); border: 1px solid transparent;
  background: transparent; color: var(--text-2); cursor: pointer;
  display: grid; place-items: center; position: relative; transition: background .16s, color .16s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.theme-icon { display: none; }
[data-theme="light"] .theme-icon--light,
[data-theme="dark"]  .theme-icon--dark { display: block; }

.icon-btn__dot {
  position: absolute; top: 7px; right: 7px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 999px; background: var(--brand); color: #fff;
  font-size: .6rem; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--surface); box-sizing: content-box;
}

.content { flex: 1; padding: 24px; max-width: 1560px; width: 100%; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 22px;
}
.page-head p { color: var(--muted); margin: 5px 0 0; font-size: .92rem; }
.page-head__actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--r); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text); font: inherit; font-size: .89rem; font-weight: 550;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .16s, border-color .16s, color .16s, box-shadow .16s, transform .1s;
  box-shadow: var(--shadow-xs);
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 8px -2px rgba(200,69,45,.5); }
.btn--primary:hover { background: var(--brand-dk); border-color: var(--brand-dk); }
.btn--dark { background: var(--text); border-color: var(--text); color: var(--surface); }
.btn--dark:hover { opacity: .88; background: var(--text); }
.btn--danger { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.btn--danger:hover { background: var(--bad); color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.btn--sm { padding: 6px 11px; font-size: .82rem; border-radius: var(--r-sm); }
.btn--lg { padding: 12px 22px; font-size: .95rem; }
.btn--block { width: 100%; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r) 0 0 var(--r); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r) var(--r) 0; }
.btn-group .btn.is-on { background: var(--text); color: var(--surface); border-color: var(--text); z-index: 1; }

/* --- Cards & grid --------------------------------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card__head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.card__head h2, .card__head h3 { font-size: .98rem; }
.card__head p { margin: 3px 0 0; font-size: .82rem; color: var(--muted); }
.card__body { padding: 20px; }
.card__body--flush { padding: 0; }
.card__foot { padding: 13px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid--side { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.span-2 { grid-column: span 2; }

/* --- KPI tiles ------------------------------------------------------------ */

.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 20px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-xs); transition: border-color .18s, box-shadow .18s, transform .18s;
}
.kpi:hover { border-color: var(--line-2); box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.kpi__label { font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.kpi__icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.kpi__icon--brand { background: var(--brand-soft); color: var(--brand); }
.kpi__icon--ok    { background: var(--ok-soft);   color: var(--ok); }
.kpi__icon--warn  { background: var(--warn-soft); color: var(--warn); }
.kpi__icon--bad   { background: var(--bad-soft);  color: var(--bad); }
.kpi__icon--info  { background: var(--info-soft); color: var(--info); }
.kpi__icon--gold  { background: var(--gold-soft); color: var(--gold); }
.kpi__value { font-size: 1.78rem; font-weight: 700; letter-spacing: -0.038em; line-height: 1.1; }
.kpi__meta { margin-top: 7px; font-size: .81rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi__delta { font-weight: 650; display: inline-flex; align-items: center; gap: 3px; }
.kpi__delta--up   { color: var(--ok); }
.kpi__delta--down { color: var(--bad); }

/* --- Tables --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .885rem; }
table.data th {
  text-align: left; font-weight: 600; font-size: .74rem; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
  padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: var(--surface-2); position: sticky; top: 0; z-index: 1;
}
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .shrink { width: 1%; white-space: nowrap; }
table.data a.row-link { color: var(--text); font-weight: 600; }
table.data a.row-link:hover { color: var(--brand); }
table.data tfoot td { padding: 12px 16px; font-weight: 650; border-top: 2px solid var(--line); background: var(--surface-2); }

.empty { padding: 54px 24px; text-align: center; color: var(--muted); }
.empty__icon {
  width: 52px; height: 52px; border-radius: 15px; margin: 0 auto 16px;
  background: var(--surface-3); display: grid; place-items: center; color: var(--dim);
}
.empty h3 { margin-bottom: 6px; color: var(--text); }
.empty p { max-width: 380px; margin: 0 auto 18px; font-size: .9rem; }

/* --- Badges, pills, avatars ----------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 650; letter-spacing: .015em; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge--ok      { background: var(--ok-soft);   color: var(--ok); }
.badge--warn    { background: var(--warn-soft); color: var(--warn); }
.badge--bad     { background: var(--bad-soft);  color: var(--bad); }
.badge--info    { background: var(--info-soft); color: var(--info); }
.badge--muted   { background: var(--surface-3); color: var(--dim); }
.badge--neutral { background: var(--surface-3); color: var(--text-2); }
.badge--brand   { background: var(--brand-soft); color: var(--brand); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: .76rem; font-weight: 700;
  background: linear-gradient(140deg, var(--brand-lt), var(--brand-dk)); color: #fff;
}
.avatar--sm { width: 26px; height: 26px; font-size: .64rem; }
.avatar--lg { width: 48px; height: 48px; font-size: 1rem; }
.avatar--teal { background: linear-gradient(140deg, #48A8BC, #23616F); }
.avatar--gold { background: linear-gradient(140deg, #DCA85E, #9A6A22); }

.cell-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-user b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.cell-user span { display: block; font-size: .78rem; color: var(--muted); }

/* --- Forms ---------------------------------------------------------------- */

.field { margin-bottom: 16px; }
.field > label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 6px; color: var(--text-2); }
.field .hint { font-size: .78rem; color: var(--muted); margin: 6px 0 0; }
.field .req { color: var(--brand); }

.input, .select, .textarea {
  width: 100%; padding: 9px 12px; font: inherit; font-size: .89rem;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  color: var(--text); transition: border-color .16s, box-shadow .16s;
}
.input::placeholder, .textarea::placeholder { color: var(--dim); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
.input--sm { padding: 6px 9px; font-size: .83rem; }
.input.num, .num-input { text-align: right; font-variant-numeric: tabular-nums; }

.select {
  appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%237A8598' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}

.field-error { color: var(--bad); font-size: .78rem; margin: 6px 0 0; }
.input.has-error, .select.has-error, .textarea.has-error { border-color: var(--bad); }

.form-row { display: grid; gap: 16px; }
.form-row--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-row--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.check { display: flex; align-items: flex-start; gap: 9px; font-size: .88rem; cursor: pointer; margin-bottom: 9px; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand); flex: none; cursor: pointer; }
.check span b { display: block; font-weight: 600; }
.check span small { color: var(--muted); font-size: .8rem; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--line-2);
  position: relative; transition: background .18s; flex: none;
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .18s var(--ease); box-shadow: var(--shadow-xs);
}
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }

.form-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding-top: 16px; margin-top: 4px; border-top: 1px solid var(--line);
}
.form-actions--end { justify-content: flex-end; }

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

.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 13px 20px; border-bottom: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }
.toolbar__spacer { flex: 1; }

.search-field { position: relative; flex: 1; max-width: 320px; min-width: 180px; }
.search-field .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field .input { padding-left: 34px; width: 100%; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface); font-size: .81rem; font-weight: 550; color: var(--text-2);
  text-decoration: none; transition: all .15s; white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.chip.is-on { background: var(--text); border-color: var(--text); color: var(--surface); }

/* --- Flash / alerts ------------------------------------------------------- */

.flash-stack { position: fixed; top: 74px; right: 20px; z-index: 200; display: grid; gap: 10px; max-width: 400px; }
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 15px; border-radius: var(--r); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-size: .88rem;
  animation: flashIn .3s var(--ease);
}
@keyframes flashIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
.flash--success { border-left: 3px solid var(--ok);   } .flash--success .icon { color: var(--ok); }
.flash--error   { border-left: 3px solid var(--bad);  } .flash--error   .icon { color: var(--bad); }
.flash--warning { border-left: 3px solid var(--warn); } .flash--warning .icon { color: var(--warn); }
.flash--info    { border-left: 3px solid var(--info); } .flash--info    .icon { color: var(--info); }
.flash span { flex: 1; }
.flash__close { background: none; border: 0; color: var(--dim); cursor: pointer; padding: 2px; display: grid; place-items: center; }
.flash__close:hover { color: var(--text); }

.notice {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 16px; border-radius: var(--r); font-size: .88rem; margin-bottom: 18px;
  background: var(--info-soft); color: var(--info); border: 1px solid transparent;
}
.notice--warn { background: var(--warn-soft); color: var(--warn); }
.notice--bad  { background: var(--bad-soft);  color: var(--bad); }
.notice--ok   { background: var(--ok-soft);   color: var(--ok); }
.notice b { font-weight: 650; }

/* --- Progress ------------------------------------------------------------- */

.bar { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 999px; background: var(--brand); transition: width .5s var(--ease); }
.bar__fill--ok   { background: var(--ok); }
.bar__fill--warn { background: var(--warn); }
.bar__fill--teal { background: var(--teal); }

.meter { display: flex; align-items: center; gap: 10px; }
.meter .bar { flex: 1; min-width: 60px; }
.meter b { font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--text-2); min-width: 34px; text-align: right; }

/* --- Charts --------------------------------------------------------------- */

.chart-box { position: relative; height: 280px; }
.chart-box--sm { height: 190px; }
.chart-box--tall { height: 340px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; }

/* --- Timeline / activity -------------------------------------------------- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 13px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline__dot {
  width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2);
}
.timeline__body { flex: 1; min-width: 0; font-size: .87rem; }
.timeline__body b { font-weight: 600; }
.timeline__time { font-size: .77rem; color: var(--muted); white-space: nowrap; }

/* --- Kanban --------------------------------------------------------------- */

.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kanban__col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; }
.kanban__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; padding: 0 4px; }
.kanban__head h4 { font-size: .8rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.kanban__count { font-size: .74rem; background: var(--surface-3); color: var(--text-2); padding: 1px 8px; border-radius: 999px; font-weight: 650; }
.kanban__card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 13px; margin-bottom: 9px; box-shadow: var(--shadow-xs); font-size: .86rem;
}
.kanban__card b { display: block; font-weight: 600; margin-bottom: 6px; }
.kanban__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .77rem; color: var(--muted); }

/* --- Misc ----------------------------------------------------------------- */

.stack   { display: grid; gap: 16px; }
.stack--sm { gap: 9px; }
.row     { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.mono    { font-family: var(--mono); font-size: .84em; }
.muted   { color: var(--muted); }
.dim     { color: var(--dim); }
.tiny    { font-size: .78rem; }
.strong  { font-weight: 650; }
.right   { text-align: right; }
.center  { text-align: center; }
.nowrap  { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.pos     { color: var(--ok); }
.neg     { color: var(--bad); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-3 { margin-top: 18px; } .mb-3 { margin-bottom: 18px; }
.hr { height: 1px; background: var(--line); border: 0; margin: 18px 0; }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; font-size: .88rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 550; text-align: right; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 13px 20px; }
.pager__links { display: flex; gap: 5px; }
.pager__links a, .pager__links span {
  min-width: 32px; height: 32px; padding: 0 9px; border-radius: var(--r-sm);
  display: grid; place-items: center; font-size: .84rem; font-weight: 550;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); text-decoration: none;
}
.pager__links a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pager__links .is-on { background: var(--text); border-color: var(--text); color: var(--surface); }
.pager__links .is-off { opacity: .4; pointer-events: none; }

/* Dropdown menu */
.menu { position: relative; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 7px); min-width: 210px; z-index: 60;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 6px; display: none;
}
.menu.is-open .menu__panel { display: block; }
.menu__item {
  display: flex; align-items: center; gap: 10px; padding: 8px 11px; border-radius: var(--r-sm);
  font-size: .87rem; color: var(--text-2); text-decoration: none; width: 100%;
  background: none; border: 0; font-family: inherit; cursor: pointer; text-align: left;
}
.menu__item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.menu__item--danger { color: var(--bad); }
.menu__item--danger:hover { background: var(--bad-soft); color: var(--bad); }
.menu__sep { height: 1px; background: var(--line); margin: 5px 0; }
.menu__head { padding: 9px 11px 7px; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); font-weight: 700; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8, 11, 16, .55); z-index: 150;
  display: none; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; border: 1px solid var(--line);
  animation: modalIn .22s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal__head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.modal__body { padding: 22px; }
.modal__foot { padding: 15px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; background: var(--surface-2); }

/* Tabs */
.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a {
  padding: 10px 15px; font-size: .89rem; font-weight: 550; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.is-on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* Auth screens */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
.auth__aside {
  background: linear-gradient(155deg, #171E28 0%, #0B0E13 100%);
  color: #E9ECF1; padding: 52px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth__aside::before {
  content: ""; position: absolute; width: 560px; height: 560px; border-radius: 50%;
  background: radial-gradient(circle, rgba(200,69,45,.36), transparent 66%);
  top: -220px; right: -180px; filter: blur(60px);
}
.auth__aside > * { position: relative; z-index: 1; }
.auth__aside h2 { font-size: 1.9rem; letter-spacing: -0.032em; margin-bottom: 14px; }
.auth__aside p { color: #9AA4B4; max-width: 380px; }
.auth__points { list-style: none; margin: 30px 0 0; padding: 0; display: grid; gap: 13px; }
.auth__points li { display: flex; gap: 11px; align-items: flex-start; font-size: .92rem; color: #C6CDD8; }
.auth__points .icon { color: #E45C3E; margin-top: 3px; }
.auth__main { display: grid; place-items: center; padding: 40px 24px; }
.auth__card { width: 100%; max-width: 396px; }
.auth__logo { display: flex; align-items: center; gap: 11px; margin-bottom: 30px; font-weight: 700; letter-spacing: -0.03em; }

/* Invoice print view */
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 42px; max-width: 840px; margin: 0 auto; }
.doc__head { display: flex; justify-content: space-between; gap: 30px; flex-wrap: wrap; margin-bottom: 34px; }
.doc__title { font-size: 1.9rem; letter-spacing: -0.035em; font-weight: 700; }
.doc__num { font-family: var(--mono); color: var(--muted); font-size: .9rem; margin-top: 4px; }
.doc__parties { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-bottom: 30px; }
.doc__parties h4 { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 9px; }
.doc__totals { margin-left: auto; width: 100%; max-width: 300px; margin-top: 20px; }
.doc__totals .row--between { padding: 7px 0; font-size: .9rem; }
.doc__totals .total-line { border-top: 2px solid var(--text); margin-top: 8px; padding-top: 12px; font-size: 1.15rem; font-weight: 700; }

@media print {
  .sidebar, .topbar, .page-head__actions, .flash-stack, .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .content { padding: 0; }
  .doc { border: 0; padding: 0; max-width: none; box-shadow: none; }
  .shell { display: block; }
}

/* --- Responsive ----------------------------------------------------------- */

.sidebar__scrim { display: none; }

@media (max-width: 1200px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--main, .grid--side { grid-template-columns: minmax(0, 1fr); }
  .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; transform: translateX(-100%);
    transition: transform .24s var(--ease); box-shadow: var(--shadow-lg); width: var(--sidebar-w);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-mini .sidebar { width: var(--sidebar-w); }
  body.nav-mini .sidebar__name, body.nav-mini .nav-item__label { display: block; }
  body.nav-mini .nav-item { justify-content: flex-start; padding: 9px 11px; }
  .sidebar__scrim { display: block; position: fixed; inset: 0; background: rgba(8,11,16,.5); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .24s; }
  body.nav-open .sidebar__scrim { opacity: 1; pointer-events: auto; }
  .content { padding: 18px 16px; }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: span 1; }
  .form-row--2, .form-row--3, .form-row--4 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
  .kanban { grid-template-columns: minmax(0, 1fr); }
  .doc { padding: 24px; }
  .doc__parties { grid-template-columns: 1fr; }
  .flash-stack { left: 16px; right: 16px; max-width: none; }
}
