
:root{
  --bg:#f5f6f8; --surface:#fff; --surface-2:#fafbfc; --line:#e6e8ee; --line-strong:#d5d9e2;
  --fg:#111827; --fg-2:#3f4756; --muted:#6b7280; --muted-2:#9aa1ac;
  --brand:#2f5fe0; --brand-hover:#244fc4; --brand-soft:#eef3ff; --brand-line:#c9d8ff;
  --ok:#0f8a5f; --ok-soft:#e7f6ef; --warn:#b45309; --warn-soft:#fdf3e3;
  --bad:#cf2f24; --bad-soft:#fdeceb; --idle:#64748b; --idle-soft:#f1f3f6;
  --radius:10px; --radius-sm:7px; --radius-lg:14px;
  --shadow-sm:0 1px 2px rgba(16,24,40,.05);
  --shadow:0 4px 14px rgba(16,24,40,.07);
  --shadow-lg:0 18px 50px rgba(16,24,40,.18);
  --sidebar:236px; --topbar:56px;
  --font:system-ui,-apple-system,"Segoe UI","Microsoft YaHei","PingFang SC",sans-serif;
  --mono:ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",monospace;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{font:14px/1.55 var(--font);color:var(--fg);background:var(--bg);-webkit-font-smoothing:antialiased}
a{color:var(--brand);text-decoration:none}
a:hover{text-decoration:underline}
h1,h2,h3{margin:0;font-weight:650;letter-spacing:-.01em}
h1{font-size:20px}h2{font-size:15px}h3{font-size:14px}
.muted{color:var(--muted);font-size:12.5px}
.mono{font-family:var(--mono);font-size:12px;letter-spacing:.01em}
.err{color:var(--bad);font-size:12.5px;min-height:16px}
.num{font-variant-numeric:tabular-nums}

/* ---------- shell ---------- */
.shell{display:flex;min-height:100vh}
.sidebar{width:var(--sidebar);flex:0 0 var(--sidebar);background:#0f1522;color:#c7cfdb;display:flex;flex-direction:column;position:sticky;top:0;height:100vh}
.brand{display:flex;align-items:center;gap:10px;padding:18px 18px 14px;color:#fff}
.brand-mark{width:30px;height:30px;border-radius:9px;background:linear-gradient(135deg,#4f7cff,#2f5fe0);display:grid;place-items:center;font-size:13px;font-weight:700;color:#fff;box-shadow:0 6px 16px rgba(47,95,224,.45)}
.brand-text{line-height:1.2}
.brand-text b{display:block;font-size:14px}
.brand-text span{font-size:11px;color:#8b95a7}
.nav{padding:8px 10px;display:flex;flex-direction:column;gap:2px}
.nav a{display:flex;align-items:center;gap:10px;padding:9px 10px;border-radius:8px;color:#c7cfdb;font-size:13.5px;text-decoration:none;transition:background .12s,color .12s}
.nav a svg{width:16px;height:16px;opacity:.75}
.nav a:hover{background:#1a2333;color:#fff}
.nav a.on{background:linear-gradient(90deg,rgba(79,124,255,.28),rgba(79,124,255,.10));color:#fff;box-shadow:inset 2px 0 0 #6f96ff}
.nav a.on svg{opacity:1}
.sidebar-foot{margin-top:auto;padding:14px 16px 18px;border-top:1px solid #1c2434;font-size:12px;color:#8b95a7}
.sidebar-foot .who{color:#e5e9f0;font-size:13px;margin-bottom:8px;display:flex;align-items:center;gap:8px}
.avatar{width:22px;height:22px;border-radius:50%;background:#25314a;display:grid;place-items:center;font-size:11px;color:#cfe0ff}
.sidebar-foot form{margin:0}
.sidebar-foot button.link{color:#9fb0c8}
.main{flex:1;min-width:0;display:flex;flex-direction:column}
.topbar{height:var(--topbar);display:flex;align-items:center;gap:14px;padding:0 24px;background:rgba(255,255,255,.86);backdrop-filter:saturate(1.2) blur(8px);border-bottom:1px solid var(--line);position:sticky;top:0;z-index:20}
.topbar h1{font-size:16px;font-weight:650}
.topbar .crumb{color:var(--muted);font-size:12.5px}
.topbar .spacer{flex:1}
.content{padding:20px 24px 40px;max-width:1440px;width:100%}
.banner{display:flex;gap:10px;align-items:flex-start;padding:10px 14px;border-radius:var(--radius);font-size:13px;margin-bottom:16px}
.banner.warn{background:var(--warn-soft);border:1px solid #f3ddb7;color:#7a4b06}
.banner.ok{background:var(--ok-soft);border:1px solid #c7e9d8;color:#0b6849}
.banner.bad{background:var(--bad-soft);border:1px solid #f6cfcb;color:#8f2620}

/* ---------- surfaces ---------- */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm)}
.card-pad{padding:16px 18px}
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:14px}
.section-title{display:flex;align-items:center;justify-content:space-between;margin:22px 0 10px}
.section-title h2{font-size:14px;color:var(--fg-2)}
.hr{height:1px;background:var(--line);margin:16px 0}

/* ---------- buttons ---------- */
.btn,button{font:inherit;display:inline-flex;align-items:center;justify-content:center;gap:6px;height:34px;padding:0 13px;border-radius:8px;border:1px solid var(--line-strong);background:var(--surface);color:var(--fg-2);cursor:pointer;white-space:nowrap;transition:background .12s,border-color .12s,color .12s,box-shadow .12s;text-decoration:none}
.btn:hover,button:hover{background:var(--surface-2);border-color:#c3c9d4;color:var(--fg);text-decoration:none}
.btn:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{outline:none;box-shadow:0 0 0 3px rgba(47,95,224,.18);border-color:var(--brand)}
.btn.primary,button.primary{background:var(--brand);border-color:var(--brand);color:#fff;box-shadow:0 1px 2px rgba(47,95,224,.35)}
.btn.primary:hover,button.primary:hover{background:var(--brand-hover);border-color:var(--brand-hover);color:#fff}
button.danger{color:var(--bad);border-color:#f1c7c3;background:#fff}
button.danger:hover{background:var(--bad-soft);border-color:#e9aaa4;color:var(--bad)}
button.link,.link{border:0;background:none;height:auto;padding:0 2px;color:var(--brand);font-size:13px}
button.link:hover{background:none;text-decoration:underline}
.btn.sm,button.sm{height:28px;padding:0 9px;font-size:12.5px;border-radius:6px}
button:disabled,.btn:disabled{opacity:.55;cursor:not-allowed}
button.is-loading{color:transparent !important;position:relative}
button.is-loading::after{content:"";position:absolute;width:14px;height:14px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:spin .7s linear infinite;color:#fff}
button:not(.primary).is-loading::after{color:var(--brand)}
@keyframes spin{to{transform:rotate(360deg)}}

/* ---------- forms ---------- */
label{display:block;font-size:12.5px;color:var(--fg-2);margin:0 0 6px}
input,select,textarea{font:inherit;width:100%;height:34px;padding:0 10px;border:1px solid var(--line-strong);border-radius:8px;background:#fff;color:var(--fg);transition:border-color .12s,box-shadow .12s}
textarea{height:auto;min-height:72px;padding:8px 10px;resize:vertical;line-height:1.5}
select{appearance:none;background-image:linear-gradient(45deg,transparent 50%,#8a93a3 50%),linear-gradient(135deg,#8a93a3 50%,transparent 50%);background-position:calc(100% - 15px) 14px,calc(100% - 10px) 14px;background-size:5px 5px;background-repeat:no-repeat;padding-right:28px}
input[type=checkbox]{width:15px;height:15px;accent-color:var(--brand);vertical-align:-2px}
input[type=datetime-local],input[type=date]{font-variant-numeric:tabular-nums}
.field{margin-bottom:12px}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.form-grid .full{grid-column:1/-1}
.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.hint{font-size:12px;color:var(--muted);margin-top:4px}

/* ---------- filters / toolbar ---------- */
.toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;padding:12px 14px;border-bottom:1px solid var(--line);background:var(--surface);border-radius:var(--radius) var(--radius) 0 0}
.toolbar .grow{flex:1}
.toolbar-break{flex:0 0 100%;height:0;margin:0}
#batch-bar{display:none;background:var(--brand-soft);border-top:1px solid var(--brand-line)}
#batch-bar.show{display:flex}
.search{position:relative;flex:1 1 260px;min-width:220px;max-width:380px}
.search input{padding-left:32px;background:#fff}
.search svg{position:absolute;left:10px;top:9px;width:15px;height:15px;color:var(--muted-2)}
.filters{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.filters select{width:auto;min-width:120px}
.filters input{width:auto;min-width:150px}
.chip{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 10px;border-radius:999px;border:1px solid var(--line-strong);background:#fff;font-size:12.5px;color:var(--fg-2);cursor:pointer}
.chip.on{background:var(--brand-soft);border-color:var(--brand-line);color:var(--brand)}
.chip input{display:none}

/* ---------- tables ---------- */
.table-wrap{overflow:auto;border-radius:0 0 var(--radius) var(--radius);max-height:calc(100vh - 300px)}
table{width:100%;border-collapse:separate;border-spacing:0;font-size:13.5px;background:var(--surface)}
thead th{position:sticky;top:0;z-index:2;background:#f8f9fb;color:var(--muted);font-weight:600;font-size:12px;letter-spacing:.02em;text-align:left;padding:10px 12px;border-bottom:1px solid var(--line);white-space:nowrap}
tbody td{padding:10px 12px;border-bottom:1px solid #f0f2f6;vertical-align:middle}
tbody tr:hover td{background:#fafcff}
tbody tr:last-child td{border-bottom:0}
td.num,th.num{text-align:right;font-variant-numeric:tabular-nums}
.cell-main{font-weight:600;color:var(--fg)}
.cell-sub{color:var(--muted);font-size:11.5px;margin-top:1px}
.actions{display:flex;gap:6px;justify-content:flex-end}
.actions button{height:26px;padding:0 8px;font-size:12px;border-radius:6px}

/* ---------- pills ---------- */
.pill{display:inline-flex;align-items:center;gap:6px;height:22px;padding:0 9px;border-radius:999px;font-size:12px;font-weight:600;white-space:nowrap}
.pill::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.85}
.pill.ok{background:var(--ok-soft);color:var(--ok)}
.pill.warn{background:var(--warn-soft);color:var(--warn)}
.pill.bad{background:var(--bad-soft);color:var(--bad)}
.pill.idle{background:var(--idle-soft);color:var(--idle)}
.tag{display:inline-block;padding:1px 7px;border-radius:6px;background:#f1f3f7;color:#5b6678;font-size:11.5px}

/* ---------- pager ---------- */
.pager{display:flex;gap:6px;align-items:center;padding:12px 14px;border-top:1px solid var(--line);font-size:12.5px;color:var(--muted);flex-wrap:wrap}
.pager a,.pager span.pg{display:inline-flex;align-items:center;height:28px;padding:0 10px;border:1px solid var(--line-strong);border-radius:7px;background:#fff;color:var(--fg-2);text-decoration:none}
.pager a:hover{border-color:var(--brand);color:var(--brand);text-decoration:none}
.pager .pg.off{opacity:.45}
.pager .pginfo{margin:0 8px;color:var(--muted)}
.pager .spacer{flex:1}

/* ---------- empty / skeleton ---------- */
.empty{padding:56px 20px;text-align:center;color:var(--muted)}
.empty .orb{width:52px;height:52px;border-radius:50%;margin:0 auto 12px;background:radial-gradient(circle at 30% 30%,#e9efff,#f4f6fb);border:1px solid #e3e8f3}
.empty b{display:block;color:var(--fg-2);font-size:14px;margin-bottom:4px}
.skeleton{padding:14px}
.skeleton i{display:block;height:12px;border-radius:6px;margin:10px 0;background:linear-gradient(90deg,#eef0f4 25%,#f6f7fa 37%,#eef0f4 63%);background-size:400% 100%;animation:shimmer 1.4s ease infinite}
@keyframes shimmer{0%{background-position:100% 0}100%{background-position:0 0}}
.htmx-request .skeleton{display:block}
.htmx-indicator{display:none}
.htmx-request .htmx-indicator{display:inline-flex}

/* ---------- dialogs ---------- */
dialog{border:0;border-radius:var(--radius-lg);padding:0;width:min(620px,calc(100vw - 32px));box-shadow:var(--shadow-lg);background:var(--surface);color:var(--fg)}
dialog::backdrop{background:rgba(15,21,34,.48);backdrop-filter:blur(2px)}
dialog .dlg-head{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--line)}
dialog .dlg-head h3{margin:0;font-size:15px}
dialog .dlg-body{padding:16px 20px}
dialog .dlg-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 var(--radius-lg) var(--radius-lg)}
dialog menu{display:flex;justify-content:flex-end;gap:8px;padding:12px 20px;margin:0;border-top:1px solid var(--line);background:var(--surface-2)}
pre.plain{white-space:pre-wrap;background:#0f1522;color:#dbe4f3;border-radius:10px;padding:12px 14px;font:12.5px/1.75 var(--mono);max-height:260px;overflow:auto}

/* ---------- auth ---------- */
.auth-wrap{min-height:100vh;display:grid;grid-template-columns:1.05fr .95fr;background:var(--surface)}
.auth-brand{position:relative;overflow:hidden;background:radial-gradient(1200px 600px at -10% -10%,#3d6ef0 0%,#1b2a52 55%,#0d1424 100%);color:#e8eefc;padding:56px 56px 44px;display:flex;flex-direction:column;justify-content:space-between}
.auth-brand .logo{display:flex;align-items:center;gap:12px;font-weight:650;font-size:15px;color:#fff}
.auth-brand h1{font-size:34px;line-height:1.25;margin:0 0 14px;color:#fff;letter-spacing:-.02em}
.auth-brand p{color:#a9b8d8;max-width:420px;margin:0 0 26px;font-size:14px}
.auth-brand ul{list-style:none;padding:0;margin:0;display:grid;gap:10px;max-width:420px}
.auth-brand li{display:flex;gap:10px;align-items:flex-start;font-size:13.5px;color:#c6d3ea}
.auth-brand li svg{flex:0 0 16px;margin-top:3px;color:#8fb0ff}
.auth-brand .foot{font-size:12px;color:#7f8db0}
.auth-panel{display:flex;align-items:center;justify-content:center;padding:32px}
.auth-card{width:100%;max-width:360px}
.auth-card h2{font-size:22px;margin-bottom:4px}
.auth-card .sub{color:var(--muted);font-size:13px;margin-bottom:22px}
.auth-card .field input{height:40px}
.auth-card button[type=submit]{width:100%;height:40px;margin-top:6px}
.auth-tip{margin-top:18px;font-size:12px;color:var(--muted);text-align:center}

/* ---------- toast ---------- */
#toast-root{position:fixed;right:18px;bottom:18px;display:flex;flex-direction:column;gap:8px;z-index:100}
.toast{min-width:240px;max-width:380px;display:flex;gap:10px;align-items:flex-start;padding:11px 13px;border-radius:10px;background:#111827;color:#f3f6fb;box-shadow:var(--shadow-lg);font-size:13px;animation:toast-in .18s ease-out}
.toast.ok{background:#0f6b4b}
.toast.bad{background:#a3251c}
.toast .close{margin-left:auto;background:none;border:0;color:inherit;opacity:.7;height:auto;padding:0 2px}
@keyframes toast-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}

/* ---------- detail ---------- */
.detail-grid{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(330px,.85fr);gap:14px;align-items:start}
.detail-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;flex-wrap:wrap;margin-bottom:14px}
.detail-no{font-size:22px;font-weight:700;letter-spacing:.02em}
.facts{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:2px 20px}
.facts>div{display:flex;flex-direction:column;gap:2px;padding:8px 0;border-bottom:1px dashed #eef0f5;min-width:0}
.facts .k{color:var(--muted);font-size:12px}
.facts .v{font-weight:600;font-size:13.5px;word-break:break-all}
@media(max-width:1100px){.detail-grid{grid-template-columns:1fr}}

/* ---------- misc ---------- */
.w-110{max-width:110px}
.mt-12{margin-top:12px}.mt-10{margin-top:10px}.mb-14{margin-bottom:14px}.ml-6{margin-left:6px}
.banner.mb-0-10{margin:0 0 10px}
.mb-0-10{margin:0 0 10px}
.th-check{width:34px}
.sel-status{width:auto;min-width:118px}
.sel-expiry{width:auto;min-width:130px}
.sel-action{width:auto;min-width:140px}
.inp-batch{width:170px;flex:0 0 170px}
dl{display:grid;grid-template-columns:1fr 1fr;gap:2px 18px;margin:0}
dl>div{display:flex;justify-content:space-between;gap:12px;padding:6px 0;border-bottom:1px dashed #eef0f5}
dl dt{color:var(--muted);font-size:12.5px}
dl dd{margin:0;font-weight:600;text-align:right;font-variant-numeric:tabular-nums}
dl.tight{grid-template-columns:1fr}
.stat{padding:16px 18px}
.stat .label{color:var(--muted);font-size:12.5px}
.stat .value{font-size:26px;font-weight:700;letter-spacing:-.02em;margin-top:2px;font-variant-numeric:tabular-nums}
.stat .meta{color:var(--muted-2);font-size:12px;margin-top:2px}
.stat.accent{background:linear-gradient(180deg,#f7faff,#fff);border-color:var(--brand-line)}
@media(max-width:900px){
  .shell{flex-direction:column}
  .sidebar{width:100%;flex:none;height:auto;position:static;flex-direction:row;align-items:center;gap:10px;padding:0 12px}
  .brand{padding:10px 0}
  .brand-text{display:none}
  .nav{flex-direction:row;overflow:auto;padding:6px 0}
  .sidebar-foot{margin:0 0 0 auto;border:0;padding:0}
  .sidebar-foot .who span.name{display:none}
  .content{padding:14px}
  .topbar{padding:0 14px}
  .form-grid{grid-template-columns:1fr}
  dl.kv{grid-template-columns:1fr}
  .auth-wrap{grid-template-columns:1fr}
  .auth-brand{display:none}
}
