/* Wisherly Admin — light, dense suite shell; brand pink for actions and the current place only */
:root {
  --bg: #F4F5F7; --surface: #FFFFFF; --surface-2: #F9FAFB; --surface-3: #F2F4F7; --line: #E2E5EA; --line-2: #EDEFF2; --line-3: #D3D8DF;
  --ink: #0F1419; --ink-2: #39414A; --muted: #67707C; --faint: #98A0AB;
  --brand: #C41D56; --brand-hover: #A8184B; --brand-soft: #FCEBF1; --brand-softer: #FEF6F9; --focus: #D4225F;
  --ok: #137451; --ok-bg: #E6F4EC; --warn: #8A5A00; --warn-bg: #FFF5DC; --danger: #B42318; --danger-bg: #FDEDEB; --info: #1F5AA6; --info-bg: #EAF1FB;
  --r: 6px; --r-card: 10px; --nav-w: 236px; --nav-w-c: 60px; --top-h: 54px;
  --shadow: 0 1px 2px rgba(15,20,25,.04);
  --shadow-pop: 0 2px 4px rgba(15,20,25,.04), 0 12px 32px rgba(15,20,25,.14);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
a { color: var(--brand); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
small { font-size: 12px; }
.ico { display: inline-flex; width: 16px; height: 16px; flex: none; align-items: center; justify-content: center; }
.ico svg { width: 16px; height: 16px; display: block; }
kbd { font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: var(--surface); }

/* ── Gate ── */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent 70%), var(--bg); }
.gate-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 36px 32px; max-width: 400px; width: 100%; text-align: center; box-shadow: var(--shadow-pop); }
.gate-card h1 { font-size: 22px; margin: 14px 0 6px; }
.gate-card p { color: var(--muted); margin: 0 0 20px; }
.gate-msg { margin: 16px 0 0 !important; font-size: 13px; min-height: 1em; }
.gate-msg.err { color: var(--danger); }

/* ── Shell ── */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); grid-template-rows: var(--top-h) 1fr; min-height: 100vh; }
body.side-collapsed .shell { grid-template-columns: var(--nav-w-c) minmax(0, 1fr); }

/* top bar / app switcher */
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; padding: 0 12px 0 14px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; height: var(--top-h); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); flex: none; padding: 4px 6px 4px 2px; border-radius: var(--r); }
.brand img { border-radius: 6px; }
.brand-word { font-weight: 800; font-size: 16px; letter-spacing: -.02em; }
.brand-tag { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.pop-wrap { position: relative; flex: none; }
.launcher-btn { margin-left: 4px; }
.apptabs { display: flex; align-items: stretch; align-self: stretch; gap: 2px; flex: 1 1 auto; min-width: 0; overflow: hidden; margin-left: 6px; }
.apptab { display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 13.5px; white-space: nowrap; position: relative; border-radius: 0; }
.apptab .ico { color: var(--muted); }
.apptab:hover { color: var(--ink); background: var(--surface-2); }
.apptab:hover .ico { color: var(--ink-2); }
.apptab.active { color: var(--brand); }
.apptab.active .ico { color: var(--brand); }
.apptab.active::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--brand); border-radius: 2px 2px 0 0; }
.apptab:focus-visible { outline-offset: -2px; }
body.tabs-collapsed .apptabs { visibility: hidden; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 4px; flex: none; }
.gsearch { position: relative; display: flex; align-items: center; width: 260px; margin-right: 4px; }
.gsearch > .ico { position: absolute; left: 10px; color: var(--faint); pointer-events: none; }
.gsearch kbd { position: absolute; right: 8px; pointer-events: none; }
.gsearch-input { font: inherit; font-size: 13px; width: 100%; height: 34px; padding: 0 30px 0 32px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); color: var(--ink); -webkit-appearance: none; appearance: none; }
.gsearch-input::-webkit-search-cancel-button { display: none; }
.gsearch-input:hover { border-color: var(--line-3); }
.gsearch-input:focus { outline: none; background: var(--surface); border-color: var(--focus); box-shadow: 0 0 0 3px rgba(212,34,95,.14); }
.gsearch-input:focus ~ kbd { display: none; }
.icon-btn.search-btn { display: none; }
.avatar { font: inherit; width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .02em; display: inline-grid; place-items: center; cursor: pointer; margin-left: 4px; flex: none; }
.avatar:hover { background: var(--brand-hover); }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; margin: 0; cursor: default; }
.avatar-lg:hover { background: var(--brand); }

