/* ============================================================
   Epsopay Admin Console — "Liquid Glass"
   Modern glassmorphism system: frosted translucent panels float
   over a soft aurora of the brand forest-green & brass on cool
   pearl. Skeuomorphic glossy icon chips with a sweeping glint.
   Sora display · Inter body · JetBrains Mono numerals.
   Light default · smoked-glass dark optional.
   Brand: 1F7A5C forest · B07D2A brass · cool ink
   ============================================================ */

:root {
  /* ---- surfaces (LIGHT glass is the default) ---- */
  --bg:            #e6eaf3;   /* cool pearl */
  --bg-tint:       #dde2ee;
  --panel:         rgba(255, 255, 255, 0.60);   /* frosted card */
  --panel-2:       rgba(255, 255, 255, 0.40);   /* row hover / faint glass */
  --panel-hi:      rgba(255, 255, 255, 0.80);   /* raised glass chip */
  --line:          rgba(255, 255, 255, 0.65);   /* bright glass edge */
  --line-soft:     rgba(28, 35, 64, 0.07);      /* inner hairline */
  --rule:          rgba(28, 35, 64, 0.16);

  --txt:           #161b2b;
  --txt-dim:       #515a72;
  --txt-faint:     #8b93a8;

  /* ---- signature: forest + brass ---- */
  --accent:        #1f7a5c;
  --accent-deep:   #145d46;
  --accent-bright: #2eab80;   /* gradient highlight */
  --accent-soft:   rgba(31, 122, 92, 0.12);
  --accent-glow:   rgba(31, 122, 92, 0.28);
  --brass:         #b07d2a;
  --brass-soft:    rgba(176, 125, 42, 0.14);

  /* ---- semantic palette (used by app.js inline styles) ---- */
  --ok:            #1f9d6b;
  --warn:          #c08a1e;
  --bad:           #d8453d;
  --info:          #2f87a8;
  --mute:          #8b93a8;

  /* ---- legacy var names kept resolving (JS gradients/markup) ---- */
  --rose:          #d8453d;
  --crimson:       #b07d2a;
  --plum:          #7a5bc4;
  --amber:         #c08a1e;
  --cyan:          #2f87a8;
  --violet:        #7a5bc4;
  --green:         #1f9d6b;

  /* ---- component tokens ---- */
  --input-bg:      rgba(255, 255, 255, 0.55);
  --track:         rgba(28, 35, 64, 0.10);
  --ghost-hover:   rgba(255, 255, 255, 0.55);
  --scroll-hover:  rgba(28, 35, 64, 0.26);
  --overlay:       rgba(18, 24, 44, 0.42);
  --sidebar-bg:    rgba(255, 255, 255, 0.46);
  --topbar-bg:     rgba(255, 255, 255, 0.52);
  --thead-bg:      rgba(255, 255, 255, 0.72);

  /* ---- glass mechanics ---- */
  --blur:          22px;
  --blur-sm:       12px;
  --glass-hi:      rgba(255, 255, 255, 0.70);   /* inner top highlight */

  --r-sm: 9px;
  --r:    16px;
  --r-lg: 22px;
  --shadow:    0 26px 60px -28px rgba(18, 24, 44, 0.45), 0 6px 20px -12px rgba(18, 24, 44, 0.20);
  --shadow-sm: 0 8px 22px -14px rgba(18, 24, 44, 0.32);

  --font-display: 'Sora', system-ui, -apple-system, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;
}

