/* ==========================================================================
   NexaAdmin 2.0 — admin dashboard kit
   One stylesheet for every page. Sections:
     1. Tokens (colours, sizes)       6. Tables
     2. Base                          7. Overlays (dropdown, modal, toast)
     3. Layout (sidebar, topbar)      8. Page pieces (calendar, chat, etc.)
     4. Building blocks               9. Auth pages
     5. Forms                        10. Responsive, print, reduced motion
   ========================================================================== */

/* 1. TOKENS ---------------------------------------------------------------
   Change --brand to re-colour the kit. Everything else follows. */
:root {
  --brand: #5b54e8;
  --brand-ink: #ffffff;                 /* text on top of --brand */
  --brand-soft: color-mix(in srgb, var(--brand) 12%, var(--surface));
  --brand-text: var(--brand);           /* brand colour used as text */

  --bg: #f2f3f7;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --line: #e4e7ee;
  --line-strong: #cfd4df;
  --ink: #151828;
  --ink-2: #555b74;
  --ink-3: #646a85;

  --ok: #0a7d56;      --ok-soft: #dff6ec;
  --warn: #8d5205;    --warn-soft: #fdf0d8;
  --bad: #b7283a;     --bad-soft: #fde4e6;
  --info: #1a5fad;    --info-soft: #e0eefc;

  --side-bg: #141726;
  --side-ink: rgba(255,255,255,.62);
  --side-ink-strong: #ffffff;
  --side-line: rgba(255,255,255,.08);

  --sidebar-w: 256px;
  --sidebar-w-mini: 76px;
  --topbar-h: 64px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(21,24,40,.05);
  --shadow-2: 0 10px 30px rgba(21,24,40,.10);
  --shadow-3: 0 24px 60px rgba(21,24,40,.22);
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --t: .18s ease;
  color-scheme: light;
}

[data-theme="dark"] {
  --brand-text: color-mix(in srgb, var(--brand) 62%, #fff);
  --brand-soft: color-mix(in srgb, var(--brand) 22%, var(--surface));
  --bg: #0d0f17;
  --surface: #161925;
  --surface-2: #1c2030;
  --line: #272c3f;
  --line-strong: #363c54;
  --ink: #eceef6;
  --ink-2: #a9afc6;
  --ink-3: #8389a3;

  --ok: #4fd3a2;      --ok-soft: #12352b;
  --warn: #f0b757;    --warn-soft: #3a2c10;
  --bad: #ff8590;     --bad-soft: #401c22;
  --info: #7db8f5;    --info-soft: #14304c;

  --side-bg: #11131c;
  --side-line: rgba(255,255,255,.06);
  --shadow-1: 0 1px 2px rgba(0,0,0,.3);
  --shadow-2: 0 10px 30px rgba(0,0,0,.4);
  --shadow-3: 0 24px 60px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* 2. BASE ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; border-radius: 6px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
::selection { background: color-mix(in srgb, var(--brand) 28%, transparent); }

/* 3. LAYOUT --------------------------------------------------------------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 60;
  width: var(--sidebar-w); display: flex; flex-direction: column;
  background: var(--side-bg); color: var(--side-ink);
  border-right: 1px solid var(--side-line);
  transition: width var(--t), transform var(--t);
}
.side-brand { display: flex; align-items: center; gap: 11px; height: var(--topbar-h); padding: 0 20px; flex: none; color: #fff; font-size: 17px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; }
.side-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; flex: none; }
.side-mark svg { width: 18px; height: 18px; }
.side-nav { flex: 1; overflow-y: auto; padding: 10px 12px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.side-label { display: block; padding: 16px 10px 8px; font-size: 11.5px; font-weight: 600; color: rgba(255,255,255,.56); white-space: nowrap; overflow: hidden; }
.side-link { position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 10px; margin-bottom: 2px; border-radius: var(--r-sm); font-weight: 500; white-space: nowrap; transition: background var(--t), color var(--t); }
.side-link:hover { background: rgba(255,255,255,.07); color: var(--side-ink-strong); }
.side-link[aria-current="page"] { background: var(--brand); color: var(--brand-ink); }
.side-link .count { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 99px; background: #e5484d; color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.side-link[aria-current="page"] .count { background: rgba(255,255,255,.22); }
.side-link:focus-visible, .side-user:focus-visible { outline-color: #fff; }
.side-user { display: flex; align-items: center; gap: 10px; margin: 0 12px 12px; padding: 10px; border-radius: var(--r-sm); border: 1px solid var(--side-line); white-space: nowrap; overflow: hidden; flex: none; }
.side-user:hover { background: rgba(255,255,255,.05); }
.side-user b { display: block; color: #fff; font-size: 13.5px; font-weight: 600; }
.side-user span { font-size: 12px; }

.shell { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; min-width: 0; transition: margin var(--t); }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; margin-right: auto; }
.topbar-title h1 { font-size: 18px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs { display: flex; gap: 6px; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.crumbs a:hover { color: var(--ink); }
.crumbs li + li::before { content: '/'; margin-right: 6px; opacity: .6; }
.search { position: relative; width: 240px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search input { width: 100%; height: 38px; padding: 0 12px 0 34px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); outline: none; transition: border-color var(--t), box-shadow var(--t); }
.search input::placeholder { color: var(--ink-3); }
.search input:focus { border-color: var(--brand-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.icon-btn { position: relative; width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); transition: background var(--t), color var(--t), border-color var(--t); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: #e5484d; border: 2px solid var(--surface); }
.icon-btn--plain { border-color: transparent; background: transparent; }
[data-theme="dark"] .theme-moon, :root:not([data-theme="dark"]) .theme-sun { display: none; }   /* the button shows the theme you would switch to */
.menu-btn { display: none; }
.content { flex: 1; padding: 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; min-width: 0; }
.content > * { min-width: 0; }
.footer { padding: 16px 24px 22px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); }
.footer a:hover { color: var(--ink); }
.backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(10,12,20,.5); opacity: 0; pointer-events: none; transition: opacity var(--t); }