/* popovers */
.popover { position: absolute; top: calc(100% + 8px); z-index: 45; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-pop); }
.pop-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 12px 14px 4px; }
.launcher { left: 0; width: 540px; padding-bottom: 8px; }
.launcher-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; padding: 4px 8px; }
.launch-tile { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.launch-tile:hover { background: var(--surface-2); }
.launch-tile.active { background: var(--brand-softer); }
.launch-ico, .side-app-ico, .app-card-ico, .state-ico { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.launch-ico .ico, .launch-ico svg { width: 18px; height: 18px; }
.launch-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.launch-text b { font-size: 13.5px; font-weight: 700; }
.launch-text small { color: var(--muted); font-size: 12px; }
.me-menu { right: 0; width: 280px; padding: 6px; }
.me-card { display: flex; gap: 12px; padding: 10px 8px; align-items: flex-start; }
.me-ids { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; }
.me-ids b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.me-ids .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-ids .badge { margin-top: 4px; }
.menu-sep { height: 1px; background: var(--line-2); margin: 4px 0; }
.menu-item { font: inherit; font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: var(--r); color: var(--ink-2); text-decoration: none; cursor: pointer; text-align: left; }
.menu-item .ico { color: var(--muted); }
.menu-item:hover { background: var(--surface-2); color: var(--ink); }

/* side bar */
.side { background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); display: flex; flex-direction: column; min-width: 0; z-index: 30; }
.side-head { padding: 14px 12px 10px; }
.side-app { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); border-radius: var(--r); min-width: 0; }
.side-app-ico { width: 30px; height: 30px; }
.side-app-name { font-weight: 800; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { flex: 1 1 auto; overflow-y: auto; padding: 4px 10px 16px; display: flex; flex-direction: column; gap: 1px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r); color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 13.5px; white-space: nowrap; min-width: 0; }
.nav a .ico { color: var(--faint); }
.nav-text { overflow: hidden; text-overflow: ellipsis; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a:hover .ico { color: var(--ink-2); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.nav a.active .ico { color: var(--brand); }
.side-foot { display: flex; align-items: center; gap: 6px; padding: 8px 10px 10px; border-top: 1px solid var(--line-2); }
.side-ver { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; }
body.side-collapsed .side-head { padding: 12px 0 10px; display: flex; justify-content: center; }
body.side-collapsed .side-app-name, body.side-collapsed .nav-text, body.side-collapsed .side-ver { display: none; }
body.side-collapsed .nav { padding: 4px 8px 16px; }
body.side-collapsed .nav a { justify-content: center; padding: 9px 0; }
body.side-collapsed .side-foot { justify-content: center; padding: 8px 0 10px; }
.scrim { display: none; }

/* main */
.main { padding: 16px 28px 64px; min-width: 0; }
.crumbs { max-width: 1320px; margin: 0 auto 10px; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.crumbs li + li::before { content: '/'; color: var(--line-3); margin-right: 6px; }
.crumbs a { color: var(--muted); text-decoration: none; font-weight: 500; }
.crumbs a:hover { color: var(--brand); text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink-2); font-weight: 600; }
.content { outline: none; min-width: 0; }
.view { max-width: 1320px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.view-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* empty/forbidden route */
.state-card { max-width: 440px; margin: 48px auto; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 32px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.state-ico { width: 44px; height: 44px; border-radius: 50%; margin-bottom: 8px; }
.state-ico .ico, .state-ico svg { width: 20px; height: 20px; }
.state-card b { font-size: 16px; }
.state-card p { margin: 0 0 12px; color: var(--muted); }

@media (max-width: 1400px) {
  .gsearch { width: 200px; }
  .apptabs { gap: 0; margin-left: 2px; }
  .apptab { padding: 0 9px; gap: 6px; }
  .brand-tag { display: none; }
}
@media (max-width: 900px) {
  .shell, body.side-collapsed .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 0 8px; gap: 2px; }
  .apptabs { display: none; }
  .side { position: fixed; top: var(--top-h); left: 0; bottom: 0; width: 272px; height: auto; transform: translateX(-100%); transition: transform .2s ease; visibility: hidden; }
  body.nav-open .side { transform: none; box-shadow: 12px 0 32px rgba(15,20,25,.14); visibility: visible; }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--top-h) 0 0 0; background: rgba(15,20,25,.32); z-index: 25; }
  body.side-collapsed .side-app-name, body.side-collapsed .nav-text, body.side-collapsed .side-ver { display: revert; }
  body.side-collapsed .side-head { display: block; padding: 14px 12px 10px; }
  body.side-collapsed .nav { padding: 4px 10px 16px; }
  body.side-collapsed .nav a { justify-content: flex-start; padding: 7px 10px; }
  body.side-collapsed .side-foot { justify-content: flex-start; padding: 8px 10px 10px; }
  .icon-btn.collapse-btn { display: none; }
  .main { padding: 12px 16px 48px; }
  .launcher { position: fixed; top: calc(var(--top-h) + 6px); left: 8px; right: 8px; width: auto; max-height: calc(100vh - var(--top-h) - 16px); overflow-y: auto; }
}
@media (min-width: 901px) { .icon-btn.nav-toggle { display: none; } }
@media (max-width: 760px) {
  .icon-btn.search-btn { display: inline-flex; }
  .gsearch { display: none; position: fixed; top: var(--top-h); left: 0; right: 0; width: auto; margin: 0; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 8px 16px rgba(15,20,25,.06); z-index: 39; }
  .gsearch > .ico { left: 22px; }
  .gsearch kbd { display: none; }
  body.search-open .gsearch { display: flex; }
  .icon-btn.help-btn { display: none; }
  .brand-tag { display: none; }
  .launcher-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .launch-tile { flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line-2); }
  .launch-text small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .me-menu { position: fixed; top: calc(var(--top-h) + 6px); right: 8px; }
}