/* ---------------- DARK THEME — "smoked glass" ---------------- */
html[data-theme="dark"] {
  --bg:            #0b0e16;
  --bg-tint:       #10141f;
  --panel:         rgba(30, 37, 54, 0.55);
  --panel-2:       rgba(255, 255, 255, 0.05);
  --panel-hi:      rgba(48, 57, 80, 0.62);
  --line:          rgba(255, 255, 255, 0.12);
  --line-soft:     rgba(255, 255, 255, 0.07);
  --rule:          rgba(255, 255, 255, 0.18);

  --txt:           #eef1f8;
  --txt-dim:       #aab2c6;
  --txt-faint:     #6f7890;

  --accent:        #35c490;
  --accent-deep:   #23a376;
  --accent-bright: #4cdba6;
  --accent-soft:   rgba(53, 196, 144, 0.14);
  --accent-glow:   rgba(53, 196, 144, 0.30);
  --brass:         #dcae65;
  --brass-soft:    rgba(220, 174, 101, 0.16);

  --ok:            #35c490;
  --warn:          #dcae65;
  --bad:           #f0766c;
  --info:          #5cb6d4;
  --mute:          #8b93a8;

  --rose:          #f0766c;
  --crimson:       #dcae65;
  --plum:          #b095ec;
  --amber:         #dcae65;
  --cyan:          #5cb6d4;
  --violet:        #b095ec;
  --green:         #35c490;

  --input-bg:      rgba(255, 255, 255, 0.06);
  --track:         rgba(255, 255, 255, 0.10);
  --ghost-hover:   rgba(255, 255, 255, 0.08);
  --scroll-hover:  rgba(255, 255, 255, 0.20);
  --overlay:       rgba(4, 7, 13, 0.66);
  --sidebar-bg:    rgba(20, 26, 40, 0.55);
  --topbar-bg:     rgba(16, 21, 33, 0.55);
  --thead-bg:      rgba(34, 42, 60, 0.78);
  --glass-hi:      rgba(255, 255, 255, 0.16);

  --shadow:    0 28px 64px -26px rgba(0, 0, 0, 0.78), 0 6px 22px -12px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 10px 26px -16px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* aurora mesh — gives the frosted glass something to refract */
  background-image:
    radial-gradient(820px 620px at 8% -10%, rgba(46, 171, 128, 0.30), transparent 60%),
    radial-gradient(760px 560px at 98% 4%, rgba(176, 125, 42, 0.22), transparent 58%),
    radial-gradient(900px 700px at 52% 118%, rgba(47, 135, 168, 0.24), transparent 60%),
    radial-gradient(700px 560px at 78% 60%, rgba(122, 91, 196, 0.16), transparent 60%);
  background-attachment: fixed;
}
html[data-theme="dark"] body {
  background-image:
    radial-gradient(820px 620px at 8% -10%, rgba(53, 196, 144, 0.20), transparent 60%),
    radial-gradient(760px 560px at 98% 4%, rgba(220, 174, 101, 0.12), transparent 58%),
    radial-gradient(900px 700px at 52% 118%, rgba(47, 135, 168, 0.18), transparent 60%),
    radial-gradient(700px 560px at 78% 60%, rgba(122, 91, 196, 0.16), transparent 60%);
}

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); background-clip: padding-box; }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.mono { font-family: var(--font-mono); font-feature-settings: 'tnum' 1; letter-spacing: -.2px; }

