/* Design tokens and shell ported from the vibe-coding portal (packages/ui/src/ui.css, css/app-shell.css). */
:root {
  color-scheme: light;
  --bg: #f6f8fa; --surface: #ffffff; --surface-2: #eff2f5; --sidebar: #fbfcfd;
  --text: #1f2328; --text-2: #3d444d; --muted: #59636e; --line: #d1d9e0; --line-strong: #7d8590;
  --accent: #1d4ed8; --accent-hover: #1e40af; --accent-text: #ffffff;
  --ok: #1a7f37; --warn: #9a6700; --bad: #d1242f; --info: #1d4ed8;
  --warn-solid: #fcc419; --on-warn: #1f1600; --on-strong: #ffffff;
  --ok-bg: #dafbe1; --warn-bg: #fff8c5; --bad-bg: #ffebe9; --info-bg: #ddf4ff;
  --tip-bg: #1f2328; --tip-text: #ffffff; --scrim: #0a0e14;
  --shadow-xs: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-sm: 0 1px 3px rgb(16 24 40 / 0.07), 0 1px 2px rgb(16 24 40 / 0.04);
  --shadow-md: 0 6px 16px -4px rgb(16 24 40 / 0.1), 0 2px 4px -2px rgb(16 24 40 / 0.05);
  --shadow-lg: 0 24px 48px -12px rgb(16 24 40 / 0.22);

  --sp-1: 4px; --sp-1-5: 6px; --sp-2: 8px; --sp-2-5: 10px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-7: 32px;
  --radius-xs: 4px; --radius-sm: 6px; --radius: 8px; --radius-lg: 12px; --radius-pill: 999px;
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --fs-md: 16px; --fs-lg: 20px; --fs-xl: 24px;
  --font: "Inter Variable", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1117; --surface: #151b23; --surface-2: #212830; --sidebar: #10151c;
    --text: #e6edf3; --text-2: #c5ced8; --muted: #9ea7b3; --line: #30363d; --line-strong: #768390;
    --accent: #60a5fa; --accent-hover: #93c5fd; --accent-text: #0d1117;
    --ok: #3fb950; --warn: #d29922; --bad: #f85149; --info: #60a5fa; --on-strong: #0d1117;
    --ok-bg: #12261e; --warn-bg: #272115; --bad-bg: #2d1517; --info-bg: #121d2f;
    --tip-bg: #e6edf3; --tip-text: #0d1117;
    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3); --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.4);
    --shadow-md: 0 8px 20px -6px rgb(0 0 0 / 0.5); --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117; --surface: #151b23; --surface-2: #212830; --sidebar: #10151c;
  --text: #e6edf3; --text-2: #c5ced8; --muted: #9ea7b3; --line: #30363d; --line-strong: #768390;
  --accent: #60a5fa; --accent-hover: #93c5fd; --accent-text: #0d1117;
  --ok: #3fb950; --warn: #d29922; --bad: #f85149; --info: #60a5fa; --on-strong: #0d1117;
  --ok-bg: #12261e; --warn-bg: #272115; --bad-bg: #2d1517; --info-bg: #121d2f;
  --tip-bg: #e6edf3; --tip-text: #0d1117;
  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3); --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.4);
  --shadow-md: 0 8px 20px -6px rgb(0 0 0 / 0.5); --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.6);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 400 var(--fs-base)/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1 { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.011em; line-height: 1.3; margin: 0; }
