:root {
  --ink: #14242B; --ink-2: #3D4D53; --muted: #4B5B61; --line: #DCE2DF; --line-2: #E4E9E6;
  --bg: #F5F6F3; --card: #FFFFFF; --teal: #1D6B74; --teal-d: #124A51; --teal-l: #DCEBEA;
  --amber: #E3A33B; --amber-l: #FBEBD0; --red: #B3261E; --red-l: #FBE9E7; --green: #2E7D4F; --green-l: #E3F1E8;
  --radius: 12px;
  font-family: Figtree, 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  color: var(--ink); font-size: 16px; line-height: 1.55;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--teal); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.boot { display: grid; place-items: center; min-height: 100vh; font-weight: 700; font-size: 24px; color: var(--teal); }
[hidden] { display: none !important; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--teal); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-d); }
.btn.danger { color: var(--red); border-color: #E8C4C0; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.link { border: 0; background: none; color: var(--teal); padding: 0 4px; min-height: 36px; }
.btn[disabled] { opacity: .6; cursor: progress; }

/* Auth screens */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 32px; box-shadow: 0 18px 40px rgba(20,36,43,.08); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; text-decoration: none; color: var(--ink); }
.auth-card h1 { font-size: 24px; margin: 24px 0 6px; }
.auth-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 15px; }
.auth-foot { margin-top: 18px; font-size: 14px; color: var(--muted); text-align: center; }
.lang-switch { display: inline-flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang-switch button { border: 0; background: var(--card); padding: 6px 10px; font-size: 13px; font-weight: 600; cursor: pointer; min-height: 34px; }
.lang-switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.field input, .field select, .field textarea { font-weight: 400; font-size: 16px; padding: 10px 12px; min-height: 46px;
  border: 1.5px solid #C9D1CE; border-radius: 9px; background: #fff; width: 100%; }
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px var(--teal-l); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--teal); }
.msg { padding: 10px 14px; border-radius: 9px; font-size: 14px; }
.msg.error { background: var(--red-l); color: var(--red); }
.msg.ok { background: var(--green-l); color: var(--green); }
fieldset.group { border: 1px solid var(--line-2); border-radius: 12px; padding: 14px; margin: 0; }
fieldset.group legend { font-weight: 700; font-size: 14px; padding: 0 6px; }