/* uppercase micro-labels */
.eyebrow-label,
.field label,
.k-label,
table.grid thead th,
.nav-group-label,
.brand-sub,
.bar-line .bl-label,
.gauge .gl {
  font-family: var(--font-body);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

/* ---------------- LOGIN ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 46px 42px 36px;
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hi);
  position: relative;
  overflow: hidden;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}
.login-card::before {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--accent-bright), var(--accent) 55%, var(--brass));
  opacity: .95;
}
.brand { display: flex; align-items: center; gap: 13px; margin-bottom: 4px; }
.brand-mark {
  position: relative; width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; overflow: hidden;
  font-family: var(--font-display); font-weight: 700;
  color: #fff; font-size: 22px; line-height: 1;
  background: linear-gradient(155deg, var(--accent-bright), var(--accent-deep));
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.55),
    inset 0 -3px 6px rgba(0,0,0,.22),
    0 8px 18px -6px var(--accent-glow);
  text-shadow: 0 1px 2px rgba(0,0,0,.28);
}
.brand-mark::before {
  content: ''; position: absolute; inset: 0 0 48% 0;
  background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,0));
  border-radius: 14px 14px 44% 44%;
}
.brand-name {
  font-family: var(--font-display); font-weight: 700; font-size: 21px;
  letter-spacing: -.5px;
}
.brand-name b { color: var(--accent); font-weight: 700; }
.brand-sub { color: var(--txt-faint); font-size: 10px; letter-spacing: 2.4px; margin-top: 2px; font-weight: 600; }

.login-card h1 {
  font-family: var(--font-display); font-size: 30px; font-weight: 600;
  letter-spacing: -.8px; margin: 30px 0 6px;
}
.login-card .lead { color: var(--txt-dim); font-size: 14px; margin-bottom: 26px; max-width: 34ch; }

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 10.5px; color: var(--txt-faint);
  margin-bottom: 7px; font-weight: 700;
}
.input, .select, textarea.input {
  width: 100%;
  background: var(--input-bg);
  -webkit-backdrop-filter: blur(var(--blur-sm));
  backdrop-filter: blur(var(--blur-sm));
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  color: var(--txt);
  transition: border-color .16s, box-shadow .16s, background .16s;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(18,24,44,0.06);
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--accent);
  background: var(--panel-hi);
  box-shadow: 0 0 0 4px var(--accent-glow), inset 0 1px 2px rgba(18,24,44,0.05);
}
.input::placeholder { color: var(--txt-faint); }
.select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%238b93a8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}

/* ---- glossy buttons ---- */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 10px 17px; font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: transform .12s, box-shadow .16s, background .16s, border-color .16s, opacity .15s, color .15s;
  white-space: nowrap; user-select: none;
}
.btn::after {  /* sweeping glint */
  content: ''; position: absolute; top: -50%; left: -60%; width: 40%; height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
  transform: rotate(22deg); pointer-events: none;
  transition: left .55s ease;
}
.btn:hover::after { left: 130%; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  color: #fff;
  background: linear-gradient(160deg, var(--accent-bright), var(--accent-deep));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 8px 18px -8px var(--accent-glow);
  text-shadow: 0 1px 1px rgba(0,0,0,.2);
}
.btn-primary:hover:not(:disabled) { box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 12px 24px -8px var(--accent-glow); }
.btn-ghost {
  background: var(--panel);
  -webkit-backdrop-filter: blur(var(--blur-sm)); backdrop-filter: blur(var(--blur-sm));
  color: var(--txt); border-color: var(--line);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-sm);
}
.btn-ghost:hover:not(:disabled) { background: var(--panel-hi); }
.btn-danger { background: rgba(216,69,61,0.12); color: var(--bad); border-color: rgba(216,69,61,0.40); }
.btn-danger:hover:not(:disabled) { background: rgba(216,69,61,0.20); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }

.login-msg { margin-top: 16px; font-size: 13px; min-height: 18px; color: var(--bad); }
.api-line { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }

/* ---------------- APP SHELL ---------------- */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar-bg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  border-right: 1px solid var(--line);
  padding: 22px 16px 20px;
  display: flex; flex-direction: column; gap: 1px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 2px 8px 20px; margin-bottom: 6px; border-bottom: 1px solid var(--line-soft); }
.nav-group-label {
  font-size: 10px; color: var(--txt-faint); padding: 18px 12px 8px; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--txt-dim); cursor: pointer; font-weight: 500;
  transition: background .14s, color .14s, box-shadow .14s; position: relative;
}
.nav-item:hover { background: var(--panel-2); color: var(--txt); }
.nav-item.active {
  background: var(--panel-hi); color: var(--accent-deep); font-weight: 600;
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-sm);
}
.nav-item.active::before {
  content: ''; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent)); border-radius: 0 3px 3px 0;
}
html[data-theme="dark"] .nav-item.active { color: var(--accent); }
.nav-ico { width: 20px; display: inline-grid; place-items: center; opacity: .92; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  min-height: 74px; flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 32px;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  position: sticky; top: 0; z-index: 20;
}
.topbar .page-title {
  font-family: var(--font-display); font-size: 23px; font-weight: 600;
  letter-spacing: -.6px;
}
.topbar .spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 13px 5px 5px; border: 1px solid var(--line); border-radius: 40px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(var(--blur-sm)); backdrop-filter: blur(var(--blur-sm));
  box-shadow: inset 0 1px 0 var(--glass-hi);
}
.user-chip .avatar {
  position: relative; overflow: hidden;
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(155deg, var(--accent-bright), var(--accent-deep)); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
  font-family: var(--font-display);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.5), inset 0 -2px 4px rgba(0,0,0,.2);
}
.user-chip .uname { font-weight: 600; font-size: 13px; }
.user-chip .urole { font-size: 11px; color: var(--txt-faint); }

