/* shadcn/ui (zinc) design tokens + component styles: Button, Card, Badge, Input, Select, Tabs, Table, Dialog, Sheet,
   Switch, Toggle Group, Popover, Sidebar, Sonner-style toast. Shared by every page. */
:root{
  --background:#ffffff;--foreground:#09090b;--card:#ffffff;--card-foreground:#09090b;--popover:#ffffff;
  --muted:#f4f4f5;--muted-foreground:#71717a;--border:#e4e4e7;--input:#e4e4e7;
  --primary:#18181b;--primary-foreground:#fafafa;--secondary:#f4f4f5;--accent:#f4f4f5;
  --ring:#a1a1aa;--destructive:#dc2626;--radius:.5rem;--sidebar:#fafafa;
  --font:Inter,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","Noto Sans CJK SC",system-ui,-apple-system,"Segoe UI",sans-serif;
  color-scheme:light}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){
  --background:#09090b;--foreground:#fafafa;--card:#0c0c0f;--card-foreground:#fafafa;--popover:#0c0c0f;
  --muted:#27272a;--muted-foreground:#a1a1aa;--border:#27272a;--input:#3f3f46;
  --primary:#fafafa;--primary-foreground:#18181b;--secondary:#27272a;--accent:#27272a;
  --ring:#71717a;--destructive:#f87171;--sidebar:#0c0c0f;color-scheme:dark}}
:root[data-theme="dark"]{
  --background:#09090b;--foreground:#fafafa;--card:#0c0c0f;--card-foreground:#fafafa;--popover:#0c0c0f;
  --muted:#27272a;--muted-foreground:#a1a1aa;--border:#27272a;--input:#3f3f46;
  --primary:#fafafa;--primary-foreground:#18181b;--secondary:#27272a;--accent:#27272a;
  --ring:#71717a;--destructive:#f87171;--sidebar:#0c0c0f;color-scheme:dark}
*{box-sizing:border-box;border-color:var(--border)}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--background);color:var(--foreground);font:14px/1.5 var(--font);-webkit-font-smoothing:antialiased}
button,input,select,textarea{font:inherit;color:inherit}
h1,h2,h3,h4,p{margin:0}
h1,h2,h3,h4{font-weight:600;letter-spacing:-.01em}
a{color:inherit}
hr,.sep{border:0;border-top:1px solid var(--border);margin:0}
svg.i{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;flex:none}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
:focus-visible{outline:2px solid var(--ring);outline-offset:2px}
[hidden]{display:none!important}
.muted{color:var(--muted-foreground)}.sm{font-size:12.5px}.right{margin-left:auto}
.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.col{display:flex;flex-direction:column;gap:12px}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.grow{flex:1;min-width:0}

