/* ═══════════════════════════════════════════════════════════════════════
   switch@Zyno — Admin Console
   Design system: restrained, enterprise-fintech
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  /* ── surfaces (light; the Visitly-style console, 2026-10-30) ── */
  --bg:              #f5f6fa;   /* page */
  --bg-surface:      #eef0f6;   /* sidebar, table heads */
  --bg-elevated:     #ffffff;   /* cards */
  --bg-input:        #ffffff;
  --bg-hover:        #f1f3f9;
  --bg-active:       #e6e9f3;

  /* ── borders ── */
  --border:          #e3e6ee;
  --border-subtle:   #eceef4;
  --border-strong:   #cfd4e1;

  /* ── text ── */
  --text:            #1c2333;
  --text-secondary:  #5a6378;
  --text-muted:      #7c8499;   /* AA on white for small text */
  --text-disabled:   #b3b9c8;

  /* ── accents: indigo for data, navy for the primary action ── */
  --accent:          #5b7cf7;
  --accent-hover:    #4a6cf0;
  --accent-active:   #3d5fe0;
  --accent-bg:       rgba(91,124,247,.12);
  --accent-border:   rgba(91,124,247,.35);
  --accent-soft:     #aab7f0;   /* "completed" lavender */
  --primary:         #1f2a44;   /* dark button */
  --primary-hover:   #2a3758;
  --hero-1:          #3b5590;
  --hero-2:          #5a78c9;

  /* ── semantic ── */
  --ok:              #1f9d6a;
  --ok-bg:           rgba(31,157,106,.12);
  --warn:            #d9950f;
  --warn-bg:         rgba(240,180,41,.18);
  --warn-fill:       #f0b429;
  --err:             #d6336c;
  --err-bg:          rgba(214,51,108,.12);
  --err-fill:        #e24c7a;
  --info:            #5b7cf7;
  --info-bg:         rgba(91,124,247,.12);
  --neutral:         #6b7388;
  --neutral-bg:      rgba(107,115,136,.12);
  --violet:          #7c5cf0;
  --violet-bg:       rgba(124,92,240,.12);

  /* ── radii ── */
  --r-1:             4px;
  --r-2:             6px;
  --r-3:             8px;
  --r-4:             12px;
  --r-5:             16px;

  /* ── shadows (soft) ── */
  --sh-1:            0 1px 2px rgba(28,35,51,.05);
  --sh-2:            0 6px 20px rgba(28,35,51,.08);
  --sh-3:            0 16px 40px rgba(28,35,51,.14);

  /* ── typography ── */
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, "Roboto Mono", monospace;

  --fs-xs:    11px;
  --fs-sm:    12px;
  --fs-md:    13px;   /* body */
  --fs-lg:    14px;
  --fs-xl:    16px;
  --fs-2xl:   20px;
  --fs-3xl:   26px;

  --lh-tight:  1.30;
  --lh-body:   1.50;
  --lh-loose:  1.65;

  /* ── spacing (4px grid) ── */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-7:  32px;
  --s-8:  48px;
  --s-9:  64px;

  /* ── layout ── */
  --sidebar-w:  248px;
  --topbar-h:   56px;
  --content-max: 1400px;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11", "tnum", "ss01";
  height: 100%;
  overflow-x: hidden;
}

/* ═════════════ utility ═════════════ */
.hidden       { display: none !important; }
.muted        { color: var(--text-secondary); }
.dim          { color: var(--text-muted); }
.small        { font-size: var(--fs-sm); }
.xsmall       { font-size: var(--fs-xs); }
.mono         { font-family: var(--mono); font-size: var(--fs-sm); letter-spacing: -.01em; }
.error        { color: var(--err); }
.strong       { font-weight: 600; }
.nowrap       { white-space: nowrap; }
.right        { text-align: right; }
.grow         { flex: 1; }
.tabnum       { font-variant-numeric: tabular-nums; }

/* ═════════════ links ═════════════ */
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ═════════════ headings ═════════════ */
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: var(--fs-3xl); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-xl); line-height: var(--lh-tight); }
h3 { font-size: var(--fs-lg); line-height: var(--lh-tight); }
h4 { font-size: var(--fs-md); line-height: var(--lh-tight); }

/* ═════════════ page structure ═════════════ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  padding-bottom: var(--s-5);
  margin-bottom: var(--s-5);
  border-bottom: 1px solid var(--border-subtle);
}
.page-header-text  { min-width: 0; }
.page-title        { font-size: var(--fs-2xl); font-weight: 600; margin: 0 0 var(--s-1); }
.page-sub          { color: var(--text-secondary); font-size: var(--fs-md); margin: 0; }
.page-header-right { display: flex; align-items: center; gap: var(--s-2); flex-shrink: 0; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--s-6) 0 var(--s-3);
}
.section-title { font-size: var(--fs-lg); font-weight: 600; color: var(--text); margin: 0; }

/* ═════════════ buttons ═════════════ */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 500;
  line-height: 1;
  height: 32px;
  padding: 0 var(--s-3);
  border-radius: var(--r-3);
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, opacity .12s;
  white-space: nowrap;
  user-select: none;
}
button:hover, .btn:hover      { background: var(--primary-hover); }
button:active, .btn:active    { background: var(--primary); }
button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.secondary, .btn.secondary {
  background: var(--bg-elevated);
  box-shadow: var(--sh-1);
  color: var(--text);
  border-color: var(--border-strong);
}
button.secondary:hover, .btn.secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