.content { padding: 32px; flex: 1; min-width: 0; max-width: 1340px; }
.content > * { animation: rise .35s ease both; }

/* ---------------- PAGE PRIMITIVES ---------------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h2 {
  font-family: var(--font-display); font-size: 30px; font-weight: 700;
  letter-spacing: -.9px; line-height: 1.05;
}
.page-head .sub { color: var(--txt-dim); font-size: 14px; margin-top: 6px; }
.page-head .spacer { flex: 1; }

.panel {
  background: var(--panel);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-hi);
}
.panel-pad { padding: 22px 24px; }
.panel-title {
  font-family: var(--font-display); font-weight: 600; font-size: 16px;
  letter-spacing: -.3px;
}

/* KPI cards — frosted with glossy icon chip */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi {
  background: var(--panel);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 20px 22px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-hi);
  transition: transform .18s, box-shadow .18s;
}
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent)); opacity: .9;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hi); }
.kpi .k-label { font-size: 10.5px; color: var(--txt-faint); font-weight: 700; letter-spacing: 1.2px; }
.kpi .k-value {
  font-family: var(--font-display); font-size: 33px; font-weight: 700;
  margin-top: 10px; letter-spacing: -1.2px; line-height: 1;
  font-feature-settings: 'tnum' 1;
}
.kpi .k-foot { font-size: 12.5px; color: var(--txt-dim); margin-top: 8px; }
.kpi .k-spark { position: absolute; right: 18px; top: 18px; }
.kpi.accent .k-value { color: var(--accent); }
.kpi.cyan   .k-value { color: var(--cyan); }
.kpi.cyan::before   { background: linear-gradient(180deg, var(--cyan), #1f6f8c); }
.kpi.amber  .k-value { color: var(--brass); }
.kpi.amber::before  { background: linear-gradient(180deg, var(--brass), #8a5f17); }
.kpi.violet .k-value { color: var(--violet); }
.kpi.violet::before { background: linear-gradient(180deg, var(--violet), #5a3f8a); }
.kpi.green  .k-value { color: var(--green); }
.kpi.green::before  { background: linear-gradient(180deg, var(--green), #178a5d); }

/* Filters / toolbar — glassy controls */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px;
  padding: 12px; border-radius: var(--r);
  background: var(--panel);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-hi);
}
.toolbar .search { flex: 1; min-width: 220px; position: relative; }
.toolbar .search input { padding-left: 38px; }
.toolbar .search .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--txt-faint); pointer-events: none; }
.input.compact, .select.compact { padding: 8px 11px; }
.select.compact { min-width: 120px; padding-right: 30px; }

/* Table — glass ledger */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid thead th {
  text-align: left; padding: 13px 16px; font-size: 10.5px;
  color: var(--txt-faint); font-weight: 700; border-bottom: 1px solid var(--rule);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
  background: var(--thead-bg);
  -webkit-backdrop-filter: blur(var(--blur-sm)); backdrop-filter: blur(var(--blur-sm));
}
table.grid tbody td { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.grid tbody tr { transition: background .12s; }
table.grid tbody tr:hover { background: var(--panel-2); }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid td .muted { color: var(--txt-faint); }
table.grid .num { font-family: var(--font-mono); text-align: right; font-feature-settings: 'tnum' 1; }
.empty-row td { text-align: center; color: var(--txt-faint); padding: 46px !important; font-family: var(--font-display); font-size: 14px; }

/* Status pills — frosted glass capsules */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 11px; border-radius: 30px; font-size: 11.5px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap; letter-spacing: .2px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
.pill.ok   { color: var(--ok);   background: rgba(31,157,107,0.14);  border-color: rgba(31,157,107,0.30); }
.pill.warn { color: var(--warn); background: var(--brass-soft);      border-color: rgba(176,125,42,0.32); }
.pill.bad  { color: var(--bad);  background: rgba(216,69,61,0.13);   border-color: rgba(216,69,61,0.30); }
.pill.info { color: var(--info); background: rgba(47,135,168,0.13);  border-color: rgba(47,135,168,0.30); }
.pill.mute { color: var(--mute); background: rgba(139,147,168,0.14); border-color: rgba(139,147,168,0.28); }
.pill.violet{color: var(--violet);background: rgba(122,91,196,0.13); border-color: rgba(122,91,196,0.30); }

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 30px; font-size: 11px;
  background: var(--panel-hi); border: 1px solid var(--line); color: var(--txt-dim); margin-right: 4px;
}

/* Pagination */
.pager { display: flex; align-items: center; gap: 12px; padding: 16px; justify-content: flex-end; color: var(--txt-dim); font-size: 13px; }
.pager .pginfo { margin-right: auto; }

/* Modal — frosted sheet */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: grid; place-items: center; z-index: 100; padding: 24px;
  animation: fade .2s ease both;
}
.modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--panel);
  -webkit-backdrop-filter: blur(28px) saturate(160%); backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hi); animation: rise .28s cubic-bezier(.2,.8,.2,1) both;
}
.modal.wide { max-width: 780px; }
.modal-head { display: flex; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--line-soft); }
.modal-head h3 { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -.4px; }
.modal-head .x { margin-left: auto; cursor: pointer; color: var(--txt-faint); font-size: 24px; line-height: 1; padding: 0 4px; }
.modal-head .x:hover { color: var(--txt); }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid var(--line-soft); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* Detail rows */
.dl { display: grid; grid-template-columns: 168px 1fr; gap: 0; }
.dl > div { padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.dl .dt { color: var(--txt-faint); font-size: 12px; letter-spacing: .3px; }
.dl .dd { font-weight: 500; }

/* Toast — glass notification */
#toasts { position: fixed; right: 24px; bottom: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--panel);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%); backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 14px; padding: 13px 17px; min-width: 250px; max-width: 370px;
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hi); animation: slidein .28s cubic-bezier(.2,.8,.2,1) both; font-size: 13px;
}
.toast.error { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast .tt { font-weight: 600; margin-bottom: 2px; }
.toast .tm { color: var(--txt-dim); }

/* Bars (mini chart) */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 10px; }
.bars .bar { flex: 1; background: linear-gradient(180deg, var(--accent-bright), var(--accent-deep)); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; opacity: .92; transition: opacity .15s; box-shadow: inset 0 1px 0 rgba(255,255,255,.3); }
.bars .bar:hover { opacity: 1; }
.bars .bar .lbl { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: 9px; color: var(--txt-faint); }

