/* ==========================================================================
   Tisoro GMB — admin panel
   Glassmorphic surfaces over an ambient gradient. Dark by default, light on
   toggle; every colour is a token so the two themes stay in step.
   ========================================================================== */

:root {
  --bg-base:        #0a0e1a;
  --bg-tint-1:      #1a1040;
  --bg-tint-2:      #05202e;

  /* The tint that reads as "glass", laid over --glass-base so text has something
     solid behind it. Pure transparency looked elegant and was unreadable. */
  --glass-tint:     rgba(255, 255, 255, 0.07);
  --glass-base:     rgba(15, 21, 38, 0.72);
  --glass-bg:       rgba(255, 255, 255, 0.07);
  --glass-bg-hover: rgba(255, 255, 255, 0.13);
  --glass-border:   rgba(255, 255, 255, 0.17);
  --glass-shadow:   0 8px 32px rgba(0, 0, 0, 0.45);
  --surface-solid:  rgba(17, 23, 42, 0.94);
  --input-bg:       rgba(255, 255, 255, 0.07);

  --text:           #f5f7fc;
  --text-dim:       #c5cde1;
  --text-faint:     #94a0bd;

  --accent:         #5eead4;
  --accent-2:       #818cf8;
  --accent-ink:     #04201c;

  --ok:             #34d399;
  --warn:           #fbbf24;
  --err:            #fb7185;
  --info:           #60a5fa;

  --radius:         18px;
  --radius-sm:      11px;
  --blur:           blur(22px) saturate(160%);

  --sidebar-w:      252px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  --bg-base:        #eef2fb;
  --bg-tint-1:      #d8e4ff;
  --bg-tint-2:      #d6f5ee;

  --glass-tint:     rgba(255, 255, 255, 0.55);
  --glass-base:     rgba(255, 255, 255, 0.72);
  --glass-bg:       rgba(255, 255, 255, 0.70);
  --glass-bg-hover: rgba(255, 255, 255, 0.92);
  --glass-border:   rgba(14, 22, 48, 0.14);
  --glass-shadow:   0 8px 32px rgba(23, 34, 74, 0.13);
  --surface-solid:  rgba(255, 255, 255, 0.97);
  --input-bg:       rgba(255, 255, 255, 0.85);

  --text:           #0f1628;
  --text-dim:       #414c69;
  --text-faint:     #6b7794;

  --accent:         #0d9488;
  --accent-2:       #4f46e5;
  --accent-ink:     #ffffff;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

img { max-width: 100%; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- ambience */

.orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; }

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.4;
  animation: drift 26s ease-in-out infinite;
}
.orb-1 { width: 46vmax; height: 46vmax; top: -14vmax; left: -10vmax;
         background: var(--bg-tint-1); }
.orb-2 { width: 40vmax; height: 40vmax; bottom: -14vmax; right: -8vmax;
         background: var(--bg-tint-2); animation-delay: -9s; }
.orb-3 { width: 30vmax; height: 30vmax; top: 34%; left: 48%;
         background: var(--accent-2); opacity: 0.14; animation-delay: -17s; }

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  33%      { transform: translate3d(4vmax, -3vmax, 0) scale(1.08); }
  66%      { transform: translate3d(-3vmax, 4vmax, 0) scale(0.95); }
}

@media (prefers-reduced-motion: reduce) {
  .orb { animation: none; }
}

/* ------------------------------------------------------------------ glass */

.glass {
  background: linear-gradient(180deg, var(--glass-tint), transparent), var(--glass-base);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius);
}

/* ------------------------------------------------------------------ login */

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 30px 26px;
  display: grid;
  gap: 16px;
  animation: rise 0.5s cubic-bezier(.2,.8,.2,1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 4px; }
.login-brand h1 { margin: 0; font-size: 21px; letter-spacing: -0.02em; }
.login-brand p  { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); }

.brand-mark {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex: none;
  border-radius: 13px;
  font-size: 21px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

.login-foot {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.45;
}

/* ------------------------------------------------------------------ forms */

.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }

.input,
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 13px;
  font: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