/* collapsed sidebar on desktop */
@media (min-width: 992px) {
  .side-collapsed .sidebar { width: var(--sidebar-w-mini); }
  .side-collapsed .shell { margin-left: var(--sidebar-w-mini); }
  .side-collapsed .side-brand span, .side-collapsed .side-link span:not(.count), .side-collapsed .side-user div { display: none; }
  .side-collapsed .side-label { height: 1px; padding: 0; margin: 14px 10px; background: var(--side-line); color: transparent; }
  .side-collapsed .side-link { justify-content: center; padding: 10px; }
  .side-collapsed .side-link .count { position: absolute; top: 4px; right: 6px; min-width: 0; width: 8px; height: 8px; padding: 0; font-size: 0; }
  .side-collapsed .side-brand { padding: 0 22px; }
  .side-collapsed .side-user { justify-content: center; border-color: transparent; }
}

/* 4. BUILDING BLOCKS ------------------------------------------------------ */
.grid { display: grid; gap: 20px; min-width: 0; }
.grid > * { min-width: 0; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.cols-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-end { margin-left: auto; }
.stack { display: grid; gap: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; padding: 18px 20px 0; }
.card-head h2 { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; }
.card-head p { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.card-body { padding: 18px 20px 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.stat { padding: 18px 20px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: start; }
.stat-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.stat-value { font-size: 27px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; font-variant-numeric: tabular-nums; grid-column: 1; }
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; grid-row: 1 / span 2; grid-column: 2; }
.stat-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--ink-3); }
.spark { width: 84px; height: 28px; flex: none; }
.spark path { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tone-brand { background: var(--brand-soft); color: var(--brand-text); }
.tone-ok { background: var(--ok-soft); color: var(--ok); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-bad { background: var(--bad-soft); color: var(--bad); }
.tone-info { background: var(--info-soft); color: var(--info); }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.trend.up { color: var(--ok); } .trend.down { color: var(--bad); }
.trend svg { width: 14px; height: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; white-space: nowrap; transition: background var(--t), border-color var(--t), filter var(--t); }
.btn:hover { background: var(--surface-2); }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.1); }
.btn-danger { background: #d13a48; border-color: #d13a48; color: #fff; }
.btn-danger:hover { background: #d13a48; filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; filter: none; }
.link { color: var(--brand-text); font-weight: 600; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.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.brand { background: var(--brand-soft); color: var(--brand-text); }

.avatar { --size: 36px; width: var(--size); height: var(--size); flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--c, var(--brand)); color: #fff; font-size: calc(var(--size) * .38); font-weight: 700; letter-spacing: .01em; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { --size: 28px; } .avatar.lg { --size: 56px; } .avatar.xl { --size: 88px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person > div { min-width: 0; }
.person > div > span { display: block; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; height: 42px; padding: 0 14px; border: 0; background: transparent; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--brand-text); }
.tab[aria-selected="true"]::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand-text); }
.tab .n { margin-left: 6px; font-weight: 500; color: var(--ink-3); }