/* ---------------- DATA-VIZ PRIMITIVES ---------------- */
.metric-spark { margin-top: 14px; }
.bar-line { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; color: var(--txt-dim); margin-bottom: 7px; gap: 8px; }
.bar-line .bl-label { font-weight: 700; font-size: 10px; }
.bar-line .v { font-family: var(--font-mono); color: var(--txt); white-space: nowrap; }
.bar-track { height: 7px; border-radius: 6px; background: var(--track); overflow: hidden; box-shadow: inset 0 1px 2px rgba(18,24,44,0.10); }
.bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--brass)); transition: width .7s cubic-bezier(.2,.8,.2,1); box-shadow: inset 0 1px 0 rgba(255,255,255,.3); }

.split-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--track); box-shadow: inset 0 1px 2px rgba(18,24,44,0.10); }
.split-bar > span { display: block; height: 100%; transition: width .7s cubic-bezier(.2,.8,.2,1); }
.split-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--txt-dim); }
.split-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.split-legend .sw { width: 9px; height: 9px; border-radius: 3px; }
.split-legend .lv { font-family: var(--font-mono); color: var(--txt); font-weight: 600; }

.cell-split { min-width: 130px; }
.cell-split .split-bar { height: 6px; }
.cell-split .cs-cap { display: flex; justify-content: space-between; font-size: 10px; color: var(--txt-faint); margin-top: 4px; font-family: var(--font-mono); }
.cell-util { min-width: 110px; }
.cell-util .bar-track { height: 5px; }
.cell-util .cu-cap { font-size: 11px; color: var(--txt-dim); margin-top: 4px; font-family: var(--font-mono); }