/* Chrome paints autofilled fields with its own near-white background, which
   wrecks a dark form. An inset shadow the size of the field is the only way to
   override it; -webkit-text-fill-color fixes the text it also recolours. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px color-mix(in srgb, var(--surface-solid) 92%, transparent) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-out;
}

.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.input::placeholder { color: var(--text-faint); }

select.input, .field select { cursor: pointer; }
:root[data-theme="dark"] select option { background: #141a2c; color: var(--text); }

.input-affix { position: relative; display: flex; }
.input-affix input { padding-right: 42px; }
.affix-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer;
  font-size: 15px; padding: 6px 8px; color: var(--text-dim); border-radius: 8px;
}
.affix-btn:hover { background: var(--glass-bg-hover); }

.check { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-dim); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex: none; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 17px;
  font: inherit; font-weight: 600;
  color: var(--text);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s, background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--glass-bg-hover); }
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 26%, transparent);
}
.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--glass-bg-hover); }

.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--err) 14%, transparent); }

.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }

.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  font-size: 15px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--glass-bg-hover); color: var(--text); }

/* ---------------------------------------------------------------- shell */

#app { display: flex; min-height: 100dvh; }

.sidebar {
  position: fixed;
  top: 12px; left: 12px; bottom: 12px;
  width: var(--sidebar-w);
  padding: 18px 14px;
  display: flex; flex-direction: column; gap: 18px;
  z-index: 40;
  transition: transform .26s cubic-bezier(.3,.8,.3,1);
}

.side-brand { display: flex; align-items: center; gap: 11px; padding: 0 4px; }
.side-brand strong { display: block; font-size: 14.5px; letter-spacing: -.01em; }
.side-close { display: none; margin-left: auto; }

.nav { display: grid; gap: 3px; flex: 1; align-content: start; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 10px 12px;
  font: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: 0; border-radius: var(--radius-sm);
  cursor: pointer; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item i { font-style: normal; font-size: 15px; width: 20px; text-align: center; opacity: .85; }
.nav-item:hover { background: var(--glass-bg-hover); color: var(--text); }
.nav-item.active {
  color: var(--text);
  background: linear-gradient(100deg,
    color-mix(in srgb, var(--accent) 22%, transparent),
    color-mix(in srgb, var(--accent-2) 16%, transparent));
  box-shadow: inset 0 0 0 1px var(--glass-border);
}

.side-foot { display: grid; gap: 10px; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--glass-border);
}
:root[data-theme="light"] .user-chip { background: rgba(255,255,255,.55); }

.avatar {
  display: grid; place-items: center;
  width: 33px; height: 33px; flex: none;
  border-radius: 10px;
  font-weight: 700; font-size: 13px;
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.user-meta { min-width: 0; }
.user-meta strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: 11px; color: var(--text-faint); }

.side-actions { display: flex; gap: 7px; }
.side-actions .btn { flex: 1; }

.content {
  flex: 1;
  min-width: 0;
  margin-left: calc(var(--sidebar-w) + 24px);
  padding: 12px 16px 28px 0;
  display: flex; flex-direction: column; gap: 14px;
}

.topbar {
  position: sticky;
  top: calc(12px + env(safe-area-inset-top, 0px));
  z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
}
.menu-btn { display: none; }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.topbar-title p  { margin: 1px 0 0; font-size: 12px; color: var(--text-dim);
                   overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 7px; }

.scrim, .drawer-scrim, .modal-scrim {
  position: fixed; inset: 0;
  background: rgba(3, 6, 14, .66);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .22s;
  z-index: 35;
}
.scrim.show { opacity: 1; pointer-events: auto; }

/* ----------------------------------------------------------------- views */

.views { display: block; }
.view { display: none; flex-direction: column; gap: 14px; }
.view.active { display: flex; animation: fade .3s ease; }

@keyframes fade {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}

.card { padding: 18px; }
.card-head { margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.card-head small { color: var(--text-dim); font-size: 12px; }
.card-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.card-foot .alert { margin: 0; flex: 1; min-width: 200px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }

/* ------------------------------------------------------------- stat tiles */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; }