h2 { font-size: var(--fs-md); font-weight: 600; margin: 0; }
h3 { font-size: 12px; text-transform: uppercase; font-weight: 600; letter-spacing: .05em; color: var(--text-2); margin: 0; }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
.icon { width: 16px; height: 16px; flex: none; }
.sm { font-size: var(--fs-sm); }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--sp-2); }
.stack.lg { gap: var(--sp-4); }
.stack > .btn { align-self: flex-start; }
.grow { flex: 1 1 200px; min-width: 0; }
.break { overflow-wrap: anywhere; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Shell ---------- */
.app-shell { --sidebar-w: 260px; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .18s ease; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 14px 12px 12px; background: var(--sidebar); border-right: 1px solid var(--line); z-index: 30; overflow-y: auto; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; height: 56px; margin: -14px -12px 8px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); text-decoration: none; }
.brand-logo { width: 30px; height: 30px; border-radius: var(--radius); background: var(--accent); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.brand-logo .icon { width: 18px; height: 18px; }
.brand-name { font-weight: 600; font-size: var(--fs-md); white-space: nowrap; }
.brand-name b { color: var(--accent); }
.brand-tag { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 400; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border-radius: var(--radius); color: var(--text-2); text-decoration: none; font-weight: 500; }
.nav-item .icon { width: 18px; height: 18px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent); }
.nav-group-head { position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; margin-top: 14px; padding: 0 10px; color: var(--text); font-size: var(--fs-sm); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.nav-group-head::before { content: ""; position: absolute; top: -8px; left: 6px; right: 6px; border-top: 1px solid var(--line); }
.nav-group-head .icon { width: 18px; height: 18px; color: var(--accent); }
.nav-children { display: flex; flex-direction: column; margin-left: 18px; padding-left: 8px; border-left: 1px solid var(--line); }
.nav-spacer { flex: 1; }
.nav-foot { font-size: var(--fs-xs); color: var(--muted); padding: 8px 10px 0; }
.sidebar a:focus-visible, .sidebar button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.drawer-backdrop { display: none; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; padding: 0 24px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.trail { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-2); font-size: var(--fs-sm); }
.trail a { color: var(--text-2); text-decoration: none; }
.trail a:hover { color: var(--text); text-decoration: underline; }
.trail .icon { width: 14px; height: 14px; color: var(--muted); }
.trail [aria-current="page"] { color: var(--text); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; position: relative; }
.quota-btn { display: inline-flex; align-items: center; gap: 10px; padding: 0 12px; min-height: 36px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); line-height: 1; cursor: pointer; text-decoration: none; }
.quota-btn:hover { border-color: var(--accent); background: var(--surface-2); }
.quota-item { display: inline-flex; align-items: center; gap: 6px; }
.quota-item b { font-variant-numeric: tabular-nums; }
.quota-label { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quota-btn[aria-expanded="true"] { border-color: var(--accent); }
.quota-panel { width: min(380px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow-y: auto; gap: 4px; }
.quota-panel h3 { margin: 8px 0 2px; }
.quota-panel h3:first-child { margin-top: 0; }
.quota-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin: 0 -8px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.quota-row:hover { background: var(--surface-2); }
.quota-row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.quota-row-name { font-weight: 600; display: inline-flex; align-items: center; gap: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quota-row-name .icon, .monitor-tile-label .icon { width: 14px; height: 14px; }
.quota-row b { font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }
.ring { width: 18px; height: 18px; transform: rotate(-90deg); flex: none; }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: var(--surface-2); }
.ring .value { stroke-linecap: round; stroke: var(--ok); }
.ring.warn .value { stroke: var(--warn); } .ring.bad .value { stroke: var(--bad); }
.account-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 1px solid transparent; border-radius: var(--radius-pill); background: transparent; cursor: pointer; color: var(--text); }
.account-btn:hover, .account-btn[aria-expanded="true"] { background: var(--surface-2); border-color: var(--line); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: var(--fs-sm); text-transform: uppercase; }
.floating-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: 280px; box-shadow: var(--shadow-lg); padding: 14px; }
.menu-sep { border-top: 1px solid var(--line); margin: 4px -14px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.seg button { min-height: 32px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font: inherit; font-size: var(--fs-sm); display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.seg button[aria-pressed="true"] { border-color: var(--accent); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.narrow-only { display: none !important; }

.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 48px; display: flex; flex-direction: column; gap: 20px; }
.main-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

@media (min-width: 901px) {
  .app-shell.rail { --sidebar-w: 60px; }
  .rail .sidebar { padding: 12px 8px; }
  .rail .sidebar-head { margin: -12px -8px 8px; padding: 0; justify-content: center; }
  .rail .brand-text, .rail .collapse-btn, .rail .nav-foot { display: none; }
  .rail .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .rail .nav-group-head { justify-content: center; padding: 0; }
  .rail .nav-item { position: relative; justify-content: center; padding: 0; min-height: 40px; }
  .rail .nav-children { margin-left: 0; padding-left: 0; border-left: 0; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .drawer-open .sidebar { transform: none; }
  .drawer-open .drawer-backdrop { display: block; position: fixed; inset: 0; background: color-mix(in srgb, var(--scrim) 40%, transparent); z-index: 25; }
  .topbar { padding: 0 16px; }
  .page { padding: 20px 16px 40px; }
  .narrow-only { display: inline-flex !important; }
  .wide-only { display: none !important; }
  .collapse-btn { display: none; }
  .quota-btn { padding: 0 10px; gap: 6px; }
  .quota-item:not(:first-child), .quota-label { display: none; }
  .trail > :not([aria-current]) { display: none; }
  .trail [aria-current] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-xs); min-width: 0; }
.card > h2 + * { margin-top: 12px; }
.btn { min-height: 36px; padding: 0 14px; border-radius: var(--radius); font: inherit; font-weight: 500; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; box-shadow: var(--shadow-xs); transition: background .12s, border-color .12s, box-shadow .12s; text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; box-shadow: inset 0 1px 0 rgb(255 255 255 / .14), var(--shadow-sm); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn.lg { min-height: 44px; width: 100%; }
.icon-btn { width: 36px; padding: 0; }
.field { width: 100%; min-height: 36px; padding: 7px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; transition: border-color .12s, box-shadow .12s; }
.field:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
textarea.field { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: var(--fs-sm); }
select.field { width: auto; }
label.lbl { display: flex; flex-direction: column; gap: 4px; font-weight: 500; color: var(--text-2); font-size: var(--fs-sm); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 600; line-height: 1.5; white-space: nowrap; background: var(--surface); color: var(--text); }
.badge.ok, .badge.bad, .badge.info { color: var(--on-strong); }
.badge.ok { background: var(--ok); border-color: var(--ok); }
.badge.bad { background: var(--bad); border-color: var(--bad); }
.badge.info { background: var(--info); border-color: var(--info); }
.badge.warn { background: var(--warn-solid); border-color: var(--warn-solid); color: var(--on-warn); }
.badge.outline { background: var(--surface); }
.badge.outline.ok { color: var(--ok); } .badge.outline.bad { color: var(--bad); } .badge.outline.info { color: var(--info); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.ok i { background: var(--ok); } .status.warn i { background: var(--warn); } .status.bad i { background: var(--bad); }
.progress-bar { height: 8px; border-radius: var(--radius-pill); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--ok); transition: width .4s; }
.progress-bar.sm { height: 6px; }
.progress-bar.warn > span { background: var(--warn); } .progress-bar.bad > span { background: var(--bad); } .progress-bar.info > span { background: var(--accent); }
.page-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.page-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; text-decoration: none; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; }
.page-tabs a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); max-height: 62vh; }
.board { width: 100%; border-collapse: collapse; }
.board th, .board td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.board th { color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.board tr:last-child td { border-bottom: 0; }
.board tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.board .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.board .chk { width: 36px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.alert, .error { background: var(--surface); color: var(--text); border: 1.5px solid var(--bad); border-left-width: 4px; border-radius: var(--radius-sm); padding: 8px 10px; font-weight: 500; }
.alert { border-color: var(--warn); }
.alert.info { border-color: var(--info); }
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--radius-sm); min-height: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 48px 24px; }
.empty-state .tile { width: 48px; height: 48px; border-radius: var(--radius); border: 1.5px solid currentColor; color: var(--accent); display: grid; place-items: center; }
.empty-state .tile .icon { width: 24px; height: 24px; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: var(--fs-sm); }
.crumbs .icon { width: 14px; height: 14px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv > div { display: contents; }
.kv dt { color: var(--text-2); font-weight: 500; }
.kv dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.qr svg { width: 200px; height: 200px; background: #fff; border-radius: var(--radius); padding: 6px; }

/* ---------- Monitor tiles ---------- */
.monitor-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-3); }
.monitor-tile { display: flex; flex-direction: column; gap: var(--sp-1-5); min-width: 0; padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.monitor-tile.warn { border-left-color: var(--warn); } .monitor-tile.bad { border-left-color: var(--bad); } .monitor-tile.info { border-left-color: var(--line-strong); }
.monitor-tile-label { font-weight: 600; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.monitor-tile-label > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.monitor-tile-value { font-size: var(--fs-xl); font-weight: 700; line-height: 1.1; color: var(--text); font-family: var(--mono); }
.meter-line { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-xs); color: var(--muted); }
.monitor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--sp-4); }
.monitor-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.monitor-list > li { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: 44px; padding: var(--sp-1-5) 0; border-bottom: 1px solid var(--line); }
.monitor-list > li:last-child { border-bottom: 0; }
.monitor-list > li.bad { box-shadow: inset 4px 0 0 var(--bad); padding-left: var(--sp-3); }