/* ---- app shell (sidebar-07 style) ---- */
.app{display:grid;grid-template-columns:248px minmax(0,1fr);min-height:100vh}
.sidebar{position:sticky;top:0;height:100vh;display:flex;flex-direction:column;gap:4px;padding:12px;background:var(--sidebar);border-right:1px solid var(--border);overflow:auto}
.sb-brand{display:flex;align-items:center;gap:10px;padding:6px 8px 14px;font-weight:600;font-size:15px}
.logo{width:28px;height:28px;border-radius:6px;background:var(--primary);color:var(--primary-foreground);display:grid;place-items:center}
.sb-label{padding:10px 8px 4px;font-size:11.5px;font-weight:500;color:var(--muted-foreground)}
.nav a,.nav button{display:flex;align-items:center;gap:10px;width:100%;height:34px;padding:0 8px;border:0;border-radius:calc(var(--radius) - 2px);background:transparent;font-size:13.5px;text-decoration:none;cursor:pointer;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.nav a:hover,.nav button:hover{background:var(--accent)}
.nav a[aria-current="page"]{background:var(--accent);font-weight:500}
.nav .sub{padding-left:34px;height:30px;font-size:13px;color:var(--muted-foreground)}
.nav .sub[aria-current="page"]{color:var(--foreground)}
.sb-foot{margin-top:auto;display:flex;align-items:center;gap:8px;padding:10px 4px 0;border-top:1px solid var(--border)}
.sb-foot .who{flex:1;min-width:0;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.main{min-width:0;display:flex;flex-direction:column}
.topbar{position:sticky;top:0;z-index:20;display:flex;align-items:center;gap:12px;min-height:56px;padding:8px 24px;border-bottom:1px solid var(--border);background:var(--background)}
.topbar h1{font-size:15px}
.crumb{color:var(--muted-foreground);font-size:13px}
.content{padding:20px 24px 48px;display:flex;flex-direction:column;gap:16px;max-width:1800px;width:100%}
.menu-btn{display:none}
@media (max-width:900px){
  .app{grid-template-columns:minmax(0,1fr)}
  .sidebar{position:fixed;z-index:60;left:0;top:0;width:260px;transform:translateX(-100%);transition:transform .2s}
  .nav-open .sidebar{transform:none;box-shadow:0 0 0 100vmax rgb(0 0 0/.5)}
  .menu-btn{display:inline-flex}.topbar,.content{padding-inline:16px}}

/* ---- button ---- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:36px;padding:0 14px;border-radius:calc(var(--radius) - 2px);border:1px solid transparent;background:var(--primary);color:var(--primary-foreground);font-size:13px;font-weight:500;cursor:pointer;white-space:nowrap;text-decoration:none;transition:background .15s,opacity .15s}
.btn:hover{opacity:.9}.btn:disabled{opacity:.5;pointer-events:none}
.btn.outline{background:var(--background);color:var(--foreground);border-color:var(--input);box-shadow:0 1px 2px rgb(0 0 0/.05)}
.btn.outline:hover{background:var(--accent);opacity:1}
.btn.secondary{background:var(--secondary);color:var(--foreground)}
.btn.ghost{background:transparent;color:var(--foreground)}.btn.ghost:hover{background:var(--accent);opacity:1}
.btn.destructive{background:var(--destructive);color:#fff}
.btn.sm{height:32px;padding:0 10px;font-size:12.5px}.btn.icon{width:32px;height:32px;padding:0}
.btn.danger:hover{color:var(--destructive)}

/* ---- card ---- */
.card{border:1px solid var(--border);border-radius:calc(var(--radius) + 4px);background:var(--card);color:var(--card-foreground);box-shadow:0 1px 2px rgb(0 0 0/.05);min-width:0}
.card-h{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:18px 20px 12px}
.card-h h3{font-size:15px;line-height:1.35}.card-h p{margin-top:2px;color:var(--muted-foreground);font-size:12.5px}
.card-h .acts{display:flex;gap:2px;flex:none}
.card-b{padding:0 20px 20px;min-width:0}
.card.pad{padding:16px 20px}
.badge{display:inline-flex;align-items:center;height:22px;padding:0 8px;border-radius:99px;border:1px solid var(--border);font-size:11.5px;font-weight:500;color:var(--muted-foreground);white-space:nowrap}
.badge.solid{background:var(--secondary);color:var(--foreground);border-color:transparent}
.badge.ok{background:color-mix(in srgb,#16a34a 16%,transparent);color:var(--foreground);border-color:transparent}
.badge.warn{background:color-mix(in srgb,#eda100 20%,transparent);color:var(--foreground);border-color:transparent}
.badge.bad{background:color-mix(in srgb,var(--destructive) 16%,transparent);color:var(--foreground);border-color:transparent}

/* ---- inputs ---- */
.lbl{font-size:12.5px;font-weight:500;display:block;margin-bottom:6px}
.field{min-width:0}
.inp,textarea.inp{width:100%;height:36px;padding:0 12px;border-radius:calc(var(--radius) - 2px);border:1px solid var(--input);background:transparent;box-shadow:0 1px 2px rgb(0 0 0/.04);font-size:13px}
textarea.inp{height:auto;padding:8px 12px}
.inp.sm{height:32px;font-size:12.5px}.inp::placeholder{color:var(--muted-foreground)}
.sel{position:relative}
.sel select{appearance:none;-webkit-appearance:none;width:100%;height:36px;padding:0 32px 0 12px;border-radius:calc(var(--radius) - 2px);border:1px solid var(--input);background:transparent;box-shadow:0 1px 2px rgb(0 0 0/.04);cursor:pointer;text-overflow:ellipsis;font-size:13px}
.sel.sm select{height:32px;font-size:12.5px}
.sel select option,.sel select optgroup{background:var(--background);color:var(--foreground)}
.sel::after{content:"";position:absolute;right:11px;top:50%;width:14px;height:14px;margin-top:-7px;background:var(--muted-foreground);pointer-events:none;-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat}
.sw-row{display:flex;align-items:center;justify-content:space-between;gap:12px;font-size:13px}
.sw{width:36px;height:20px;border-radius:99px;border:2px solid transparent;background:var(--input);position:relative;cursor:pointer;padding:0;flex:none;transition:background .15s}
.sw::after{content:"";position:absolute;top:0;left:0;width:16px;height:16px;border-radius:50%;background:var(--background);box-shadow:0 1px 2px rgb(0 0 0/.3);transition:transform .15s}
.sw[aria-checked="true"]{background:var(--primary)}.sw[aria-checked="true"]::after{transform:translateX(16px)}
/* toggle group / tabs */
.tg{display:grid;grid-template-columns:repeat(3,1fr);gap:4px;padding:4px;background:var(--muted);border-radius:var(--radius)}
.tg button{height:32px;border:0;background:transparent;border-radius:calc(var(--radius) - 2px);font-size:12.5px;font-weight:500;color:var(--muted-foreground);cursor:pointer;white-space:nowrap}
.tg button:hover{color:var(--foreground)}
.tg button[aria-pressed="true"]{background:var(--background);color:var(--foreground);box-shadow:0 1px 2px rgb(0 0 0/.1)}
.tabs{display:inline-flex;align-items:center;gap:2px;padding:4px;background:var(--muted);border-radius:var(--radius);max-width:100%;overflow-x:auto;scrollbar-width:none}
.tabs a,.tabs button{display:inline-flex;align-items:center;height:30px;padding:0 12px;border:0;border-radius:calc(var(--radius) - 2px);background:transparent;color:var(--muted-foreground);font-size:13px;font-weight:500;cursor:pointer;white-space:nowrap;text-decoration:none}
.tabs a:hover,.tabs button:hover{color:var(--foreground)}
.tabs [aria-selected="true"],.tabs [aria-current="page"]{background:var(--background);color:var(--foreground);box-shadow:0 1px 2px rgb(0 0 0/.1)}

/* ---- multi-select popover (combobox) ---- */
.ms{position:relative}
.ms-btn{display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 10px;border-radius:calc(var(--radius) - 2px);border:1px dashed var(--input);background:var(--background);font-size:12.5px;cursor:pointer}
.ms-btn:hover{background:var(--accent)}.ms-btn .badge{height:18px;padding:0 6px;font-size:11px}
.pop{position:absolute;z-index:80;top:calc(100% + 4px);left:0;width:240px;max-height:340px;display:flex;flex-direction:column;border:1px solid var(--border);border-radius:var(--radius);background:var(--popover);box-shadow:0 8px 24px rgb(0 0 0/.15)}
.pop .inp{border:0;border-bottom:1px solid var(--border);border-radius:var(--radius) var(--radius) 0 0;box-shadow:none}
.pop-list{overflow:auto;padding:4px}
.pop-item{display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:calc(var(--radius) - 2px);font-size:13px;cursor:pointer}
.pop-item:hover{background:var(--accent)}
.pop-item .ck{width:16px;height:16px;border:1px solid var(--input);border-radius:4px;display:grid;place-items:center;flex:none}
.pop-item[aria-checked="true"] .ck{background:var(--primary);border-color:var(--primary);color:var(--primary-foreground)}
.pop-foot{display:flex;justify-content:space-between;padding:4px;border-top:1px solid var(--border)}

/* ---- table ---- */
.tbl{overflow:auto;max-height:560px;border:1px solid var(--border);border-radius:var(--radius)}
.tbl.tall{max-height:none}
table{width:100%;border-collapse:separate;border-spacing:0;font-size:13px;font-variant-numeric:tabular-nums}
th,td{padding:9px 14px;border-bottom:1px solid var(--border);white-space:nowrap;text-align:left;background:var(--card)}
th{position:sticky;top:0;z-index:1;height:40px;font-weight:500;color:var(--muted-foreground);background:var(--muted);font-size:12.5px}
th.n,td.n{text-align:right}
tbody tr:last-child td{border-bottom:0}
tbody tr:hover td{background:var(--muted)}
td.k{font-weight:500}td.grp{vertical-align:top}
td.tot,th.tot{font-weight:600}td.tot{background:var(--muted)}
tfoot td{font-weight:600;background:var(--muted);border-top:1px solid var(--border);border-bottom:0}
td.z{color:var(--muted-foreground)}
td.lk{cursor:pointer}td.lk:hover{text-decoration:underline;text-underline-offset:3px}
td.op{width:1%}
.exporting th{position:static}.exporting .tbl{max-height:none;overflow:visible}.exporting .card{box-shadow:none}

/* ---- dialog / sheet ---- */
.overlay{position:fixed;inset:0;z-index:100;background:rgb(0 0 0/.6);display:flex;align-items:center;justify-content:center;padding:16px}
.overlay.sheet-wrap{justify-content:flex-end;padding:0}
.dlg{background:var(--background);border:1px solid var(--border);border-radius:calc(var(--radius) + 4px);width:min(720px,100%);max-height:100%;display:flex;flex-direction:column;box-shadow:0 20px 50px rgb(0 0 0/.35)}
.dlg.lg{width:min(1000px,100%)}.dlg.sm{width:min(460px,100%)}
.sheet-wrap .dlg{width:min(900px,100%);height:100%;max-height:100%;border-radius:0;border-width:0 0 0 1px}
.dlg-h{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:16px 20px;border-bottom:1px solid var(--border)}
.dlg-h p{color:var(--muted-foreground);font-size:12.5px;margin-top:2px}
.dlg-b{padding:16px 20px;overflow:auto;flex:1;min-height:0}
.dlg-f{display:flex;gap:8px;flex-wrap:wrap;align-items:center;justify-content:flex-end;padding:12px 20px;border-top:1px solid var(--border)}
.dlg-f .hint{color:var(--muted-foreground);font-size:12.5px;flex:1;min-width:160px;text-align:left}
.ed-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px}
.toast-wrap{position:fixed;right:16px;bottom:16px;z-index:300;display:flex;flex-direction:column;gap:8px;align-items:flex-end}
.toast{background:var(--background);color:var(--foreground);border:1px solid var(--border);padding:12px 16px;border-radius:var(--radius);font-size:13px;box-shadow:0 8px 24px rgb(0 0 0/.18);max-width:min(420px,calc(100vw - 32px))}
.toast.err{border-color:var(--destructive)}

/* ---- dashboard ---- */
.filters{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.filters .inp{width:150px;height:32px;font-size:12.5px}
.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px}
.tile{border:1px solid var(--border);border-radius:var(--radius);padding:10px 14px;display:flex;flex-direction:column;gap:2px;background:var(--card)}
.tile span{font-size:12px;color:var(--muted-foreground)}
.tile small{font-size:12px;display:flex;gap:6px;align-items:center;flex-wrap:wrap}
.dl{font-style:normal;font-weight:500}.dl.up{color:#16a34a}.dl.down{color:var(--destructive)}
.tile svg{margin-top:4px}
.chip{display:inline-flex;align-items:center;gap:4px;height:22px;padding:0 8px;border-radius:99px;background:var(--secondary);font-size:12px;white-space:nowrap}
.chip button{border:0;background:transparent;padding:0;cursor:pointer;color:var(--muted-foreground);line-height:1;font-size:14px}
.chip button:hover{color:var(--destructive)}
.tile strong{font-size:22px;font-weight:600;letter-spacing:-.02em;font-variant-numeric:tabular-nums}
.board{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,460px),1fr));gap:16px}
.board .card.wide{grid-column:1/-1}
.board .card.active{border-color:var(--ring);box-shadow:0 0 0 3px color-mix(in srgb,var(--ring) 28%,transparent)}
.cw{position:relative;height:320px}
.empty{padding:40px 0;text-align:center;color:var(--muted-foreground);font-size:13px}
.drop{display:flex;flex-direction:column;align-items:center;gap:6px;text-align:center;padding:36px 12px;border:1px dashed var(--input);border-radius:var(--radius);cursor:pointer;color:var(--muted-foreground);font-size:12.5px;transition:background .15s}
.drop:hover,.drop.over{background:var(--accent);border-color:var(--ring)}
.drop strong{color:var(--foreground);font-size:13px;font-weight:500}
.pill{display:inline-block;margin-left:6px;padding:0 6px;border-radius:99px;font-size:11px;line-height:18px;background:color-mix(in srgb,#eda100 22%,transparent)}
.preset-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:10px}
.preset{display:flex;flex-direction:column;gap:4px;text-align:left;padding:12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--card);cursor:pointer}
.preset:hover{background:var(--accent)}.preset b{font-size:13px;font-weight:500}.preset span{font-size:12px;color:var(--muted-foreground)}
.preset .tag{align-self:flex-start}
pre.code,code.code{font:12px/1.55 ui-monospace,SFMono-Regular,Menlo,monospace;background:var(--muted);border-radius:var(--radius);padding:10px 12px;overflow:auto;margin:0;white-space:pre-wrap;word-break:break-all}
code.code{padding:2px 6px;display:inline-block}
.login{min-height:100vh;display:grid;place-items:center;padding:16px}
.login .card{width:min(380px,100%)}
.err{color:var(--destructive);font-size:12.5px;min-height:18px}
@media (prefers-reduced-motion:reduce){*{transition:none!important}}