.rank { display: flex; flex-direction: column; }
.rank-row { padding: 13px 22px; border-bottom: 1px solid var(--line-soft); }
.rank-row:last-child { border-bottom: 0; }
.rank-top { display: flex; align-items: center; gap: 11px; margin-bottom: 8px; }
.rank-idx { width: 24px; height: 24px; flex: 0 0 auto; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--panel-hi); color: var(--txt-dim); font-family: var(--font-mono); box-shadow: inset 0 1px 0 var(--glass-hi); }
.rank-row:first-child .rank-idx { background: linear-gradient(155deg, var(--accent-bright), var(--accent-deep)); color: #fff; box-shadow: inset 0 1px 1px rgba(255,255,255,.4); }
.rank-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { margin-left: auto; font-family: var(--font-mono); font-weight: 600; white-space: nowrap; }
.rank-bar { height: 6px; border-radius: 5px; background: var(--track); overflow: hidden; box-shadow: inset 0 1px 2px rgba(18,24,44,0.10); }
.rank-bar > span { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), var(--brass)); transition: width .7s cubic-bezier(.2,.8,.2,1); }

.gauge-row { display: flex; gap: 16px; flex-wrap: wrap; }
.gauge {
  display: flex; align-items: center; gap: 16px; flex: 1; min-width: 200px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%); backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-hi);
}
.gauge svg { transform: rotate(-90deg); flex: 0 0 auto; }
.gauge-track { stroke: var(--track); }
.gauge .gv { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.6px; }
.gauge .gl { font-size: 10.5px; color: var(--txt-dim); font-weight: 700; margin-top: 3px; }
.gauge .gsub { font-size: 12px; color: var(--txt-faint); margin-top: 4px; font-family: var(--font-mono); }

.area-wrap { position: relative; }
.area-chart { width: 100%; height: auto; display: block; overflow: visible; }
.area-chart .ac-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.area-chart .ac-dot { fill: var(--panel-hi); stroke: var(--accent); stroke-width: 2; }
.area-chart .ac-base { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.area-x { display: flex; justify-content: space-between; margin-top: 8px; font-size: 10px; color: var(--txt-faint); font-family: var(--font-mono); }

.loading { display: grid; place-items: center; padding: 56px; color: var(--txt-dim); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }

/* hamburger + drawer backdrop are hidden on desktop */
.nav-toggle { display: none; padding: 8px 10px; }
.nav-toggle .rp-ic { display: block; width: 18px; height: 18px; }
.nav-backdrop { display: none; }

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 860px) {
  /* single-column shell; sidebar becomes an off-canvas drawer */
  .shell { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-grid; place-items: center; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100%;
    width: 280px; max-width: 84vw; z-index: 60;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.2,.8,.2,1);
    box-shadow: var(--shadow);
  }
  .shell.nav-open .sidebar { transform: none; }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: var(--overlay);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none; transition: opacity .28s;
  }
  .shell.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 22px 18px 40px; }
  .topbar { padding: 0 16px; min-height: 64px; gap: 10px; }
  .topbar .page-title { font-size: 19px; }
  .page-head h2 { font-size: 24px; }
  .modal-overlay { padding: 14px; }
}