button.ghost, .btn.ghost {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}
button.ghost:hover, .btn.ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

button.danger, .btn.danger {
  background: var(--err);
  color: #fff;
}
button.danger:hover, .btn.danger:hover { background: #bf2a5e; }

button.link, .btn.link {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  height: auto;
  padding: 0;
}
button.link:hover, .btn.link:hover { text-decoration: underline; background: transparent; }

button.sm { height: 26px; padding: 0 var(--s-2); font-size: var(--fs-sm); }
button.lg { height: 40px; padding: 0 var(--s-4); font-size: var(--fs-lg); }

/* ═════════════ inputs ═════════════ */
input, select, textarea {
  font: inherit;
  font-size: var(--fs-md);
  height: 34px;
  padding: 0 var(--s-3);
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
}
textarea { height: auto; padding: var(--s-2) var(--s-3); resize: vertical; min-height: 80px; }
input[readonly] { background: var(--bg-surface); color: var(--text-secondary); cursor: default; }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}
input:disabled, select:disabled, textarea:disabled {
  opacity: .5; cursor: not-allowed;
}

label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 var(--s-1);
}

.field       { margin-bottom: var(--s-3); }
.field-row   { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-bottom: var(--s-3); }
.field-help  { font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--s-1); }
.field-err   { font-size: var(--fs-sm); color: var(--err); margin-top: var(--s-1); }

/* ═════════════ AUTH SCREENS ═════════════ */
.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: var(--s-6);
  background: radial-gradient(ellipse at top, #e8ecf8 0%, var(--bg) 60%);
}
.login-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-5);
  padding: var(--s-7) var(--s-6);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--sh-2);
}
.login-card h1 { font-size: var(--fs-2xl); margin: 0 0 var(--s-1); }
.login-card > p:first-of-type { margin: 0 0 var(--s-6); color: var(--text-secondary); font-size: var(--fs-md); }
.login-card label { margin-top: var(--s-3); }
.login-card button[type=submit] { width: 100%; height: 38px; margin-top: var(--s-4); }
.login-card p.small { margin: var(--s-4) 0 0; color: var(--text-muted); font-size: var(--fs-sm); }
/* A checkbox beside its label, not stretched to a full-width text box by the
   input rules above ("I have saved these codes", the recovery-code card). */
.login-card label.check { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-4); cursor: pointer; }
.login-card label.check input[type=checkbox] { width: auto; height: auto; padding: 0; margin: 0; flex: none; accent-color: var(--accent); }

/* ═════════════ APP SHELL ═════════════ */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── sidebar ── */
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--s-4) var(--s-3) var(--s-3);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  gap: var(--s-2);
}

.brand-card {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-2) var(--s-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  box-shadow: var(--sh-1);
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.brand-text     { flex: 1; min-width: 0; }
.brand-title    { font-weight: 600; font-size: var(--fs-lg); line-height: 1.2; }
.brand-subtitle { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-caret, .user-caret { color: var(--text-muted); font-size: 12px; }

.nav-search {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: var(--s-1) 0 var(--s-2);
  padding: 0 var(--s-2) 0 var(--s-3);
  height: 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  color: var(--text-muted);
}
.nav-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.nav-search svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; flex-shrink: 0; }
.nav-search input { border: none; background: transparent; height: 100%; padding: 0; box-shadow: none !important; font-size: var(--fs-md); }
.nav-search input::-webkit-search-cancel-button { display: none; }
.nav-search kbd {
  font-family: var(--mono); font-size: 10px; color: var(--text-muted);
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}

.sidebar nav {
  display: flex; flex-direction: column;
  flex: 1;
  gap: 2px;
}
.nav-section-label {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: var(--s-3) var(--s-3) var(--s-1);
  margin-top: var(--s-2);
}
.nav-section-label:first-child { margin-top: 0; }
.sidebar nav a, .sidebar-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px var(--s-3);
  border-radius: var(--r-3);
  color: var(--text-secondary);
  font-size: var(--fs-lg);
  font-weight: 450;
  transition: background .1s, color .1s;
  text-decoration: none;
  border: 1px solid transparent;
}
.sidebar nav a:hover, .sidebar-links a:hover {
  background: rgba(255,255,255,.7);
  color: var(--text);
  text-decoration: none;
}
.sidebar nav a.active {
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 500;
  border-color: var(--border);
  box-shadow: var(--sh-1);
}
.sidebar nav a.search-miss { display: none; }
.nav-icon { width: 18px; height: 18px; display: inline-grid; place-items: center; color: var(--text-muted); flex-shrink: 0; }
.sidebar nav a.active .nav-icon { color: var(--text); }
.nav-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  background: var(--err-fill); color: #fff;
  font-size: var(--fs-xs); font-weight: 600;
  display: inline-grid; place-items: center;
  font-variant-numeric: tabular-nums;
}
.nav-count.warn { background: var(--warn-fill); color: #3a2a00; }
.nav-count.quiet { background: var(--bg-active); color: var(--text-secondary); }

.sidebar-links { display: flex; flex-direction: column; gap: 2px; padding-top: var(--s-2); }

/* sidebar foot: user menu */
.sidebar-foot {
  padding: 0;
  margin-top: var(--s-2);
  position: relative;
}
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  padding: var(--s-2);
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  cursor: pointer;
  text-align: left;
  height: auto;
  font-weight: 400;
  padding: var(--s-2) var(--s-3);
  box-shadow: var(--sh-1);
}
.user-menu-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: var(--fs-sm);
  flex-shrink: 0;
  border: 1px solid var(--accent-border);
}
.user-name { font-size: var(--fs-lg); font-weight: 500; line-height: 1.2; }
.user-email { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.2; margin-top: 2px; }
.user-menu-btn > div:nth-child(2) { flex: 1; min-width: 0; }
.user-menu-btn > div:nth-child(2) > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.user-caret {
  color: var(--text-muted);
  font-size: 10px;
}