.stat {
  padding: 16px 17px;
  border-radius: var(--radius);
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  position: relative;
  overflow: hidden;
  transition: transform .18s, background .18s;
}
.stat:hover { transform: translateY(-2px); background: var(--glass-bg-hover); }
.stat::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(var(--accent), var(--accent-2));
  opacity: .8;
}
.stat-label { font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
              text-transform: uppercase; color: var(--text-faint); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.15; margin-top: 4px;
              letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-note  { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }
.stat.tone-ok::after   { background: var(--ok); }
.stat.tone-warn::after { background: var(--warn); }
.stat.tone-err::after  { background: var(--err); }
/* Switched off rather than broken: present on the grid, but not asking to be looked at. */
.stat.tone-muted::after { background: var(--text-faint); opacity: .5; }
.stat.tone-muted .stat-value { color: var(--text-faint); }

/* ----------------------------------------------------------------- bars */

.bars { display: grid; gap: 11px; }
.bar-row { display: grid; gap: 5px; }
.bar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.bar-top span:first-child { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-top span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-track { height: 7px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; }
:root[data-theme="light"] .bar-track { background: rgba(20,28,56,.09); }
.bar-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .5s cubic-bezier(.3,.9,.3,1);
}

/* ----------------------------------------------------------------- chart */

.chart { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 8px; }
.chart-bar { flex: 1; min-width: 2px; border-radius: 4px 4px 2px 2px;
             background: linear-gradient(180deg, var(--accent), var(--accent-2));
             opacity: .82; transition: opacity .15s, transform .15s; position: relative; }
.chart-bar:hover { opacity: 1; transform: scaleY(1.03); }
.chart-bar.zero { background: rgba(255,255,255,.08); }
:root[data-theme="light"] .chart-bar.zero { background: rgba(20,28,56,.08); }

/* ---------------------------------------------------------------- tables */

.toolbar { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 14px; align-items: center; }
.toolbar .input { flex: 1 1 170px; min-width: 0; max-width: 300px; }

.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 620px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 8px 11px; border-bottom: 1px solid var(--glass-border); white-space: nowrap;
}
.table td { padding: 11px; border-bottom: 1px solid color-mix(in srgb, var(--glass-border) 55%, transparent); vertical-align: middle; }
.table tbody tr { transition: background .13s; }
.table tbody tr:hover { background: var(--glass-bg-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { font-variant-numeric: tabular-nums; }
.table .muted { color: var(--text-faint); }
.table .row-deleted { opacity: .48; }
.table .actions { text-align: right; white-space: nowrap; }

.empty { padding: 34px 16px; text-align: center; color: var(--text-faint); font-size: 13px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px;
         margin-top: 14px; font-size: 12.5px; color: var(--text-dim); flex-wrap: wrap; }
.pager-btns { display: flex; gap: 7px; }

/* ----------------------------------------------------------------- pills */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  border-radius: 99px;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--glass-border);
  white-space: nowrap;
}
:root[data-theme="light"] .pill { background: rgba(20,28,56,.06); }
.pill-ok    { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 38%, transparent);
              background: color-mix(in srgb, var(--ok) 13%, transparent); }
.pill-warn  { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 38%, transparent);
              background: color-mix(in srgb, var(--warn) 13%, transparent); }
.pill-err   { color: var(--err);  border-color: color-mix(in srgb, var(--err) 38%, transparent);
              background: color-mix(in srgb, var(--err) 13%, transparent); }
.pill-info  { color: var(--info); border-color: color-mix(in srgb, var(--info) 38%, transparent);
              background: color-mix(in srgb, var(--info) 13%, transparent); }
.pill-muted { color: var(--text-faint); }

/* ---------------------------------------------------------------- alerts */

.alert { padding: 10px 13px; border-radius: var(--radius-sm); font-size: 12.5px; border: 1px solid; }
.alert-error   { color: var(--err);  background: color-mix(in srgb, var(--err) 12%, transparent);
                 border-color: color-mix(in srgb, var(--err) 34%, transparent); }
.alert-ok      { color: var(--ok);   background: color-mix(in srgb, var(--ok) 12%, transparent);
                 border-color: color-mix(in srgb, var(--ok) 34%, transparent); }
.alert-info    { color: var(--info); background: color-mix(in srgb, var(--info) 12%, transparent);
                 border-color: color-mix(in srgb, var(--info) 34%, transparent); }

/* --------------------------------------------------------------- settings */