/* App shell */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--ink); color: #DCE6E8; padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.side .brand { color: #fff; padding: 0 8px 14px; }
.side .org { font-size: 13px; color: #A9BCC0; padding: 0 8px 16px; border-bottom: 1px solid #2A3D44; margin-bottom: 8px; }
.side .org b { display: block; color: #fff; font-size: 15px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; color: #DCE6E8; text-decoration: none; font-weight: 500; }
.nav a:hover { background: #22363E; }
.nav a[aria-current="page"] { background: var(--teal); color: #fff; }
.nav a svg { flex: none; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 8px; font-size: 14px; }
.side-foot .who { color: #A9BCC0; }
.side-foot .who b { color: #fff; display: block; }
.side-foot .btn { background: transparent; color: #DCE6E8; border-color: #3A4F57; }
.side-foot .lang-switch { align-self: flex-start; border-color: #3A4F57; }
.side-foot .lang-switch button { background: transparent; color: #DCE6E8; }
.side-foot .lang-switch button[aria-pressed="true"] { background: #FFFFFF; color: var(--ink); }
.main { padding: 28px 32px 60px; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 26px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.topbar { display: none; }

/* Cards & tables */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat .k { color: var(--muted); font-size: 14px; }
.stat .v { font-size: 30px; font-weight: 700; }
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 12px 14px; background: #FAFBFA; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #F7FAF9; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--teal-l); color: var(--teal-d); white-space: nowrap; }
.pill.amber { background: var(--amber-l); color: #7A5208; }
.pill.grey { background: #ECEFEE; color: var(--muted); }
.pill.red { background: var(--red-l); color: var(--red); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type="search"] { min-height: 42px; padding: 0 12px; border: 1.5px solid #C9D1CE; border-radius: 9px; min-width: 220px; background: #fff; }
h2.section { font-size: 18px; margin: 28px 0 10px; }
.cat-title { font-size: 15px; font-weight: 700; margin: 22px 0 8px; color: var(--teal-d); }

/* Checklist */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 12px; }
.steps .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #ECEFEE; font-size: 13px; font-weight: 700; flex: none; }
.steps .done .dot { background: var(--green); color: #fff; }

/* Drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(20,36,43,.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--card); z-index: 41; display: flex; flex-direction: column; box-shadow: -18px 0 40px rgba(20,36,43,.15); }
.drawer header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer header h2 { margin: 0; font-size: 20px; }
.drawer .body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.drawer .body > * { flex-shrink: 0; }
.drawer footer { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; padding: 14px 22px; border-top: 1px solid var(--line); }
.drawer footer .right { display: flex; gap: 10px; margin-left: auto; }
.icon-btn { width: 40px; height: 40px; border-radius: 9px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--bg); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; }
#toast .t { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-weight: 500; }
#toast .t.error { background: var(--red); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0 30% 0 0; z-index: 50; height: auto; }
  .shell.menu-open .side { display: flex; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 30; }
  .topbar .brand { color: #fff; font-size: 18px; }
  .topbar .icon-btn { color: #fff; }
  .topbar .icon-btn:hover { background: #22363E; }
  .main { padding: 20px 16px 48px; }
  .grid2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
/* Compact sidebar: scrolls on short screens, footer always visible, set-up pages folded away */
.side { gap: 4px; padding: 16px 12px; }
.side .brand { padding-bottom: 10px; }
.side .org { padding-bottom: 12px; margin-bottom: 4px; }
.side .nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: 8px 12px; }
.nav-group summary { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 9px; cursor: pointer; list-style: none; color: #A9BCC0; font-weight: 500; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary:hover { background: #22363E; }
.nav-group summary .chev { margin-left: auto; transition: transform .15s; font-size: 18px; line-height: 1; }
.nav-group[open] summary .chev { transform: rotate(90deg); }
.nav-group a { padding-left: 22px; font-size: 15px; }
.side-foot { flex-shrink: 0; gap: 8px; padding: 10px 8px 4px; border-top: 1px solid #2A3D44; }
.side-foot .who { font-size: 13px; overflow-wrap: anywhere; }
.side-foot .row { display: flex; gap: 8px; align-items: center; }
.side-foot .row .btn { flex: 1; min-height: 36px; }
/* User guide */
.side-foot .help-link { display: flex; align-items: center; gap: 10px; padding: 8px 4px; color: #DCE6E8; text-decoration: none; font-weight: 500; border-radius: 8px; }
.side-foot .help-link:hover, .side-foot .help-link[aria-current="page"] { color: #fff; background: #22363E; }
.help-tabs { border-color: #C9D1CE; }
.help-tabs button { min-height: 40px; padding: 0 14px; }
.help-topic { padding: 0; }
.help-topic summary { cursor: pointer; padding: 18px 22px; font-size: 18px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.help-topic summary::-webkit-details-marker { display: none; }
.help-topic summary::after { content: '+'; color: var(--teal); font-size: 22px; line-height: 1; }
.help-topic[open] summary::after { content: '−'; }
.help-topic > :not(summary) { margin-left: 22px; margin-right: 22px; }
.help-intro { margin-top: 0; color: var(--ink-2); }
.help-steps { padding-left: 22px; display: flex; flex-direction: column; gap: 8px; margin-top: 0; }
.help-steps li { padding-left: 4px; }
.help-tips { background: var(--teal-l); color: var(--teal-d); border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; font-size: 15px; }
.help-tips ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.help-topic > ol:last-child { margin-bottom: 20px; }