/* dropdown appearing above the user menu */
.user-menu-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: var(--s-1);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-3);
  padding: var(--s-1);
  box-shadow: var(--sh-2);
  z-index: 20;
}
.user-menu-dropdown a, .user-menu-dropdown button {
  display: block;
  width: 100%;
  padding: 8px var(--s-3);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 400;
  border: none;
  border-radius: var(--r-2);
  text-align: left;
  cursor: pointer;
  height: auto;
  text-decoration: none;
}
.user-menu-dropdown a:hover, .user-menu-dropdown button:hover {
  background: var(--bg-hover);
  text-decoration: none;
}
.user-menu-dropdown .divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--s-1) 0;
}

/* ── main / topbar ── */
main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-7);
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: rgba(245,246,250,.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: sticky; top: 0;
  z-index: 5;
}
.topbar-left  { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: var(--s-2); }

.breadcrumb { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-lg); color: var(--text-secondary); white-space: nowrap; }
.breadcrumb .crumb-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; color: var(--text-muted); margin-right: var(--s-1); }
.breadcrumb .crumb-sep { color: var(--text-disabled); }
.breadcrumb #crumb-page { color: var(--text); font-weight: 500; }

.icon-btn {
  position: relative;
  width: 36px; height: 36px; padding: 0;
  display: inline-grid; place-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  color: var(--text-secondary);
  box-shadow: var(--sh-1);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--err-fill); border: 1.5px solid var(--bg-elevated); }
.icon-dot.warn { background: var(--warn-fill); }

/* status chip: health dot + the clock, "● THU, OCT 30 · 14:22" */
.status-chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 36px; padding: 0 var(--s-3);
  border-radius: var(--r-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--sh-1);
  font-family: var(--mono);
  font-size: var(--fs-sm);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.status-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-disabled); }
.status-chip.ok .dot   { background: var(--ok);   box-shadow: 0 0 0 3px var(--ok-bg); }
.status-chip.warn .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.status-chip.err .dot  { background: var(--err);  box-shadow: 0 0 0 3px var(--err-bg); }

/* view container */
#view {
  padding: var(--s-6) var(--s-7) var(--s-8);
  max-width: var(--content-max);
  width: 100%;
  flex: 1;
}

/* ═════════════ STATUS PILLS (badges) ═════════════ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--s-2);
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: .01em;
  border: 1px solid transparent;
  white-space: nowrap;
  background: var(--neutral-bg);
  color: var(--neutral);
}
.pill::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.pill.no-dot::before { display: none; }
.pill-ok      { background: var(--ok-bg);      color: var(--ok); }
.pill-warn    { background: var(--warn-bg);    color: #8a5a00; }
.pill-err     { background: var(--err-bg);     color: var(--err); }
.pill-info    { background: var(--info-bg);    color: var(--info); }
.pill-neutral { background: var(--neutral-bg); color: var(--neutral); }
.pill-violet  { background: var(--violet-bg);  color: var(--violet); }

/* ═════════════ CARDS ═════════════ */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-4);
  padding: var(--s-4) var(--s-5);
}

/* stat card */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-6);
}
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-5);
  box-shadow: var(--sh-1);
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}
.stat-label {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.stat-value {
  font-size: var(--fs-3xl);
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.stat-sub { font-size: var(--fs-sm); color: var(--text-secondary); }

/* ═════════════ TABLES ═════════════ */
.data-table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-5);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
}
th, td {
  text-align: left;
  padding: 10px var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
thead th {
  background: #f8f9fc;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
  height: 36px;
  padding-top: 0; padding-bottom: 0;
}
tbody tr {
  transition: background .08s;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--bg-hover); }
tbody tr.norow:hover { background: transparent; cursor: default; }
td.num, td.right, th.right { text-align: right; font-variant-numeric: tabular-nums; }
td.mono, .mono-cell { font-family: var(--mono); font-size: var(--fs-sm); }

/* action buttons in a row - inline set */
.row-actions { display: flex; gap: var(--s-1); }