@media (max-width: 560px) {
  .content { padding: 18px 13px 36px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .user-chip { padding: 4px; }
  .user-chip > div:last-child { display: none; }   /* keep avatar only */
  .page-head h2 { font-size: 21px; }
  .kpi .k-value { font-size: 27px; }
  .dl { grid-template-columns: 104px 1fr; }
  table.grid thead th, table.grid tbody td { padding: 10px 12px; }
  .panel-pad { padding: 18px 16px; }
}

.help { color: var(--txt-faint); font-size: 12px; }
.row-actions { display: flex; gap: 6px; }
.muted { color: var(--txt-faint); }
.accent-txt { color: var(--accent); }
.right { text-align: right; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glint-sweep { 0% { left: -120%; } 60%, 100% { left: 130%; } }

/* ============================================================
   ICONOGRAPHY — skeuomorphic glossy chips with a sweeping glint
   ============================================================ */
.rp-ic { width: 1em; height: 1em; display: inline-block; vertical-align: -.16em; }
.nav-ico { display: inline-grid; place-items: center; width: 20px; height: 20px; }
.nav-ico .rp-ic { width: 19px; height: 19px; }
.nav-item.active .rp-ic { color: var(--accent); }
.toolbar .search .ico .rp-ic { width: 16px; height: 16px; }

/* glossy 3D tile — gradient body, top gloss, inner bevel, glint sweep,
   white glyph with a soft drop-shadow → tactile, skeuomorphic depth */
.icon-tile {
  position: relative; width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; flex: 0 0 auto; overflow: hidden;
  background: linear-gradient(155deg, var(--it-2, var(--accent-bright)), var(--it-1, var(--accent-deep)));
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.55),
    inset 0 -3px 6px rgba(0,0,0,.20),
    0 8px 16px -6px var(--it-shadow, var(--accent-glow));
}
.icon-tile::before {  /* top gloss highlight */
  content: ''; position: absolute; inset: 0 0 50% 0;
  background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,0));
  border-radius: 13px 13px 42% 42%;
}
.icon-tile::after {  /* diagonal glint */
  content: ''; position: absolute; top: -60%; left: -120%; width: 55%; height: 220%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  transform: rotate(20deg); pointer-events: none; transition: left .55s ease;
}
.icon-tile:hover::after { left: 130%; }
.icon-tile .rp-ic {
  position: relative; z-index: 1; width: 22px; height: 22px; color: #fff;
  filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.30));
}
/* tones — deep base (it-1) → light top (it-2) + matching glow */
.icon-tile.t-warm   { --it-1: #155d46; --it-2: #34c08e; --it-shadow: rgba(31,122,92,.55); }
.icon-tile.t-rose   { --it-1: #ad332c; --it-2: #f0766c; --it-shadow: rgba(216,69,61,.55); }
.icon-tile.t-amber  { --it-1: #8a5f17; --it-2: #e0aa48; --it-shadow: rgba(176,125,42,.55); }
.icon-tile.t-jewel  { --it-1: #1c6c89; --it-2: #4fc0df; --it-shadow: rgba(47,135,168,.55); }
.icon-tile.t-plum   { --it-1: #5a3f2a; --it-2: #b08a5e; --it-shadow: rgba(122,80,40,.50); }
.icon-tile.t-violet { --it-1: #543098; --it-2: #a884e6; --it-shadow: rgba(122,91,196,.55); }
.icon-tile.t-ok     { --it-1: #157a51; --it-2: #3fce98; --it-shadow: rgba(31,157,107,.55); }

.kpi .k-spark { opacity: 1; font-size: 0; top: 18px; right: 18px; }

/* theme toggle */
.theme-toggle { padding: 8px 10px; }
.theme-toggle .rp-ic { display: block; }
.theme-fab { position: fixed; top: 20px; right: 20px; z-index: 50; }

@media (prefers-reduced-motion: reduce) {
  .content > *, .login-card, .modal, .toast { animation: none !important; }
  .btn::after, .icon-tile::after { transition: none; display: none; }
}