/* ---------- Jobs ---------- */
.job { display: flex; flex-direction: column; gap: 6px; padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius-lg); }
.job.done { border-left-color: var(--ok); } .job.failed, .job.interrupted { border-left-color: var(--bad); } .job.stopped { border-left-color: var(--line-strong); }
.job-title { font-weight: 600; overflow-wrap: anywhere; }
.job-sub { font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; }

/* ---------- Explorer ---------- */
.page.wide { max-width: none; gap: 12px; }
.main { min-width: 0; }
.explorer { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
.pane { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 10px 12px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.pane.focused { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent), var(--shadow-xs); }
.tabs { display: flex; align-items: flex-end; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 0 -12px; padding: 0 8px; }
.tab { display: flex; align-items: center; border: 1px solid transparent; border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; max-width: 220px; flex: none; }
.tab > button[role="tab"] { display: flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px; border: 0; background: none; color: var(--text-2); font: inherit; font-size: var(--fs-sm); font-weight: 500; cursor: pointer; min-width: 0; }
.tab > button[role="tab"] span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab.active { background: var(--surface); border-color: var(--line); margin-bottom: -1px; }
.tab.active > button[role="tab"] { color: var(--text); font-weight: 600; }
.tab:not(.active):hover { background: var(--surface-2); }
.tab-close, .tab-add { display: grid; place-items: center; width: 26px; height: 26px; margin-right: 4px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); cursor: pointer; flex: none; }
.tab-close .icon { width: 14px; height: 14px; }
.tab-close:hover, .tab-add:hover { background: var(--surface-2); color: var(--text); }
.tab-add { margin: 0 0 4px 4px; }
.pane-bar { display: flex; align-items: center; gap: 4px; }
.pane-bar select { flex: 1 1 auto; min-width: 0; max-width: 260px; }
.pane-list { height: calc(100vh - 420px); min-height: 260px; max-height: none; outline: none; }
.pane-list:focus-visible { box-shadow: var(--ring); }
.pane-list.drop-target { box-shadow: inset 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.pane .board td { padding: 6px 8px; }
.pane .board tbody tr { cursor: default; user-select: none; }
.pane .board tbody tr.selected { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.pane .board tbody tr.drop-target { box-shadow: inset 0 0 0 2px var(--accent); }
.name-cell .link-btn, .file-name { display: inline-flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.name-cell .icon { color: var(--muted); }
.name-cell .link-btn .icon { color: var(--accent); }
.board th .sort { color: inherit; font-weight: 600; }
.pane-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.side-toggle { grid-template-columns: 1fr 1fr; }
.side-toggle button { min-height: 40px; }
.queue { padding: 10px 16px; }
.queue-toggle { color: var(--text); }
.queue-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; max-height: 260px; overflow: auto; }
.queue-row { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.queue-row.failed, .queue-row.interrupted { box-shadow: inset 4px 0 0 var(--bad); }
.rot-90 { transform: rotate(90deg); }
.ctx-menu { position: fixed; z-index: 60; min-width: 220px; max-width: 320px; padding: 6px; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.ctx-menu button { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.ctx-menu button span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-menu button:hover:not(:disabled), .ctx-menu button:focus-visible { background: var(--surface-2); outline: none; }
.ctx-menu button.danger { color: var(--bad); }
.ctx-menu button:disabled { opacity: .45; cursor: default; }
.ctx-menu kbd { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); }
.ctx-sep { border-top: 1px solid var(--line); margin: 4px 0; }
.count-sm.hot { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: auto; padding: 0 6px; border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 600; background: var(--bad); color: var(--on-strong); }
.nav-count { margin-left: auto; color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; }
@media (max-width: 900px) {
  .explorer { grid-template-columns: 1fr; }
  .explorer[data-mobile="left"] .pane[data-side="right"], .explorer[data-mobile="right"] .pane[data-side="left"] { display: none; }
  .pane-list { height: calc(100vh - 400px); }
}

/* ---------- Overlays ---------- */
dialog { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); padding: 20px; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: color-mix(in srgb, var(--scrim) 45%, transparent); }
dialog h2 { margin-bottom: 12px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast-stack { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--tip-bg); color: var(--tip-text); padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow-md); font-weight: 500; overflow-wrap: anywhere; }
.toast.bad { border-left: 4px solid var(--bad); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px 24px; }

@media (pointer: coarse) { .btn, .field, .nav-item { min-height: 44px; } }
@media (max-width: 600px) { .monitor-grid, .kv { grid-template-columns: 1fr; } .board .hide-sm { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Usage grouping & account labels ---------- */
.field.compact { width: auto; min-height: 32px; padding: 4px 8px; font-size: var(--fs-sm); }
.usage-view { gap: var(--sp-3); }
.usage-view label { color: var(--text-2); font-weight: 500; }
.group-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: var(--sp-2); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-2); font: inherit; font-size: var(--fs-xs); font-weight: 500; line-height: 1.6; }
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--accent); color: var(--text); }
.chip .icon { width: 12px; height: 12px; }
.tile-actions { gap: 2px; flex-wrap: nowrap; margin-left: auto; }
.tile-actions .btn { min-height: 28px; width: 28px; }
.tile-actions .btn[aria-pressed="true"] { color: var(--accent); }
.meter-line .icon { width: 13px; height: 13px; vertical-align: -2px; }
.meter-line.text-warn { color: var(--warn); } .meter-line.text-bad { color: var(--bad); }
.alert.sm { padding: 4px 8px; font-size: var(--fs-xs); }
.note-view { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); font-size: var(--fs-sm); padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }
.pw-wrap { position: relative; display: block; }
.pw-wrap .field { padding-right: 42px; }
.pw-toggle { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 34px; height: 30px; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
.pw-toggle:focus-visible { outline: none; box-shadow: var(--ring); }
.otp-field { font-family: var(--mono); font-size: var(--fs-lg); letter-spacing: .4em; text-align: center; }
.login-card [data-icon] { display: inline-flex; }
.login-card #back { align-self: center; }
.service-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-3); }
.service-tile { display: flex; align-items: flex-start; gap: 12px; padding: 14px; text-align: left; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.service-tile:hover { border-color: var(--accent); background: var(--surface-2); }
.service-tile:focus-visible { outline: none; box-shadow: var(--ring); }
.service-tile > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.service-tile-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: var(--radius); background: var(--accent); color: var(--accent-text); }
.vault-gate { max-width: 560px; }
.vault-notes { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
#vault-door { cursor: default; user-select: none; -webkit-tap-highlight-color: transparent; }