/* ═════════════ TOOLBAR / FILTERS ═════════════ */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-bottom: var(--s-3);
}
.toolbar select, .toolbar input {
  height: 32px;
  min-width: 160px;
  width: auto;
}
.filter-active-indicator {
  padding: 2px var(--s-2);
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 500;
}

/* ═════════════ PAGINATION ═════════════ */
.pagination {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-3);
  align-items: center;
  justify-content: flex-end;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* ═════════════ DETAIL VIEWS ═════════════ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--s-3);
}
.back-link:hover { color: var(--text); text-decoration: none; }

.detail-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--s-2) var(--s-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-5);
  box-shadow: var(--sh-1);
  padding: var(--s-4) var(--s-5);
  margin-bottom: var(--s-4);
}
.detail-grid .k {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  padding-top: 2px;
}
.detail-grid .v {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--text);
  word-break: break-word;
  padding-bottom: 2px;
}
.detail-grid .v.plain { font-family: var(--sans); font-size: var(--fs-md); }

pre.code-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-3);
  padding: var(--s-3);
  overflow: auto;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 260px;
  margin: 0;
}

/* ═════════════ EMPTY STATE ═════════════ */
.empty-state {
  text-align: center;
  padding: var(--s-8) var(--s-6);
  color: var(--text-secondary);
}
.empty-state-icon {
  width: 44px; height: 44px;
  margin: 0 auto var(--s-3);
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-muted);
  display: grid; place-items: center;
  font-size: 20px;
}
.empty-state-title {
  color: var(--text);
  font-weight: 500;
  font-size: var(--fs-lg);
  margin: 0 0 var(--s-1);
}
.empty-state-sub {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin: 0 0 var(--s-4);
  max-width: 380px;
  margin-left: auto; margin-right: auto;
  line-height: var(--lh-loose);
}
.empty-state button { margin-top: var(--s-2); }

/* ═════════════ SKELETON LOADER ═════════════ */
.skel {
  background: linear-gradient(90deg,
    var(--bg-hover) 0%, var(--bg-active) 50%, var(--bg-hover) 100%);
  background-size: 200% 100%;
  animation: skel-pulse 1.4s ease-in-out infinite;
  border-radius: var(--r-2);
}
.skel-row {
  height: 40px;
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-4);
}
.skel-cell { height: 12px; border-radius: 3px;
  background: linear-gradient(90deg,
    var(--bg-hover) 0%, var(--bg-active) 50%, var(--bg-hover) 100%);
  background-size: 200% 100%;
  animation: skel-pulse 1.4s ease-in-out infinite;
}
@keyframes skel-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ═════════════ MODAL ═════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28,35,51,.45);
  backdrop-filter: blur(2px);
  z-index: 50;
  animation: fade-in .12s;
}
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 60;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-5);
  padding: var(--s-5) var(--s-6);
  box-shadow: var(--sh-3);
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow: auto;
  animation: scale-in .14s;
}
.modal h2 { margin: 0 0 var(--s-2); font-size: var(--fs-xl); }
.modal p { margin: 0 0 var(--s-3); color: var(--text-secondary); }
.modal .modal-actions {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  margin-top: var(--s-5);
}
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes scale-in { from { opacity: 0; transform: translate(-50%, -48%) scale(.98) } to { opacity: 1; transform: translate(-50%, -50%) scale(1) } }

/* invite-link reveal (unchanged position, updated styling) */
.invite-link-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  padding: var(--s-3);
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--accent);
  word-break: break-all;
  margin: var(--s-3) 0;
  line-height: var(--lh-loose);
}

/* ═════════════ TOAST ═════════════ */
#toast {
  position: fixed;
  bottom: var(--s-5);
  right: var(--s-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-3);
  padding: var(--s-3) var(--s-4);
  box-shadow: var(--sh-2);
  max-width: 380px;
  font-size: var(--fs-md);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  transform: translateY(20px);
  opacity: 0;
  transition: all .18s;
  z-index: 80;
  pointer-events: none;
}
#toast.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
#toast.ok::before  { content: "✓"; color: var(--ok);  font-size: 16px; font-weight: 700; }
#toast.err::before { content: "!"; color: var(--err); font-size: 16px; font-weight: 700; }

/* ═════════════ COPY BUTTON ═════════════ */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px 1px 4px;
  margin-left: 6px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--r-2);
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-xs);
  height: 20px;
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s, border-color .12s;
  flex-shrink: 0;
  vertical-align: middle;
}
.copy-btn::before {
  content: "";
  width: 10px;
  height: 10px;
  border: 1px solid currentColor;
  border-radius: 2px;
  box-shadow: -2px 2px 0 -1px transparent, -3px 3px 0 -2px currentColor;
  display: inline-block;
  transform: translateY(-1px);
}
.copy-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border);
}
.copy-btn.copied {
  color: var(--ok);
  border-color: transparent;
  opacity: 1;
}
.copy-btn.copied::before {
  content: "";
  width: 10px; height: 6px;
  border: none;
  border-left: 1.5px solid var(--ok);
  border-bottom: 1.5px solid var(--ok);
  transform: rotate(-45deg) translate(1px, -2px);
  box-shadow: none;
  border-radius: 0;
}
.copyable, .copyable-parent {
  display: inline-flex;
  align-items: center;
}
.copyable:hover .copy-btn,
.copyable-parent:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}