/* ── Page head ── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; padding-bottom: 2px; }
.page-titles { min-width: 0; }
.page-head h1 { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.page-sub { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .search { min-width: 220px; flex: 1 1 220px; max-width: 360px; }
@media (max-width: 560px) { .toolbar .search { min-width: 0; flex-basis: 100%; max-width: none; } .toolbar > .input:not(.search) { flex: 1 1 140px; } }

/* ── Cards, KPIs ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; letter-spacing: -.005em; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head .card-title { margin: 0; }
.card-link { font-size: 12.5px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.card-link:hover { text-decoration: underline; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; text-decoration: none; color: inherit; box-shadow: var(--shadow); min-width: 0; transition: border-color .15s, box-shadow .15s; }
a.kpi:hover { border-color: var(--line-3); box-shadow: 0 2px 8px rgba(15,20,25,.07); }
a.kpi:hover .kpi-label { color: var(--brand); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
.kpi-label { align-items: flex-start; line-height: 1.35; }
.kpi-label .ico { margin-top: 1px; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -.025em; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-delta { align-self: flex-start; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 4px; background: var(--surface-3); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.kpi-delta-up { background: var(--ok-bg); color: var(--ok); }
.kpi-delta-down { background: var(--danger-bg); color: var(--danger); }
.kpi-warn { border-color: #EFD08A; background: linear-gradient(var(--warn-bg), var(--warn-bg)); }
.kpi-warn .kpi-label { color: var(--warn); }
.kpi-danger { border-color: #F2C0BB; background: var(--danger-bg); }
.kpi-danger .kpi-label { color: var(--danger); }
@media (max-width: 560px) { .kpi { padding: 12px; } .kpi-value { font-size: 20px; } }

/* ── Buttons, inputs ── */
.btn { font: inherit; font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-3); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; text-decoration: none; box-shadow: 0 1px 1px rgba(15,20,25,.03); transition: background .12s, border-color .12s; }
.btn:hover:not(:disabled) { border-color: #BCC3CC; background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #912018; border-color: #912018; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.icon-btn { font: inherit; font-size: 20px; line-height: 1; border: 0; background: none; cursor: pointer; min-width: 34px; height: 34px; padding: 0 8px; border-radius: var(--r); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn[aria-expanded="true"] { background: var(--surface-3); color: var(--ink); }
.link-btn { font: inherit; font-size: 13px; border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
.input { font: inherit; font-size: 13.5px; height: 34px; padding: 0 10px; border: 1px solid var(--line-3); border-radius: var(--r); background: var(--surface); color: var(--ink); min-width: 0; }
select.input { padding-right: 28px; -webkit-appearance: none; appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2367707C' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center; cursor: pointer; }
select.input[multiple] { height: auto; background-image: none; padding: 6px 10px; }
.input:hover { border-color: #BCC3CC; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(212,34,95,.14); }
textarea.input { min-height: 90px; resize: vertical; width: 100%; height: auto; padding: 8px 10px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field .input { width: 100%; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: 12px; color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
.check { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--brand); }
.range { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.range-custom { display: inline-flex; gap: 6px; align-items: center; }
.range-date { width: 140px; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600; line-height: 18px; padding: 0 7px; border-radius: 4px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; border: 1px solid transparent; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }

/* ── Tables ── */
.table-wrap { min-width: 0; }
.table-scroll { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow); }
@media (min-width: 901px) { .table-scroll { max-height: calc(100vh - 150px); } }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: top; white-space: nowrap; }
.tbl td.wrap, .tbl .wrap { white-space: normal; min-width: 200px; }
.tbl th { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); border-bottom-color: var(--line); position: sticky; top: 0; z-index: 1; white-space: nowrap; padding-top: 8px; padding-bottom: 8px; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl th[aria-sort] { color: var(--ink-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr.clickable { cursor: pointer; }
.tbl tbody tr:hover td { background: #FAFBFC; }
.tbl tr.clickable:hover td { background: var(--brand-softer); }
.tbl .r, .tbl th.r { text-align: right; }
.tbl-compact th, .tbl-compact td { padding: 6px 10px; }
.card .table-scroll { border: 0; border-radius: 0; box-shadow: none; max-height: none; }
.card > .table-wrap:last-child, .card > .table-scroll:last-child { margin: 0 -16px -16px; }
.card > .table-wrap:last-child .table-scroll, .card > .table-scroll:last-child { border-top: 1px solid var(--line-2); border-radius: 0 0 var(--r-card) var(--r-card); }
.card > .table-wrap .pager { padding: 10px 16px 12px; }
.card > .table-wrap > .empty { padding: 24px 16px 28px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px 0 0; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pager span { margin-right: 4px; }
.person { display: flex; flex-direction: column; line-height: 1.3; }
.person b { font-weight: 600; }
.person .muted { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ── States ── */
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 32px 0; justify-content: center; font-size: 13.5px; }
.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); font-size: 13.5px; }
.empty b { display: block; color: var(--ink); font-size: 14.5px; margin-bottom: 4px; }
.empty p { margin: 0 0 12px; }
.empty-err { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.empty-err b { color: var(--danger); }
.empty-sm { padding: 16px; }
.note { font-size: 12.5px; color: var(--muted); margin: 0; }
.callout { border: 1px solid #EFD08A; background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 14px; font-size: 13px; }
.callout-info { border-color: #BED2EE; background: var(--info-bg); color: var(--info); }

/* ── Modal, drawer, toasts ── */
.overlay, .drawer-wrap { position: fixed; inset: 0; background: rgba(15,20,25,.38); z-index: 50; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-items: center; padding: 16px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-pop); border: 1px solid var(--line); }
.modal-wide { max-width: 760px; }
.modal-head, .drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2, .drawer-head h2 { font-size: 15.5px; font-weight: 700; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-body p { margin: 0 0 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 12px 12px; }
.drawer-wrap { justify-items: end; align-items: stretch; padding: 0; }
.drawer { background: var(--surface); width: min(640px, 100vw); height: 100vh; display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(15,20,25,.16); animation: slide .18s ease; }
.drawer-head { min-height: var(--top-h); }
.drawer-body { padding: 16px 20px 40px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 7px 12px; margin: 0; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; word-break: break-word; }
@media (max-width: 560px) { .dl { grid-template-columns: 110px 1fr; } }
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; max-width: 380px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-pop); transition: opacity .3s, transform .3s; border-left: 3px solid var(--faint); }
.toast-ok { border-left-color: #3DD39A; }
.toast-err { border-left-color: #FF7A6E; }
.toast.out { opacity: 0; transform: translateY(6px); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ── Charts ── */
.chart { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.chart-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.chart-title { font-weight: 700; font-size: 14px; margin-right: auto; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item i, .tip-row i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-canvas { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--line-2); stroke-width: 1; }
.chart-svg .axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart-svg .cross { stroke: #9AA1AB; stroke-width: 1; stroke-dasharray: 3 3; }
.tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow-pop); font-size: 12px; pointer-events: none; min-width: 130px; z-index: 2; }
.tip b { display: block; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip-row span { margin-left: auto; font-weight: 700; color: var(--ink); padding-left: 10px; font-variant-numeric: tabular-nums; }
.barlist { display: flex; flex-direction: column; gap: 9px; }
.barlist-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.barlist-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.barlist-track { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.barlist-fill { display: block; height: 100%; border-radius: 4px; }
.barlist-value { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; min-width: 60px; }
.barlist-value small { display: block; font-weight: 500; color: var(--muted); }
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: minmax(140px, 28%) 1fr 120px; gap: 12px; align-items: center; }
.funnel-label { display: flex; flex-direction: column; font-size: 13px; }
.funnel-track { height: 20px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.funnel-fill { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.funnel-num { text-align: right; display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.funnel-num small { color: var(--muted); }
@media (max-width: 560px) { .funnel-row { grid-template-columns: 1fr 80px; } .funnel-track { grid-column: 1 / -1; grid-row: 2; } }

/* ── Permission matrix ── */
.perm-group { margin-bottom: 14px; }
.perm-group h4 { margin: 0 0 6px; font-size: 13px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 16px; }
.perm-key { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); display: block; }
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.yes { color: var(--ok); font-weight: 800; }
.no { color: #C4C9D0; }

/* ── Dashboards (home, module landing pages) ── */
.hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hello h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.hello p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }
.hello-date { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.sec-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 8px 0 -6px; }
.app-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.app-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; min-width: 0; }
.app-card:hover { border-color: var(--line-3); box-shadow: 0 4px 14px rgba(15,20,25,.08); }
.app-card-top { display: flex; align-items: center; gap: 12px; }
.app-card-ico .ico, .app-card-ico svg { width: 18px; height: 18px; }
.app-card b { font-size: 14.5px; font-weight: 700; }
.app-card p { margin: 0; font-size: 12.5px; color: var(--muted); flex: 1; }
.app-card-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 10px; }
.app-card-open { display: inline-flex; align-items: center; gap: 4px; color: var(--brand); font-weight: 700; font-size: 12.5px; }
.app-card:hover .app-card-open { text-decoration: underline; }
.attn { list-style: none; margin: 0; padding: 0; }
.attn li { border-bottom: 1px solid var(--line-2); }
.attn li:last-child { border-bottom: 0; }
.attn a { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 2px; text-decoration: none; color: var(--ink); border-radius: var(--r); }
.attn a:hover { background: var(--brand-softer); }
.attn-ico { width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; }
.attn-warn { background: var(--warn-bg); color: var(--warn); }
.attn-danger { background: var(--danger-bg); color: var(--danger); }
.attn-info { background: var(--info-bg); color: var(--info); }
.attn-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.attn-main b { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attn-main span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attn-side { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat-list { display: flex; flex-direction: column; }
.stat-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.stat-row:last-child { border-bottom: 0; }
.stat-row b { font-variant-numeric: tabular-nums; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.dash-grid-wide { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
@media (max-width: 1439px) { .dash-grid-wide { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .attn-main span { white-space: normal; } .attn a { gap: 10px; } }
@media (max-width: 560px) {
  .app-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .app-card { padding: 12px; gap: 0; }
  .app-card p, .app-card-foot { display: none; }
  .app-card-top { gap: 10px; }
  .app-card-ico { width: 30px; height: 30px; }
  .app-card b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