.settings-form { display: grid; gap: 15px; }
.setting-row {
  display: grid; grid-template-columns: 1fr minmax(180px, 260px); gap: 12px 18px;
  align-items: center;
  padding: 14px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.035);
  border: 1px solid var(--glass-border);
}
:root[data-theme="light"] .setting-row { background: rgba(255,255,255,.5); }
.setting-info strong { display: block; font-size: 13.5px; font-family: var(--mono); }
.setting-info small  { color: var(--text-dim); font-size: 12px; display: block; margin-top: 3px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 46px; height: 26px; flex: none; border-radius: 99px;
  background: rgba(255,255,255,.12); border: 1px solid var(--glass-border);
  transition: background .2s; position: relative;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-dim); transition: transform .2s, background .2s;
}
.switch input:checked + .switch-track { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.switch input:checked + .switch-track::after { transform: translateX(20px); background: #fff; }
.switch-label { font-size: 12.5px; color: var(--text-dim); }

.google-box { display: grid; gap: 12px; }
.kv { display: flex; justify-content: space-between; gap: 14px; font-size: 13px;
      padding: 8px 0; border-bottom: 1px solid color-mix(in srgb, var(--glass-border) 55%, transparent); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--text-dim); }
.kv span:last-child { font-weight: 600; text-align: right; word-break: break-word; }

/* ------------------------------------------------------------------ tabs */

.tabs { display: flex; gap: 4px; margin-bottom: 15px; flex-wrap: wrap;
        border-bottom: 1px solid var(--glass-border); padding-bottom: 10px; }
.tab {
  padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-dim); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
  transition: background .15s, color .15s;
}
.tab:hover { background: var(--glass-bg-hover); color: var(--text); }
.tab.active { color: var(--text); background: var(--glass-bg-hover); border-color: var(--glass-border); }

/* ----------------------------------------------------------------- media */

.upload-box {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; align-items: end;
  padding: 15px; margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.035);
  border: 1px dashed var(--glass-border);
}
:root[data-theme="light"] .upload-box { background: rgba(255,255,255,.5); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }
.media-tile {
  border-radius: var(--radius-sm); overflow: hidden;
  background: rgba(255,255,255,.04); border: 1px solid var(--glass-border);
}
.media-tile img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.media-tile .media-meta { padding: 9px 11px; font-size: 11.5px; color: var(--text-dim); }
.media-placeholder { display: grid; place-items: center; aspect-ratio: 4/3; font-size: 30px; opacity: .45; }

/* ---------------------------------------------------------- drawer/modal */

.drawer-wrap, .modal-wrap { position: fixed; inset: 0; z-index: 60; }

/* Layer order inside the wrap: scrim behind, panel in front. Without an
   explicit z-index the panel (auto) loses to the scrim's inherited 35. */
.drawer-scrim, .modal-scrim { opacity: 1; pointer-events: auto; z-index: 0; }
.drawer, .modal { z-index: 1; }

.drawer {
  background: linear-gradient(180deg, var(--glass-tint), transparent), var(--surface-solid);
  position: absolute; top: 12px; right: 12px; bottom: 12px;
  width: min(560px, calc(100vw - 24px));
  display: flex; flex-direction: column;
  animation: slideIn .28s cubic-bezier(.25,.9,.3,1);
  overflow: hidden;
}
@keyframes slideIn { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }

.drawer-head, .modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 17px 19px; border-bottom: 1px solid var(--glass-border); flex: none;
}
.drawer-head h3, .modal-head h3 { margin: 0; font-size: 15.5px; }
.drawer-body { padding: 19px; overflow-y: auto; flex: 1; display: grid; gap: 18px; align-content: start; }

.modal {
  background: linear-gradient(180deg, var(--glass-tint), transparent), var(--surface-solid);
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  display: flex; flex-direction: column;
  animation: rise .26s cubic-bezier(.25,.9,.3,1);
}
.modal-body { padding: 19px; overflow-y: auto; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 15px 19px;
              border-top: 1px solid var(--glass-border); flex-wrap: wrap; }

.detail-block h4 { margin: 0 0 9px; font-size: 12px; text-transform: uppercase;
                   letter-spacing: .05em; color: var(--text-faint); }
.detail-block .table { min-width: 0; }