/* ═════════════ COLLAPSIBLE JSON ═════════════ */
details.json-detail {
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-2);
  background: var(--bg-surface);
  overflow: hidden;
}
details.json-detail > summary {
  cursor: pointer;
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  list-style: none;
  user-select: none;
  transition: background .1s;
}
details.json-detail > summary::-webkit-details-marker { display: none; }
details.json-detail > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 10px;
  transition: transform .1s;
}
details.json-detail[open] > summary::before { transform: rotate(90deg); }
details.json-detail > summary:hover { background: var(--bg-hover); }
details.json-detail[open] > summary {
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
}
details.json-detail > pre {
  margin: 0;
  padding: var(--s-3);
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
  background: var(--bg-elevated);
}
details.json-detail > pre .k { color: var(--accent-active); }
details.json-detail > pre .s { color: var(--ok); }
details.json-detail > pre .n { color: #8a5a00; }
details.json-detail > pre .b { color: var(--violet); }

/* ═════════════ SORTABLE TABLES ═════════════ */
th.sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 22px;
  position: relative;
  transition: color .1s;
}
th.sortable:hover { color: var(--text); }
th.sortable::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 1px solid var(--text-muted);
  border-bottom: 1px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg);
  opacity: .3;
  transition: opacity .1s, transform .1s;
}
th.sortable.sort-asc::after {
  transform: translateY(-30%) rotate(-135deg);
  opacity: 1;
  border-color: var(--accent);
}
th.sortable.sort-desc::after {
  transform: translateY(-70%) rotate(45deg);
  opacity: 1;
  border-color: var(--accent);
}

/* ═════════════ SEARCH INPUT (with prefix icon) ═════════════ */
.search-input-wrap {
  position: relative;
  display: inline-block;
  min-width: 220px;
}
.search-input-wrap input {
  padding-left: 30px;
}
.search-input-wrap::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--text-muted);
  border-radius: 50%;
  transform: translateY(-60%);
  pointer-events: none;
}
.search-input-wrap::after {
  content: "";
  position: absolute;
  left: 20px;
  top: 50%;
  width: 5px;
  height: 1.5px;
  background: var(--text-muted);
  transform: translateY(3px) rotate(45deg);
  transform-origin: 0 0;
  pointer-events: none;
}

/* ═════════════ AUDIT TIMELINE ═════════════ */
.timeline {
  position: relative;
  padding: var(--s-3) 0 var(--s-3) var(--s-6);
}
.timeline::before {
  content: "";
  position: absolute;
  left: 12px;
  top: var(--s-3);
  bottom: var(--s-3);
  width: 1px;
  background: var(--border-strong);
}
.timeline-item {
  position: relative;
  padding-bottom: var(--s-4);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.timeline-item.ok::before  { background: var(--ok);  box-shadow: 0 0 0 1px var(--ok); }
.timeline-item.err::before { background: var(--err); box-shadow: 0 0 0 1px var(--err); }
.timeline-item.warn::before { background: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.timeline-header {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.timeline-action {
  font-family: var(--mono);
  font-size: var(--fs-md);
  color: var(--text);
  font-weight: 500;
}
.timeline-actor {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.timeline-time {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-left: auto;
}

/* ═════════════ POS specifics ═════════════ */
.pos-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-5);
  box-shadow: var(--sh-1);
  padding: var(--s-5);
  max-width: 560px;
}
/* Touch-optimised inputs inside .pos-card — bigger targets + ≥16px
   font-size (iOS Safari zooms in on inputs < 16px on focus). */
.pos-card input, .pos-card select {
  font-size: 15px;
  height: 42px;
  padding: 0 14px;
}
.pos-card label {
  font-size: var(--fs-md);
  margin-bottom: 6px;
}
.pos-card button {
  height: 42px;
  font-size: var(--fs-lg);
  padding: 0 var(--s-4);
}
.pos-card .field-help { font-size: var(--fs-md); }
.pos-amount-input {
  font-variant-numeric: tabular-nums;
  font-size: 22px !important;
  height: 52px !important;
  font-weight: 500;
  letter-spacing: -.01em;
}
.pos-step-label {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 0 0 var(--s-2);
}
.pos-step-num {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
}

/* ═════════════ SKIP-TO-CONTENT (a11y) ═════════════ */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--s-3);
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-2);
  font-weight: 500;
  transition: top .12s;
}
.skip-link:focus,
.skip-link:focus-visible {
  top: var(--s-3);
  outline: 2px solid var(--text);
  outline-offset: 2px;
  text-decoration: none;
}

/* ═════════════ SR-ONLY (a11y) ═════════════ */
.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;
}

/* ═════════════ FOCUS RINGS (keyboard-only) ═════════════ */
/* base focus outline goes to focus-visible only, so mouse clicks don't ring */
a:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline-offset: -1px;
}
.sidebar nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
tbody tr.clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
th.sortable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ═════════════ TABLE HORIZONTAL SCROLL wrapper ═════════════ */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}


