/* ---------- Base ---------- */
[hidden] { display: none !important; }
.app-card h2 { font-size: 15px; font-weight: 600; }
.avatar--0 { background: #e0ecff !important; color: #1e40af !important; }
.avatar--1 { background: #e8f7ee !important; color: #166534 !important; }
.avatar--2 { background: #f3e8ff !important; color: #6d28d9 !important; }
.avatar--3 { background: #fff3ee !important; color: #9a2b14 !important; }
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.has-overlay { overflow: hidden; }
h1, h2, h3, h4, p, ul, ol, blockquote, dl, dd, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.ico {
  width: 16px; height: 16px; flex: none; vertical-align: -3px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.ico--lg { width: 20px; height: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 20px; min-width: 0; }
.stack > * { min-width: 0; }

/* ---------- Brand ---------- */
.brand-mark {
  display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 7px;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 17px; letter-spacing: -0.01em; line-height: 1;
}
.brand-mark--sm { font-size: 15px; padding: 5px 9px; }
.brand-mark--inverse { background: #fff; color: var(--brand-ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap; background: transparent;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary:hover:not(:disabled) { background: #2b2b2e; }
.btn--secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn--secondary:hover:not(:disabled) { background: var(--hover); }
.btn--ghost { color: var(--ink-2); }
.btn--ghost:hover:not(:disabled) { background: var(--hover); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: #a91818; }
.btn--brand { background: var(--brand-action); color: #fff; }
.btn--brand:hover:not(:disabled) { background: var(--brand-action-hover); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn--lg { height: 44px; padding: 0 18px; font-size: 15px; border-radius: 10px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--muted);
}
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.link {
  display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none;
  color: var(--ink); font-weight: 500; cursor: pointer;
}
.link:hover { color: var(--brand-ink); }
.link--muted { color: var(--muted); font-weight: 400; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor;
  border-right-color: transparent; animation: spin 0.7s linear infinite;
}

/* ---------- Chips (levels, roles, statuses) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--tone-none-bg); color: var(--tone-none-fg);
}
.chip .ico { width: 12px; height: 12px; stroke-width: 2; vertical-align: 0; }
.chip--xs { height: 18px; padding: 0 6px; font-size: 11px; }
.chip--none { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip--basic { background: var(--tone-basic-bg); color: var(--tone-basic-fg); }
.chip--premium { background: var(--tone-premium-bg); color: var(--tone-premium-fg); }
.chip--vip { background: var(--tone-vip-bg); color: var(--tone-vip-fg); }
.chip--vvip { background: var(--tone-vvip-bg); color: var(--tone-vvip-fg); }
.chip--admin { background: var(--tone-admin-bg); color: var(--tone-admin-fg); }
.chip--eatalyst { background: var(--tone-eatalyst-bg); color: var(--tone-eatalyst-fg); }
.chip--senior { background: var(--tone-senior-bg); color: var(--tone-senior-fg); }
.chip--neutral { background: var(--hover); color: var(--ink-2); }
.chip--pending { background: var(--warning-bg); color: var(--warning); }
.chip--pending-outline { background: transparent; color: var(--warning); box-shadow: inset 0 0 0 1px var(--warning-line); }
.chip--approved { background: var(--success-bg); color: var(--success); }
.chip--rejected { background: var(--danger-bg); color: var(--danger); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.dash { color: var(--line-strong); }

/* ---------- App monograms and avatars ---------- */
.mono {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: 10px; font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
}
.mono--sm { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; }
.mono--xs { width: 18px; height: 18px; border-radius: 5px; font-size: 8.5px; vertical-align: -4px; }
.mono--ht { background: #ccfbf1; color: #0f766e; }
.mono--em { background: #ffedd5; color: #c2410c; }
.mono--ah { background: #ede9fe; color: #6d28d9; }
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; font-weight: 600; letter-spacing: 0.01em; }
.app-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 3px; border-radius: 999px;
  background: var(--hover); font-weight: 500; font-size: 13px; white-space: nowrap;
}

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field-label, .field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field-hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-size: 14px; transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px rgba(15, 15, 16, 0.08); }
.input[readonly] { background: var(--canvas); color: var(--muted); }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
.input-icon { position: relative; display: inline-flex; align-items: center; }
.input-icon > .ico { position: absolute; left: 11px; color: var(--subtle); pointer-events: none; }
.input-icon .input { padding-left: 34px; }
.checkbox { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.switch {
  position: relative; width: 36px; height: 20px; flex: none; padding: 0; border: 0; border-radius: 999px;
  background: var(--line-strong); transition: background 0.15s;
}
.switch span {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: transform 0.15s var(--ease);
}
.switch.is-on { background: var(--ink); }
.switch.is-on span { transform: translateX(16px); }
.switch:disabled { opacity: 0.45; cursor: not-allowed; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--hover); }
.segmented button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.segmented button.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; z-index: 30; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; padding: 16px 12px 12px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.sidebar-brand { padding: 4px 8px 12px; }
.sidebar-nav { display: grid; gap: 18px; }
.nav-group { display: grid; gap: 2px; }
.nav-group-label { padding: 0 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--subtle); }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px;
  border-radius: var(--radius); color: var(--ink-2); font-weight: 500;
}
.nav-item .ico { color: var(--subtle); }
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.is-active { background: var(--canvas); color: var(--ink); font-weight: 600; }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav-item.is-active .ico { color: var(--ink); }
.nav-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: auto; padding: 0 6px;
  border-radius: 999px; background: var(--brand-action); color: #fff; font-size: 11px; font-weight: 600;
}
.nav-dot { width: 8px; height: 8px; margin-left: auto; border-radius: 50%; background: #f59e0b; }
.sidebar-foot { position: relative; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
.user-card {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0;
  border-radius: var(--radius); background: transparent; text-align: left;
}
.user-card:hover { background: var(--hover); }
.user-card-text { flex: 1; min-width: 0; display: grid; gap: 3px; }
.user-card-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card-text .chip { justify-self: start; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 32px; border-bottom: 1px solid var(--line);
  background: rgba(246, 246, 247, 0.86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar-menu { display: none; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 13.5px; }
.crumb-current { color: var(--ink); font-weight: 500; }
.crumb-sep { color: var(--line-strong); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.searchbox {
  position: relative; display: flex; align-items: center; width: 280px; height: 34px; padding: 0 8px 0 32px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.searchbox > .ico { position: absolute; left: 10px; color: var(--subtle); }
.searchbox input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; font-size: 13.5px; }
kbd {
  padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--canvas);
  color: var(--muted); font-family: var(--font-sans); font-size: 11px;
}
.content { width: 100%; max-width: 1280px; padding: 28px 32px 112px; display: grid; gap: 20px; align-content: start; }

/* ---------- Page structure ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.page-header p { margin-top: 4px; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; font-weight: 600; }
.card-body { padding: 16px 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 15px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.banner { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid; border-radius: var(--radius-lg); font-size: 13.5px; }
.banner > .ico { margin-top: 1px; }
.banner--warning { background: var(--warning-bg); border-color: var(--warning-line); color: var(--warning-ink); }
.banner--info { background: var(--info-bg); border-color: var(--info-line); color: var(--info-ink); }
.banner--success { background: var(--success-bg); border-color: #bfe8cd; color: #14532d; }
.banner .link { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 16px 18px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { margin-top: 6px; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-sub { margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.attention-row { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--line); }
.attention-row:first-child { border-top: 0; }
.attention-icon { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 8px; background: var(--brand-soft); color: var(--brand); }
.attention-icon--ok { background: var(--success-bg); color: var(--success); }
.activity-row { display: flex; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); }
.activity-row:first-child { border-top: 0; }
.activity-text { flex: 1; min-width: 0; }
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.tile-text { flex: 1; min-width: 0; display: grid; gap: 4px; justify-items: start; }
.tile-text b { font-weight: 600; }
/* ---------- App cards (My apps) ---------- */
.app-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.app-card { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.app-card.is-focus { box-shadow: 0 0 0 2px var(--brand), var(--shadow-1); }
.app-card-head { display: flex; align-items: flex-start; gap: 12px; }
.app-card-head > div { flex: 1; min-width: 0; }
.app-card h3 { font-size: 15px; font-weight: 600; }
.app-card-desc { flex: 1; color: var(--ink-2); }
.app-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- Toolbars and tables ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.table-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table-toolbar .input-icon { flex: 1 1 260px; }
.table-toolbar .input-icon .input { width: 100%; }
.table-toolbar .select { width: auto; min-width: 140px; }
.result-count { margin-left: auto; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px; border: 1px solid var(--line-strong);
  border-radius: 999px; background: var(--surface); font-size: 12.5px;
}
.filter-chip .icon-btn { width: 20px; height: 20px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fafafb; text-align: left;
  font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table--interactive tbody tr { cursor: pointer; }
.table--interactive tbody tr:hover td { background: var(--row-hover); }
.table tr.is-selected td { background: var(--row-selected); }
.table tr.is-open td { background: #fff1eb; }
.table--compact th, .table--compact td { padding: 8px 12px; }
.col-check { width: 44px; padding-right: 0 !important; }
.cell-stack { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--line); }
.pager { display: flex; gap: 4px; }
.user-cell { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.user-cell-text { display: grid; min-width: 0; line-height: 1.3; }
.user-cell-text b { font-weight: 600; }
.user-cell-text span { color: var(--muted); font-size: 12.5px; }
.expand-row td { background: var(--canvas); }
.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.code {
  padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; overflow-x: auto;
}
.code-line {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: var(--radius);
  background: #111113; color: #e7e7ea; font-family: var(--font-mono); font-size: 12.5px;
}
.code-line code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; }
.code-line .icon-btn { color: #a1a1aa; }
.code-line .icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.check-list { display: grid; gap: 8px; }
.check-item { display: flex; align-items: center; gap: 10px; }
.check-ok { color: var(--success); }
.check-bad { color: var(--danger); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0; flex: none;
  border: 0; background: none; color: var(--muted); font-weight: 500;
}
.tab:hover, .tab.is-on { color: var(--ink); }
.tab.is-on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); }
.tab-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 6px;
  border-radius: 999px; background: var(--hover); color: var(--ink-2); font-size: 11.5px;
}
.tab.is-on .tab-count { background: var(--ink); color: #fff; }

/* ---------- Inbox rows ---------- */
.req-bulk { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: #fafafb; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.req-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 16px 20px; border-top: 1px solid var(--line); }
.req-row--select { grid-template-columns: auto auto minmax(0, 1fr) auto; }
.req-row:first-child { border-top: 0; }
.req-row .checkbox { margin-top: 10px; }
.req-main { display: grid; gap: 6px; min-width: 0; }
.req-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.req-title b { font-weight: 600; }
.req-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--ink-2); }
.req-note { padding: 8px 12px; border-left: 2px solid var(--line-strong); border-radius: 0 6px 6px 0; background: var(--canvas); color: var(--ink-2); font-size: 13.5px; }
.req-hint, .reason { display: flex; align-items: flex-start; gap: 6px; color: var(--muted); font-size: 12.5px; }
.req-side { display: grid; justify-items: end; gap: 10px; }
.req-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

/* ---------- Empty / forbidden ---------- */
.empty { display: grid; justify-items: center; gap: 8px; padding: 48px 24px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 4px; border-radius: 12px; background: var(--hover); color: var(--muted); }
.empty-icon--ok { background: var(--success-bg); color: var(--success); }
.empty h3 { font-size: 15px; font-weight: 600; }
.empty p { max-width: 380px; color: var(--muted); }
.forbidden { max-width: 520px; margin: 48px auto; padding: 32px; text-align: center; display: grid; justify-items: center; gap: 10px; }
.forbidden h1 { font-size: 20px; font-weight: 600; }
.forbidden p { color: var(--muted); }

/* ---------- Bulk bar ---------- */
.bulkbar {
  position: fixed; bottom: 24px; left: calc(50% + var(--sidebar-w) / 2); z-index: 40; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; box-shadow: var(--shadow-2); white-space: nowrap;
}
.bulkbar .btn--light { background: #fff; color: var(--ink); }
.bulkbar .btn--dark { color: #d4d4d8; }
.bulkbar .btn--dark:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* ---------- Overlays: scrim, drawer, dialog, menu ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(15, 15, 16, 0.32); animation: fade 0.15s ease; }
.scrim--dialog { z-index: 80; }
.scrim--nav { display: none; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(560px, 100%);
  display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-2); animation: slide-in 0.2s var(--ease);
}
.drawer-head { display: flex; align-items: flex-start; gap: 14px; padding: 20px 20px 12px 24px; }
.drawer-title { flex: 1; min-width: 0; display: grid; gap: 2px; }
.drawer-title h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.drawer-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 0 24px 16px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; padding: 4px 24px 24px; }
.drawer-section { display: grid; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.drawer-section:last-child { border-bottom: 0; }
.drawer-section-title { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--subtle); }
.drawer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface); }
.drawer-foot-actions { display: flex; gap: 8px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch-row b { font-weight: 600; }
.access-row { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.access-row.is-staged { border-color: #ffc9b8; background: #fffaf8; }
.access-row-head { display: flex; align-items: center; gap: 12px; }
.access-row-name { flex: 1; min-width: 0; display: grid; line-height: 1.35; }
.access-row-name b { font-weight: 600; }
.staged-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; }
.lock-note { display: flex; align-items: flex-start; gap: 6px; color: var(--muted); font-size: 12.5px; }
.pending-box { display: grid; gap: 10px; padding: 10px 12px; border: 1px solid var(--warning-line); border-radius: var(--radius); background: var(--warning-bg); color: var(--warning-ink); font-size: 13px; }
.pending-box-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pending-box-actions { display: flex; justify-content: flex-end; gap: 8px; }
.picker { position: relative; }
.picker-btn {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 156px; height: 34px;
  padding: 0 8px 0 6px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
}
.picker-btn:hover:not(:disabled) { border-color: var(--ink-2); }
.picker-btn:disabled { background: var(--canvas); color: var(--subtle); cursor: not-allowed; }
.picker-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 70; width: 360px; padding: 6px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-2);
}
.picker-group + .picker-group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.picker-group-label { padding: 6px 8px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--subtle); }
.picker-option {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 10px; width: 100%;
  padding: 8px; border: 0; border-radius: var(--radius); background: transparent; text-align: left;
}
.picker-option:hover:not([aria-disabled="true"]) { background: var(--hover); }
.picker-option[aria-disabled="true"] { cursor: not-allowed; }
.picker-option[aria-disabled="true"] .chip { opacity: 0.55; }
.picker-option-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.picker-option-desc { overflow: hidden; color: var(--muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.picker-option-meta { color: var(--muted); font-size: 12px; }
.picker-option-reason { grid-column: 1 / -1; padding-left: 2px; color: var(--muted); font-size: 12px; }
.hint { font-size: 12px; white-space: nowrap; }
.hint--apply { color: var(--success); }
.hint--request { color: var(--warning); }
.usage { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.usage-item { display: grid; gap: 4px; font-size: 12.5px; }
.usage-item-top { display: flex; justify-content: space-between; gap: 6px; color: var(--muted); }
.usage-item-top b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.meter { height: 6px; overflow: hidden; border-radius: 999px; background: var(--hover); }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--ink-2); }
.meter.is-warn span { background: #f59e0b; }
.meter.is-over span { background: var(--danger); }
.stacked { display: flex; height: 8px; overflow: hidden; border-radius: 999px; background: var(--hover); }
.stacked span { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dialog {
  position: fixed; top: 50%; left: 50%; z-index: 81; transform: translate(-50%, -50%);
  width: min(560px, calc(100% - 32px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-2); animation: pop 0.16s var(--ease);
}
.dialog--wide { width: min(720px, calc(100% - 32px)); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 24px 8px; }
.dialog-head h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.dialog-head p { margin-top: 4px; color: var(--muted); }
.dialog-body { display: grid; gap: 14px; padding: 8px 24px 16px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); }
.change-list { display: grid; gap: 8px; }
.change { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.change.is-elevated { border-color: var(--warning-line); background: #fffcf5; }
.change-scope { display: flex; align-items: center; gap: 8px; }
.change-diff { display: flex; align-items: center; gap: 6px; justify-self: end; }
.change-effect { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.change-effect.is-apply { color: var(--success); }
.change-effect.is-request { color: var(--warning); }
.change-warn { grid-column: 1 / -1; display: flex; gap: 6px; color: var(--warning-ink); font-size: 12.5px; }
.option-list { display: grid; gap: 6px; max-height: 240px; overflow-y: auto; }
.option-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); text-align: left;
}
.option-row:hover { background: var(--hover); }
.option-row.is-on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.menu {
  position: absolute; z-index: 70; display: grid; min-width: 210px; padding: 6px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-2);
}
.menu--up { bottom: calc(100% + 6px); left: 0; right: 0; }
.menu--down { top: calc(100% + 8px); right: 0; }
.menu button, .menu a {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-2); font-size: 14px; text-align: left;
}
.menu button:hover, .menu a:hover { background: var(--hover); color: var(--ink); }
.menu-sep { height: 1px; margin: 4px 0; background: var(--line); }
.menu-head { padding: 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: grid; }
.popover { position: absolute; top: calc(100% + 8px); right: 0; z-index: 70; width: 300px; padding: 14px; display: grid; gap: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-2); }
.relative { position: relative; }

/* ---------- Toasts and skeletons ---------- */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; width: min(380px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 10px 12px 14px; border-radius: 10px;
  background: var(--ink); color: #f4f4f5; box-shadow: var(--shadow-2); font-size: 13.5px; animation: toast-in 0.2s var(--ease);
}
.toast > .ico { margin-top: 2px; }
.toast--success > .ico { color: #4ade80; }
.toast--info > .ico { color: #93c5fd; }
.toast--error { background: #3b0d0d; }
.toast--error > .ico { color: #fca5a5; }
.toast-text { flex: 1; }
.toast .icon-btn { width: 24px; height: 24px; color: #a1a1aa; }
.toast .icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.skeleton { border-radius: 6px; background: linear-gradient(90deg, #eeeef1 25%, #f6f6f8 50%, #eeeef1 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }

/* ---------- Login ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; background: var(--surface); }
.auth-brand {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: 40px 48px; color: var(--ink); background: linear-gradient(150deg, #ff4d2e 0%, #ff6a3d 55%, #ff8b5c 100%);
}
.auth-brand h2 { max-width: 420px; font-size: 34px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; }
.auth-brand p { max-width: 400px; margin-top: 12px; color: var(--ink); font-size: 15px; }
.auth-apps { display: grid; gap: 10px; max-width: 360px; margin-top: 28px; }
.auth-apps li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.14); }
.auth-apps .mono { background: #fff; }
.auth-apps b { display: block; font-weight: 600; }
.auth-apps small { color: var(--ink); }
.auth-rings { position: absolute; right: -130px; bottom: -130px; width: 460px; height: 460px; opacity: 0.4; pointer-events: none; }
.auth-legal { position: relative; color: var(--ink); font-size: 12.5px; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: min(400px, 100%); display: grid; gap: 20px; }
.auth-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.auth-card .lede { margin-top: 6px; color: var(--muted); }
.auth-context { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); color: #9a2b14; font-size: 13.5px; }
.auth-form { display: grid; gap: 14px; }
.auth-form .input { height: 44px; border-radius: 10px; font-size: 15px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.password-field { position: relative; }
.password-field .input { padding-right: 44px; }
.password-field .icon-btn { position: absolute; top: 6px; right: 6px; }
.form-error { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border: 1px solid var(--danger-line); border-radius: 10px; background: var(--danger-bg); color: var(--danger); font-size: 13.5px; }
.field-status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.field-status.is-ok { color: var(--success); }
.field-status.is-bad { color: var(--danger); }
.auth-switch { color: var(--muted); text-align: center; }
.auth-switch .link { color: var(--brand-ink); }
.auth-foot { margin-top: 24px; color: var(--muted); font-size: 13px; text-align: center; }
.account-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.mail-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 65; width: 280px;
    transform: translateX(-100%); transition: transform 0.2s var(--ease); box-shadow: var(--shadow-2);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim--nav { display: block; z-index: 64; }
  .topbar { padding: 0 16px; }
  .topbar-menu { display: inline-grid; }
  .searchbox { width: 200px; }
  .content { padding: 20px 16px 112px; }
  .bulkbar { left: 50%; }
  .auth { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .auth-brand { padding: 18px 24px; }
  .auth-brand-copy, .auth-rings, .auth-legal { display: none; }
}
@media (max-width: 720px) {
  .app-grid, .tile-grid, .stats { grid-template-columns: minmax(0, 1fr); }
  .searchbox { display: none; }
  .req-row { grid-template-columns: auto minmax(0, 1fr); }
  .req-row--select { grid-template-columns: auto auto minmax(0, 1fr); }
  .req-side { grid-column: 1 / -1; justify-items: stretch; }
  .drawer { width: 100%; }
  .picker-menu { width: min(330px, calc(100vw - 40px)); }
  .page-header h1 { font-size: 20px; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .bulkbar { bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes pop { from { transform: translate(-50%, -48%); opacity: 0; } }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Production login accessibility and form feedback. */
.auth-brand > .brand-mark { align-self: flex-start; }
.auth-main > div { width: min(400px, 100%); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
.auth-loading { display: grid; gap: 16px; width: min(400px, 100%); }
.auth-loading .skeleton { height: 44px; }
.auth-message[hidden], .form-error[hidden] { display: none; }
.account-row, .auth-context { overflow-wrap: anywhere; }
.auth-form .password-toggle { width: 36px; right: 4px; }
.auth-status { min-height: 19px; }
.auth-form button[aria-busy="true"] { cursor: progress; }
.auth-brand-copy { position: relative; z-index: 1; }

/* Native dialogs keep the prototype layout and browser focus trapping. */
dialog.dialog { margin: 0; padding: 0; border: 1px solid var(--line); }
dialog.dialog:not([open]) { display: none; }
dialog.dialog::backdrop { background: rgba(15, 15, 16, 0.32); }
.avatar { width: 32px; height: 32px; background: var(--brand-soft); color: #9a2b14; font-size: 12px; }
dialog.drawer { margin: 0; padding: 0; border: 0; left: auto; transform: none; max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh; }
dialog.drawer:not([open]) { display: none; }
dialog.drawer::backdrop { background: rgba(15, 15, 16, 0.32); }

/* Administration pages use the same quiet component system as the workspace. */
.content, [data-page], .card { min-width: 0; }
.table-wrap {
  position: relative;
  max-width: 100%;
}
.table th { position: sticky; top: 0; }
.user-link { border: 0; padding: 0; background: none; color: inherit; text-align: left; }
.user-link:hover { color: var(--brand-ink); }
.selection-notice { padding: 10px 16px; background: var(--brand-soft); }
.user-list-apps { display: flex; flex-wrap: wrap; gap: 8px; }
.drawer-user { display: flex; align-items: center; gap: 12px; }
.drawer-user > div { min-width: 0; }
.drawer .dialog-body { flex: 1; min-height: 0; }
.drawer [data-user-content] { min-height: 100%; display: flex; flex-direction: column; }
.drawer .drawer-foot { position: sticky; bottom: -16px; margin-top: auto; z-index: 2; }
.drawer .dialog-foot { flex-shrink: 0; }
.drawer-meta, .drawer-user, .user-cell-text { overflow-wrap: anywhere; }
.picker-menu { max-height: min(440px, 60vh); overflow-y: auto; }
.picker-option.is-active { background: var(--hover); outline: 2px solid var(--brand); outline-offset: -2px; }
.picker-hint { grid-column: 1 / -1; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.picker-option[aria-disabled="true"] { color: var(--muted); }
.usage-item progress { width: 100%; height: 6px; accent-color: var(--ink); }
.usage-item.is-warn progress { accent-color: #92400e; }
.usage-item.is-over progress { accent-color: var(--danger); }
.inbox-row { display: flex; gap: 16px; padding: 20px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.inbox-row:last-child { border-bottom: 0; }
.inbox-content { flex: 1; min-width: 0; display: grid; gap: 8px; overflow-wrap: anywhere; }
.inbox-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.role-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stacked .segment--basic { background: #166534; }
.stacked .segment--premium { background: #6d28d9; }
.stacked .segment--vip { background: #92400e; }
.stacked .segment--vvip { background: #1f1a12; }
.stacked .segment--admin { background: #1d4ed8; }
.stacked .segment--none, .stacked .segment--neutral { background: #d4d4d8; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend .segment--basic { background: #166534; }
.legend .segment--premium { background: #6d28d9; }
.legend .segment--vip { background: #92400e; }
.legend .segment--vvip { background: #1f1a12; }
.legend .segment--admin { background: #1d4ed8; }
.mono--premium { background: #f3e8ff; color: #6d28d9; }
.audit-event { text-align: left; white-space: normal; }
.code { max-width: 100%; overflow-wrap: anywhere; }
.bulkbar { max-width: calc(100vw - 32px); flex-wrap: wrap; white-space: normal; }
.lock-note, .reason, .change-warn, .change-effect { overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .role-stats { grid-template-columns: minmax(0, 1fr); }
  .inbox-row { flex-wrap: wrap; padding: 16px; gap: 12px; }
  .inbox-actions { width: 100%; justify-content: flex-start; }
  .access-row-head { flex-wrap: wrap; }
  .access-row-head .picker { width: 100%; }
  .access-row-head > [data-level-picker] { width: 100%; flex-basis: 100%; }
  .picker-btn { width: 100%; }
  .drawer-foot { flex-wrap: wrap; padding: 12px 16px; }
  .drawer-foot-actions { margin-left: auto; }
  .dialog-body, .dialog-head { padding-left: 16px; padding-right: 16px; }
  .table-toolbar .input-icon, .table-toolbar .select { min-width: 0; width: 100%; flex-basis: 100%; }
  .change { grid-template-columns: minmax(0, 1fr); }
  .change-diff { justify-self: start; }
}

/* Keyboard focus and touch-sized hit areas, without enlarging decorative chips. */
.btn, .btn--sm, .picker-btn, .segmented button, .nav-item, .menu button, .menu a,
.input, .select, .tabs .tab { min-height: var(--touch-target); height: auto; }
.btn { padding-top: 8px; padding-bottom: 8px; }
.btn--lg { min-height: 44px; }
.input, .select { height: var(--touch-target); }
.icon-btn, .filter-chip .icon-btn, .toast .icon-btn { min-width: var(--touch-target); min-height: var(--touch-target); }
.auth-form .password-toggle { width: var(--touch-target); right: 2px; top: 2px; }
.password-field .input { padding-right: 48px; }
.filter-chip { min-height: var(--touch-target); height: auto; }
.filter-chips { align-items: center; }
.user-link, button.link, a.link { min-height: var(--touch-target); }
a.brand-mark { min-height: var(--touch-target); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: 2px solid var(--brand-ink); outline-offset: 2px; box-shadow: none;
}
.searchbox { min-height: var(--touch-target); }
.searchbox:focus-within { outline: 2px solid var(--brand-ink); outline-offset: 2px; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.switch { width: 44px; height: var(--touch-target); background: transparent; }
.switch::before { content: ""; position: absolute; left: 4px; top: 10px; width: 36px; height: 20px; border-radius: 999px; background: var(--line-strong); }
.switch span { left: 6px; top: 12px; }
.switch.is-on { background: transparent; }
.switch.is-on::before { background: var(--ink); }
.checkbox { appearance: none; position: relative; width: var(--touch-target); height: var(--touch-target); flex: none; background: transparent; }
.checkbox::before { content: ""; position: absolute; inset: 12px; border: 1px solid var(--muted); border-radius: 3px; background: var(--surface); }
.checkbox:checked::before, .checkbox:indeterminate::before { background: var(--ink); border-color: var(--ink); }
.checkbox:checked::after { content: ""; position: absolute; left: 17px; top: 13px; width: 6px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.checkbox:indeterminate::after { content: ""; position: absolute; left: 16px; top: 19px; width: 8px; height: 2px; background: #fff; }
.checkbox:disabled { opacity: 0.45; cursor: not-allowed; }
.req-row .checkbox { margin-top: -4px; }
.col-check { width: 60px; padding: 4px 8px !important; }
dialog > .toast-stack { position: relative; inset: auto; width: auto; margin: 8px 16px 16px; max-height: min(30vh, 240px); overflow-y: auto; flex: none; }
.dialog-head, .dialog-foot { flex-shrink: 0; }
.dialog-body { min-height: 0; }
.dialog-head > div, .page-header > div { min-width: 0; overflow-wrap: anywhere; }
.toast-text { min-width: 0; overflow-wrap: anywhere; }
.app-card-foot { flex-wrap: wrap; }
.skeleton-title { height: 32px; width: min(240px, 100%); }
.skeleton-icon { height: 40px; width: 50px; }
.skeleton-line { height: 20px; }
.skeleton-block { height: 80px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (forced-colors: active) {
  .checkbox::before, .switch::before { border: 1px solid ButtonText; }
  .checkbox:checked::before, .checkbox:indeterminate::before, .switch.is-on::before { background: Highlight; }
  .checkbox:checked::after { border-color: HighlightText; }
  .checkbox:indeterminate::after, .switch span { background: HighlightText; }
}