.alert { display: flex; gap: 12px; padding: 13px 15px; border-radius: var(--r-md); background: var(--info-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); }
.alert .icon { color: var(--info); margin-top: 1px; }
.alert b { display: block; }
.alert.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); } .alert.ok .icon { color: var(--ok); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); } .alert.warn .icon { color: var(--warn); }
.alert.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); } .alert.bad .icon { color: var(--bad); }

.progress { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: var(--v, 50%); border-radius: 99px; background: var(--brand); }
.progress.ok i { background: var(--ok); } .progress.warn i { background: var(--warn); } .progress.bad i { background: var(--bad); }

.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.list > li:first-child { padding-top: 0; }
.timeline > li { position: relative; padding: 0 0 18px 24px; }
.timeline > li::before { content: ''; position: absolute; left: 0; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--brand)); box-shadow: 0 0 0 4px var(--surface); z-index: 1; }
.timeline > li::after { content: ''; position: absolute; left: 4.5px; top: 8px; bottom: -6px; width: 1px; background: var(--line); }
.timeline > li:last-child { padding-bottom: 0; } .timeline > li:last-child::after { display: none; }
.timeline time { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.legend { display: grid; gap: 9px; margin-top: 16px; }
.legend li { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.legend b { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-box { position: relative; width: 100%; overflow: hidden; }
.chart-box canvas { max-width: 100%; }
.empty { padding: 44px 20px; text-align: center; color: var(--ink-3); }
.empty svg { width: 34px; height: 34px; margin: 0 auto 10px; opacity: .7; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 2px; }
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.kbd { font-size: 12px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink-2); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }

/* 5. FORMS ---------------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 13.5px; font-weight: 600; }
.field .hint { font-size: 12.5px; color: var(--ink-3); }
.field .error { display: none; font-size: 12.5px; color: var(--bad); font-weight: 500; }
.field.invalid .error { display: block; }
.field.invalid .input { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 16%, transparent); }
.input, .select, .textarea { width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); outline: none; transition: border-color var(--t), box-shadow var(--t); }
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.input:disabled { background: var(--surface-2); color: var(--ink-3); }
.select { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: 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='%237d849e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.select.sm, .input.sm { height: 34px; font-size: 13.5px; }
.input-wrap { position: relative; }
.input-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.input-wrap .input { padding-left: 36px; }
.input-wrap .peek { position: absolute; right: 4px; top: 4px; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 6px; color: var(--ink-3); display: grid; place-items: center; }
.input-wrap .peek:hover { color: var(--ink); }
.input-wrap .peek .icon { position: static; transform: none; pointer-events: auto; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--brand); flex: none; }
.switch { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { width: 40px; height: 23px; border-radius: 99px; background: var(--line-strong); transition: background var(--t); position: relative; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform var(--t); }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(17px); }
.switch input:focus-visible + i { outline: 2px solid var(--brand-text); outline-offset: 2px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; padding-bottom: 0; } .setting:first-child { padding-top: 0; }
.setting b { display: block; font-weight: 600; } .setting span { font-size: 13px; color: var(--ink-3); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* 6. TABLES --------------------------------------------------------------- */
.table-wrap { position: relative; overflow-x: auto; }   /* relative, so visually hidden labels inside are clipped too */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 10px 14px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); white-space: nowrap; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.selected { background: var(--brand-soft); }
.table .r { text-align: right; }
.table th button { all: unset; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.table th button:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 3px; border-radius: 4px; }
.table th button::after { content: ''; width: 0; height: 0; border: 4px solid transparent; border-top-color: currentColor; margin-top: 4px; opacity: .35; }
.table th[aria-sort="ascending"] button::after { border-top-color: transparent; border-bottom-color: var(--brand-text); margin-top: -4px; opacity: 1; }
.table th[aria-sort="descending"] button::after { border-top-color: var(--brand-text); opacity: 1; }
.table th[aria-sort] { color: var(--ink); }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.row-actions .icon-btn { width: 32px; height: 32px; border-color: transparent; background: transparent; }
.row-actions .icon-btn:hover { background: var(--surface); border-color: var(--line); }
.row-actions .icon-btn.danger:hover { color: var(--bad); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 20px; }
.toolbar .search { width: 260px; }
.bulk { display: none; align-items: center; gap: 12px; padding: 10px 20px; background: var(--brand-soft); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-weight: 600; }
.bulk.on { display: flex; }
.pager { display: flex; gap: 4px; }
.pager button { min-width: 34px; height: 34px; padding: 0 8px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pager button:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.pager button[aria-current="page"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

/* 7. OVERLAYS ------------------------------------------------------------- */
.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 70; min-width: 220px; padding: 6px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2); display: none; }
.dropdown.open > .menu { display: block; animation: pop .14s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; text-align: left; font-weight: 500; color: var(--ink-2); }
.menu a:hover, .menu button:hover { background: var(--surface-2); color: var(--ink); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu .menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu .danger { color: var(--bad); }
.menu.wide { width: 340px; max-width: calc(100vw - 24px); padding: 0; }
.menu.wide .menu-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; margin: 0; }
.notif { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.notif:last-of-type { border-bottom: 0; }
.notif p { font-size: 13.5px; color: var(--ink-2); line-height: 1.4; } .notif p b { color: var(--ink); font-weight: 600; }
.notif time { font-size: 12px; color: var(--ink-3); }
.notif.unread { background: var(--brand-soft); }
.menu.wide .menu-foot { padding: 10px; border-top: 1px solid var(--line); }

.modal { position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(10,12,20,.55); }
.modal.open { display: flex; }
.modal-box { width: 100%; max-width: 480px; max-height: calc(100vh - 40px); overflow-y: auto; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-3); animation: rise .18s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.modal-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.modal-body { padding: 16px 20px; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 20px 20px; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 10px; width: min(360px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 11px; padding: 13px 14px; border-radius: var(--r-md); background: var(--ink); color: var(--bg); box-shadow: var(--shadow-2); animation: slide .2s ease; font-weight: 500; }
.toast .icon { margin-top: 1px; color: #5fe0b0; }
.toast.bad .icon { color: #ff9aa2; }
.toast button { margin-left: auto; border: 0; background: transparent; color: inherit; opacity: .6; padding: 0; display: grid; }
.toast button:hover { opacity: 1; }
.toast.out { opacity: 0; transform: translateX(12px); transition: opacity .2s, transform .2s; }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } }

/* 8. PAGE PIECES ---------------------------------------------------------- */
/* products */
.product { overflow: hidden; display: flex; flex-direction: column; }
.product-art { aspect-ratio: 4 / 3; display: grid; place-items: center; background: var(--c); color: var(--ink); }
.product-art svg { width: 56px; height: 56px; stroke: currentColor; fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
[data-theme="dark"] .product-art { background: color-mix(in srgb, var(--c) 22%, var(--surface)); }
.product-body { padding: 14px 16px 16px; display: grid; gap: 4px; flex: 1; }
.product-body h3 { font-size: 15px; font-weight: 600; }
.price { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stars { color: #e8a317; letter-spacing: 1px; font-size: 13px; }

/* calendar */
.cal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 20px; }
.cal-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -.02em; min-width: 170px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.cal-dow { padding: 9px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cal-day { min-height: 108px; padding: 6px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: transparent; text-align: left; display: flex; flex-direction: column; gap: 3px; align-items: stretch; overflow: hidden; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.other { color: var(--ink-3); background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.cal-day .d { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-day.today .d { background: var(--brand); color: var(--brand-ink); }
.cal-day.picked { box-shadow: inset 0 0 0 2px var(--brand-text); }
.cal-ev { display: block; padding: 2px 7px; border-radius: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-size: 12px; color: var(--ink-3); padding-left: 4px; }

/* messages */
.chat { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100vh - var(--topbar-h) - 48px); min-height: 480px; overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.chat-list-head { padding: 16px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.chat-items { overflow-y: auto; flex: 1; }
.chat-item { display: flex; gap: 11px; width: 100%; padding: 13px 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.chat-item:hover { background: var(--surface-2); }
.chat-item[aria-current="true"] { background: var(--brand-soft); }
.chat-item .txt { min-width: 0; flex: 1; }
.chat-item .top { display: flex; justify-content: space-between; gap: 8px; }
.chat-item b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item time { font-size: 12px; color: var(--ink-3); flex: none; }
.chat-item p { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.unread p { color: var(--ink); font-weight: 600; }
.chat-item.unread .top::after { content: ''; order: 3; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-text); flex: none; align-self: center; }
.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-back { display: none; }
.chat-log { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.msg { max-width: min(78%, 520px); padding: 10px 14px; border-radius: 14px 14px 14px 4px; background: var(--surface); border: 1px solid var(--line); align-self: flex-start; }
.msg.me { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.msg time { display: block; margin-top: 3px; font-size: 11.5px; opacity: .88; }
.chat-day { align-self: center; font-size: 12px; color: var(--ink-3); padding: 4px 0; }
.chat-form { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }

/* settings / profile */
.settings-grid { grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
.side-tabs { display: grid; gap: 2px; padding: 8px; align-content: start; }
.side-tabs button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: var(--r-sm); background: transparent; text-align: left; font-weight: 600; color: var(--ink-2); }
.side-tabs button:hover { background: var(--surface-2); color: var(--ink); }
.side-tabs button[aria-selected="true"] { background: var(--brand-soft); color: var(--brand-text); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--c); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-strong); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.theme-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-pick button { padding: 10px; border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--surface); text-align: left; font-weight: 600; display: grid; gap: 8px; }
.theme-pick button[aria-pressed="true"] { border-color: var(--brand-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }
.theme-pick i { display: block; height: 54px; border-radius: 7px; border: 1px solid var(--line); background: linear-gradient(90deg, #141726 0 26%, #f2f3f7 26%); }
.theme-pick .dk i { background: linear-gradient(90deg, #11131c 0 26%, #1c2030 26%); }
.theme-pick .au i { background: linear-gradient(135deg, #f2f3f7 50%, #1c2030 50%); }
.cover { height: 150px; border-radius: var(--r-lg) var(--r-lg) 0 0; background: linear-gradient(120deg, var(--brand), color-mix(in srgb, var(--brand) 40%, #19d3c5)); }
.profile-head { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; padding: 0 24px 20px; margin-top: -40px; }
.profile-head .avatar { border: 4px solid var(--surface); }
.profile-head h2 { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; font-size: 14px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; font-weight: 500; }

/* invoice */
.invoice { max-width: 880px; margin: 0 auto; width: 100%; }
.invoice-top { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding: 28px 28px 22px; }
.invoice h2 { font-size: 26px; font-weight: 700; letter-spacing: -.03em; }
.invoice-parties { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; padding: 0 28px 24px; }
.invoice-parties h3 { font-size: 12.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 6px; }
.invoice-sum { margin-left: auto; width: min(320px, 100%); padding: 18px 28px 26px; display: grid; gap: 8px; }
.invoice-sum div { display: flex; justify-content: space-between; gap: 16px; }
.invoice-sum .total { padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line); font-size: 18px; font-weight: 700; }

/* components page */
.demo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.swatch-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.swatch-row div { border-radius: var(--r-sm); border: 1px solid var(--line); overflow: hidden; font-size: 12.5px; }
.swatch-row i { display: block; height: 44px; background: var(--c); }
.swatch-row span { display: block; padding: 6px 8px; color: var(--ink-2); }

/* 9. AUTH PAGES ----------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: 40px clamp(24px, 7vw, 96px); background: var(--surface); }
.auth-form form { display: grid; gap: 16px; width: 100%; max-width: 400px; }
.auth-form h1 { font-size: 28px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; margin-bottom: 44px; }
.auth-art { position: relative; overflow: hidden; background: var(--side-bg); color: #fff; padding: clamp(32px, 6vw, 80px); display: flex; flex-direction: column; justify-content: flex-end; }
.auth-art::before { content: ''; position: absolute; inset: 0; background: radial-gradient(60% 50% at 80% 10%, color-mix(in srgb, var(--brand) 70%, transparent), transparent 70%), radial-gradient(50% 40% at 10% 90%, color-mix(in srgb, var(--brand) 35%, transparent), transparent 70%); }
.auth-art > * { position: relative; }
.auth-art blockquote { margin: 0; font-size: clamp(20px, 2.2vw, 28px); font-weight: 600; letter-spacing: -.02em; line-height: 1.3; max-width: 22em; }
.auth-art figcaption { margin-top: 18px; color: rgba(255,255,255,.7); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.big-code { font-size: clamp(96px, 22vw, 190px); font-weight: 700; letter-spacing: -.06em; line-height: .9; color: var(--brand-text); font-variant-numeric: tabular-nums; }

/* 10. RESPONSIVE, PRINT, MOTION ------------------------------------------- */
@media (max-width: 1200px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2-1, .cols-1-2 { grid-template-columns: minmax(0, 1fr); }
  .search.top { width: 180px; }
}
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .side-open .sidebar { transform: none; box-shadow: var(--shadow-3); }
  .side-open .backdrop { opacity: 1; pointer-events: auto; }
  .shell { margin-left: 0; }
  .menu-btn { display: grid; }
  .collapse-btn { display: none; }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat { grid-template-columns: 280px minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
}
@media (max-width: 900px) {
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .side-tabs { display: flex; overflow-x: auto; scrollbar-width: none; }
  .side-tabs::-webkit-scrollbar { display: none; }
  .side-tabs button { flex: none; white-space: nowrap; }
}
@media (max-width: 720px) {
  .content { padding: 16px; gap: 16px; }
  .grid { gap: 16px; }
  .topbar { padding: 0 14px; gap: 8px; }
  .search.top, .crumbs { display: none; }
  .cols-2, .cols-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .toolbar .search { width: 100%; }
  .toolbar .row-end { margin-left: 0; }
  .cal-day { min-height: 64px; padding: 4px 2px; align-items: center; }
  .cal-ev { width: 7px; height: 7px; padding: 0; border-radius: 50%; font-size: 0; display: inline-block; background: currentColor; }
  .cal-day .evs { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
  .cal-more { display: none; }
  .cal-dow { padding: 8px 2px; text-align: center; font-size: 11.5px; }
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100vh - var(--topbar-h) - 32px); }
  .chat-main { display: none; }
  .chat.thread .chat-list { display: none; }
  .chat.thread .chat-main { display: flex; }
  .chat-back { display: grid; }
  .invoice-parties { grid-template-columns: minmax(0, 1fr); }
  .invoice-top, .invoice-parties, .invoice-sum { padding-left: 18px; padding-right: 18px; }
  .theme-pick { grid-template-columns: minmax(0, 1fr); }
  .footer { padding: 14px 16px 18px; }
  .menu.wide { position: fixed; top: calc(var(--topbar-h) + 6px); right: 12px; left: 12px; width: auto; }
}
@media (max-width: 520px) {
  .cols-4 { grid-template-columns: minmax(0, 1fr); }
  .stat-value { font-size: 24px; }
  .cols-4.products { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .products .product-body { padding: 10px 12px 12px; }
  .products .product-art svg { width: 40px; height: 40px; }
  .products .row .muted { display: none; }
  .hide-xs { display: none !important; }
}
@media print {
  .sidebar, .topbar, .footer, .no-print, .toasts { display: none !important; }
  .shell { margin: 0 !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { border: 0; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