/* ═════════════ DASHBOARD (2026-10-30 redesign) ═════════════ */
.dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-5); }
.dash-greeting { font-size: var(--fs-3xl); font-weight: 600; letter-spacing: -.02em; margin: 0 0 var(--s-1); }
.dash-summary  { color: var(--text-secondary); font-size: var(--fs-lg); margin: 0; }
.dash-head-right { display: flex; gap: var(--s-2); align-items: center; flex-shrink: 0; padding-top: var(--s-1); }
.chip-select {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 38px; padding: 0 var(--s-3);
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-3);
  color: var(--text); font-size: var(--fs-lg); box-shadow: var(--sh-1);
}
.chip-select svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; color: var(--text-muted); }
.btn-primary-lg { height: 38px; padding: 0 var(--s-4); font-size: var(--fs-lg); border-radius: var(--r-3); gap: 6px; }
.btn-primary-lg svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* hero */
.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1.15fr 1fr; gap: var(--s-6);
  padding: var(--s-6) var(--s-7);
  border-radius: var(--r-5);
  background: linear-gradient(100deg, var(--hero-1) 0%, var(--hero-2) 100%);
  color: #fff;
  margin-bottom: var(--s-5);
  box-shadow: var(--sh-2);
}
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.14) 0%, rgba(255,255,255,0) 70%);
}
.hero::before { width: 480px; height: 480px; right: -160px; top: -220px; }
.hero::after  { width: 360px; height: 360px; right: 120px; bottom: -260px; }
.hero.calm { background: linear-gradient(100deg, #1f7a5a 0%, #3aa37f 100%); grid-template-columns: 1fr auto; align-items: center; }
.hero > * { position: relative; z-index: 1; }
.hero-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.14); color: #fff;
  margin-bottom: var(--s-3);
}
.hero-tag svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.hero h2 { color: #fff; font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; margin: 0 0 var(--s-3); }
.hero p  { color: rgba(255,255,255,.78); font-size: var(--fs-lg); margin: 0 0 var(--s-5); max-width: 520px; }
.hero-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.hero-actions .btn-light { background: #fff; color: var(--primary); border-color: #fff; height: 38px; padding: 0 var(--s-4); font-size: var(--fs-lg); border-radius: var(--r-3); }
.hero-actions .btn-light:hover { background: #eef1fb; }
.hero-actions .btn-glass { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.25); height: 38px; padding: 0 var(--s-4); font-size: var(--fs-lg); border-radius: var(--r-3); }
.hero-actions .btn-glass:hover { background: rgba(255,255,255,.26); }
.hero-side-label { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.8); margin-bottom: var(--s-3); display: flex; align-items: center; gap: 6px; }
.hero-side-label svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.hero-list { display: flex; flex-direction: column; gap: var(--s-2); }
.hero-row {
  display: grid; grid-template-columns: 72px 1fr auto auto; align-items: center; gap: var(--s-3);
  padding: 10px var(--s-4);
  background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.14); border-radius: var(--r-4);
  color: #fff; text-decoration: none; font-size: var(--fs-lg);
}
.hero-row:hover { background: rgba(255,255,255,.2); text-decoration: none; color: #fff; }
.hero-row .time { font-family: var(--mono); font-size: var(--fs-sm); color: rgba(255,255,255,.85); }
.hero-row .who  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-row .who .mono { color: rgba(255,255,255,.75); }
.hero-row .amt  { font-variant-numeric: tabular-nums; font-weight: 500; }
.hero-row .why  { font-family: var(--mono); font-size: var(--fs-xs); color: rgba(255,255,255,.75); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-big { font-size: 40px; font-weight: 600; letter-spacing: -.03em; line-height: 1; }
.hero-big small { display: block; font-size: var(--fs-sm); font-weight: 400; letter-spacing: .06em; text-transform: uppercase; font-family: var(--mono); color: rgba(255,255,255,.8); margin-top: 6px; }

/* stat cards with a sparkline */
.stat-card { position: relative; gap: 0; }
.stat-card .stat-top { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-2); }
.stat-card .stat-value { font-size: 30px; font-weight: 600; letter-spacing: -.03em; }
.stat-card .stat-value small { font-size: var(--fs-lg); font-weight: 400; color: var(--text-secondary); letter-spacing: 0; margin-left: 6px; }
.stat-card .spark { width: 84px; height: 30px; flex-shrink: 0; }
.stat-card .spark rect { fill: var(--accent-soft); }
.stat-card .spark rect.hi { fill: var(--accent); }
.stat-card .stat-foot {
  display: flex; align-items: center; gap: var(--s-2);
  margin: var(--s-3) calc(-1 * var(--s-5)) calc(-1 * var(--s-4));
  padding: 10px var(--s-5);
  border-top: 1px solid var(--border-subtle);
  background: #fafbfe; border-radius: 0 0 var(--r-5) var(--r-5);
  color: var(--text-secondary); font-size: var(--fs-sm);
}
.stat-foot .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-disabled); flex-shrink: 0; }
.stat-foot .dot.ok { background: var(--ok); } .stat-foot .dot.warn { background: var(--warn-fill); } .stat-foot .dot.err { background: var(--err-fill); } .stat-foot .dot.info { background: var(--accent); }