pre.code {
  margin: 0; padding: 12px; max-height: 280px; overflow: auto;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
  background: rgba(0,0,0,.25); border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm); white-space: pre-wrap; word-break: break-word;
}
:root[data-theme="light"] pre.code { background: rgba(20,28,56,.05); }

/* ---------------------------------------------------------------- toasts */

.toasts { position: fixed; z-index: 90; right: 16px; display: grid; gap: 9px;
          bottom: calc(16px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 32px); }

.toast {
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 250px; max-width: 380px;
  padding: 12px 15px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--glass-tint), transparent), var(--surface-solid);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  animation: toastIn .28s cubic-bezier(.25,.9,.3,1);
}
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.out { animation: toastOut .22s forwards; }
@keyframes toastOut { to { transform: translateY(8px); opacity: 0; } }
.toast-ok  { border-left: 3px solid var(--ok); }
.toast-err { border-left: 3px solid var(--err); }
.toast-info{ border-left: 3px solid var(--info); }

/* ---------------------------------------------------------------- utility */

.spinner {
  width: 15px; height: 15px; flex: none;
  border: 2px solid color-mix(in srgb, var(--text) 25%, transparent);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Shown only while the session is being resolved. Deliberately plain — it is on screen for a
   few hundred milliseconds and should read as "loading", not as a screen of its own. */
.boot-mark { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.boot-spinner { width: 22px; height: 22px; border-width: 2.5px; opacity: .65; }

.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1024px) {
  :root { --sidebar-w: 232px; }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(calc(-100% - 16px));
    top: 0; left: 0; bottom: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
  }
  .sidebar.open { transform: none; }
  .side-close { display: grid; }

  .content { margin-left: 0; padding: 12px 14px 26px; }
  .topbar { top: env(safe-area-inset-top, 0px); }
  .menu-btn { display: grid; }

  .table-wrap { margin: 0 -18px; padding: 0 18px; }
  .setting-row { grid-template-columns: 1fr; }
  .card-foot { justify-content: stretch; }
  .card-foot .btn { flex: 1; }
}

@media (max-width: 560px) {
  body { font-size: 13.5px; }
  .card { padding: 15px; }
  .table-wrap { margin: 0 -15px; padding: 0 15px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat-value { font-size: 24px; }
  .topbar { padding: 10px 13px; }
  .topbar-title h2 { font-size: 15.5px; }
  .topbar-title p { display: none; }
  .drawer { top: 0; right: 0; bottom: 0; width: 100vw; border-radius: 0; }
  .toasts { left: 14px; right: 14px; }
  .toast { max-width: none; }
  .toolbar .input { max-width: none; flex-basis: 100%; }
}


/* ------------------------------------------------------------------ icons */

/* The sprite itself must never take up space or be read out. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
}
.icon-sm { width: 15px; height: 15px; stroke-width: 1.9; vertical-align: -2px; }
.icon-lg { width: 23px; height: 23px; stroke-width: 1.6; }

.brand-mark .icon { color: var(--accent-ink); }
.nav-item .icon { opacity: .9; }
.nav-item.active .icon { opacity: 1; color: var(--accent); }
.side-brand-text { min-width: 0; flex: 1; }

/* Search fields carry their glyph inside the box rather than beside it. */
.search-wrap { position: relative; flex: 1 1 200px; min-width: 0; max-width: 300px; display: flex; }
.search-wrap .input { padding-left: 36px; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); pointer-events: none;
}

.toast .icon { margin-top: 1px; }
.toast-ok  .icon { color: var(--ok); }
.toast-err .icon { color: var(--err); }
.toast-info .icon { color: var(--info); }

.media-placeholder .icon { width: 34px; height: 34px; stroke-width: 1.4; }

.alert .icon { vertical-align: -3px; margin-right: 4px; }
.pager-btns .btn { gap: 4px; }

/* -------------------------------------------------- password field affixes */

/* Two buttons now sit inside the box (reveal + generate), so they need a row
   of their own rather than each being pinned to the right edge. */
.affix-actions {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: flex; gap: 1px;
}
.input-affix:has(.affix-actions) input { padding-right: 74px; }

.affix-actions .affix-btn { position: static; transform: none; }
.affix-btn.copied { color: var(--ok); }