/* two-column body */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, 1fr); gap: var(--s-4); align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.panel { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-5); box-shadow: var(--sh-1); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--border-subtle);
  background: #fafbfe; border-radius: var(--r-5) var(--r-5) 0 0;
}
.panel-title { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); }
.panel-title svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; color: var(--text-muted); }
.panel-title .badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--err-fill); color: #fff; font-family: var(--sans); font-size: var(--fs-xs); font-weight: 600; display: inline-grid; place-items: center; letter-spacing: 0; }
.panel-link { font-size: var(--fs-md); color: var(--text); display: inline-flex; align-items: center; gap: 4px; }
.panel-link:hover { text-decoration: none; color: var(--accent); }
.panel-body { padding: var(--s-4) var(--s-5); }
.panel-legend { display: flex; flex-wrap: wrap; gap: 4px var(--s-4); font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); }
.panel-legend span { display: inline-flex; align-items: center; gap: 6px; }
.panel-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* hour grid */
.hour-grid-wrap { padding: var(--s-4) var(--s-5) var(--s-3); }
.hour-grid-title { display: flex; align-items: baseline; gap: 8px; margin-bottom: var(--s-4); }
.hour-grid-title b { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.hour-grid-title span { color: var(--text-secondary); font-size: var(--fs-lg); }
.hour-grid { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; position: relative; margin-top: 34px; }
.hour-col { display: flex; flex-direction: column-reverse; gap: 3px; min-height: 0; border-radius: 4px; }
.hour-col.now { outline: 2px solid var(--primary); outline-offset: 1px; border-radius: 5px; }
.hour-col .sq { aspect-ratio: 1; border-radius: 3px; background: var(--bg-active); }
.hour-col .sq.credited { background: var(--accent); }
.hour-col .sq.pending { background: var(--accent-soft); }
.hour-col .sq.processing { background: var(--warn-fill); }
.hour-col .sq.failed { background: var(--err-fill); }
.hour-col .sq.more { background: var(--text-disabled); }
.hour-grid .xlab { font-family: var(--mono); font-size: 10px; color: var(--text-muted); text-align: center; padding-top: 4px; }
.hour-grid .now-flag {
  position: absolute; top: -30px; transform: translateX(-50%);
  background: var(--primary); color: #fff; font-family: var(--mono); font-size: 10px; letter-spacing: .06em;
  padding: 3px 7px; border-radius: 5px; white-space: nowrap;
}
.hour-grid .now-flag::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1px; height: 14px; background: var(--primary); }
.hour-foot { display: flex; justify-content: space-between; margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border-subtle); font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); }

/* attention list */
.attn-list { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); }
.attn-row {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: var(--s-3);
  padding: 10px var(--s-3);
  border: 1px solid var(--border-subtle); border-radius: var(--r-4);
  background: #fff;
}
.attn-row:hover { border-color: var(--border); background: #fcfcfe; }
.attn-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.attn-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.attn-icon.warn { background: var(--warn-bg); color: #8a5a00; }
.attn-icon.err  { background: var(--err-bg);  color: var(--err); }
.attn-icon.info { background: var(--accent-bg); color: var(--accent-active); }
.attn-title { font-weight: 500; font-size: var(--fs-lg); color: var(--text); }
.attn-sub   { font-size: var(--fs-md); color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attn-actions { display: flex; gap: 6px; }
.attn-actions button, .attn-actions .btn { height: 32px; border-radius: var(--r-3); font-size: var(--fs-md); padding: 0 var(--s-3); }
.attn-actions .icon-btn { width: 32px; height: 32px; }

/* live list */
.live-list { display: flex; flex-direction: column; }
.live-row {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: var(--s-3);
  padding: 12px var(--s-5);
  border-bottom: 1px solid var(--border-subtle);
  color: inherit; text-decoration: none;
}
.live-row:last-child { border-bottom: none; }
.live-row:hover { background: var(--bg-hover); text-decoration: none; color: inherit; }
.live-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: var(--fs-sm); color: #fff; background: var(--hero-2); }
.live-avatar.b { background: #7a5af5; } .live-avatar.c { background: #2f9e8f; } .live-avatar.d { background: #c2607a; } .live-avatar.e { background: #d08a1d; }
.live-title { font-weight: 500; font-size: var(--fs-lg); display: flex; align-items: center; gap: 8px; }
.live-sub   { font-size: var(--fs-md); color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-right { text-align: right; }
.live-right .when { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); }
.live-bar { display: flex; gap: 2px; margin-top: 6px; justify-content: flex-end; }
.live-bar i { width: 6px; height: 6px; border-radius: 1.5px; background: var(--bg-active); display: inline-block; }
.live-bar i.on { background: var(--accent); }
.live-bar i.err { background: var(--err-fill); }
.live-bar i.warn { background: var(--warn-fill); }
.live-pill { font-family: var(--mono); font-size: var(--fs-xs); padding: 2px 8px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); letter-spacing: .04em; }

.panel-empty { padding: var(--s-6) var(--s-5); text-align: center; color: var(--text-secondary); font-size: var(--fs-md); }
.panel-empty b { display: block; color: var(--text); font-weight: 500; margin-bottom: 4px; font-size: var(--fs-lg); }

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .dash-head { flex-direction: column; }
  .panel-head { flex-wrap: wrap; row-gap: var(--s-2); }
  .panel-legend { width: 100%; }
  .dash-greeting { font-size: var(--fs-2xl); }
  .hero { padding: var(--s-5); }
  .hero h2 { font-size: var(--fs-2xl); }
  .hero-row { grid-template-columns: 60px 1fr auto; } .hero-row .why { display: none; }
  .hour-grid { gap: 2px; }
  .hour-grid .xlab:nth-child(odd) { visibility: hidden; }
}

/* ═════════════ RESPONSIVE ═════════════ */

/* --- tablet + small desktop (≤900px): off-canvas sidebar, tighter padding --- */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 260px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s;
    box-shadow: var(--sh-3);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar-mobile-menu { display: inline-grid !important; }
  .topbar { padding: 0 var(--s-4); }
  #view { padding: var(--s-4); }
  .page-header { flex-direction: column; align-items: flex-start; }
  .detail-grid { grid-template-columns: 1fr; gap: var(--s-1); }
  .detail-grid .k { padding-top: var(--s-2); }
  .field-row { grid-template-columns: 1fr; }
}
.topbar-mobile-menu { display: none; }

/* mobile-menu backdrop when sidebar is open */
@media (max-width: 900px) {
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(28,35,51,.4);
    z-index: 39;
    animation: fade-in .12s;
  }
}

/* --- mobile (≤640px): tables collapse to card rows, modal full-height --- */
@media (max-width: 640px) {
  #view { padding: var(--s-3); }
  .page-title { font-size: var(--fs-xl); }
  .toolbar { gap: var(--s-2); }
  .toolbar select, .toolbar input, .search-input-wrap { width: 100%; min-width: 0; }
  .search-input-wrap { display: block; }

  /* Tables → each row becomes a stacked list of label / value pairs */
  .data-table-wrap table { display: block; }
  .data-table-wrap thead { display: none; }
  .data-table-wrap tbody { display: block; }
  .data-table-wrap tbody tr {
    display: block;
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--border-subtle);
  }
  .data-table-wrap tbody tr:last-child { border-bottom: none; }
  .data-table-wrap tbody tr.clickable { cursor: pointer; }
  .data-table-wrap tbody tr td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--s-3);
    padding: 3px 0;
    border: none;
    text-align: left !important;
    min-height: 22px;
  }
  .data-table-wrap tbody tr td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
    flex-shrink: 0;
  }
  .data-table-wrap tbody tr td.num,
  .data-table-wrap tbody tr td.right { text-align: right !important; }
  .data-table-wrap tbody tr td .muted.small { display: inline; margin-left: 4px; }

  /* modal → bottom-sheet */
  .modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--r-4) var(--r-4) 0 0;
    top: auto; left: 0; right: 0; bottom: 0;
    transform: none;
    padding: var(--s-4);
  }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; height: 44px; }
  @keyframes scale-in {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* login card → fills viewport */
  .login-screen { padding: var(--s-3); }
  .login-card { padding: var(--s-5) var(--s-4); box-shadow: none; border: 1px solid var(--border-subtle); }
  .login-card h1 { font-size: var(--fs-xl); }

  /* topbar: hide the clock, keep only badge + refresh */
  #now-tick { display: none; }
  .status-chip { padding: 0 10px; }
  .breadcrumb #crumb-section, .breadcrumb .crumb-sep { display: none; }
  .topbar { padding: 0 var(--s-3); }
  #refresh .lg-only { display: none; }

  /* POS: single-column and taller buttons */
  .pos-card { padding: var(--s-4); }
  .field-row { grid-template-columns: 1fr; gap: var(--s-2); }
  .pos-card button { width: 100%; }

  /* timeline: reduce indent */
  .timeline { padding-left: var(--s-5); }
  .timeline::before { left: 8px; }
  .timeline-item::before { left: -17px; }

  /* toast: full width at the bottom */
  #toast { left: var(--s-3); right: var(--s-3); bottom: var(--s-3); max-width: none; }
}

/* --- prefers-reduced-motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .skel, .skel-cell { animation: none; background: var(--bg-hover); }
}

/* --- high-contrast fallback: force borders visible if OS says so --- */
@media (prefers-contrast: more) {
  :root {
    --border:        #9aa3b8;
    --border-subtle: #b4bccd;
    --border-strong: #6b758c;
    --text-muted:    #4e576b;
  }
  .pill { border-color: currentColor; }
}

/* selection */
::selection { background: var(--accent-bg); color: var(--text); }

/* scrollbars (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* a table placed inside a panel takes the panel's edges */
.panel .data-table-wrap.flush { border: none; box-shadow: none; border-radius: 0 0 var(--r-5) var(--r-5); }
