:root {
  --paper: #FFF6E9; --surface: #FFFFFF; --well: #F3E7D6; --ink: #2B2118; --ink-soft: #7A6A5C;
  --outline: #2B2118; --muted: #B9A995; --brand: #FF8A1F; --brand-deep: #E8650A; --stamp: #F2553F;
  --green: #2DBE7E; --yellow: #FFC93C; --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--paper); color: var(--ink); }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
.sub { color: var(--ink-soft); margin: 0 0 16px; }
a { color: var(--brand-deep); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: grid; gap: 12px; }
.brand { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--brand); border: 2px solid var(--outline); }

#app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.nav { background: var(--surface); border-right: 2px solid var(--outline); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.nav nav { display: grid; gap: 4px; }
.nav nav a { text-decoration: none; color: var(--ink); padding: 8px 12px; border-radius: 10px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.nav nav a:hover { background: var(--well); }
.nav nav a.active { background: var(--brand); border: 2px solid var(--outline); padding: 6px 10px; }
.me { margin-top: auto; display: flex; gap: 10px; align-items: center; color: var(--ink-soft); flex-wrap: wrap; }
main { padding: 28px 32px 60px; max-width: 1280px; width: 100%; overflow-x: auto; }

.card { background: var(--surface); border: 2px solid var(--outline); border-radius: var(--radius); padding: 18px; box-shadow: 0 3px 0 var(--outline); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat .k { color: var(--ink-soft); font-size: 13px; }
.stat .v { font-size: 26px; font-weight: 800; }

.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }

label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 2px solid var(--muted); border-radius: 10px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand-deep); }
.check { display: flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 500; }

.btn { font: inherit; font-weight: 700; border: 2px solid var(--outline); border-radius: 10px; padding: 7px 14px; background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: 0 2px 0 var(--outline); white-space: nowrap; }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.primary { background: var(--brand); }
.btn.danger { background: var(--stamp); color: #fff; }
.btn.small { padding: 3px 9px; font-size: 12px; box-shadow: 0 1px 0 var(--outline); }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: none; color: var(--brand-deep); cursor: pointer; font: inherit; padding: 0; }

table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 2px solid var(--outline); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--well); vertical-align: top; }
th { background: var(--well); font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.inactive td { color: var(--muted); }
tfoot td { font-weight: 800; background: #FFF9F0; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1.5px solid var(--outline); background: var(--well); margin: 1px 2px 1px 0; }
.tag.ok { background: #C9F2DE; } .tag.warn { background: #FFE9A8; } .tag.bad { background: #FFD0C8; } .tag.brand { background: var(--brand); }
.badge { background: var(--stamp); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }
.warn-text { color: #B4540A; font-size: 12px; }
.error { color: var(--stamp); min-height: 1em; margin: 0; }
.muted { color: var(--ink-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

dialog { border: 2px solid var(--outline); border-radius: var(--radius); padding: 0; width: min(720px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 6px 0 var(--outline); }
dialog::backdrop { background: rgba(43, 33, 24, .45); }
#dialog-form { padding: 20px; display: grid; gap: 12px; max-height: 85vh; overflow: auto; }
#dialog-form h3 { margin: 0; font-size: 18px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.module-row { display: grid; grid-template-columns: 1.4fr .8fr 1fr 2fr auto; gap: 6px; align-items: center; }
.password-box { font: 700 20px ui-monospace, Menlo, monospace; background: var(--well); border: 2px dashed var(--outline); padding: 10px 14px; border-radius: 10px; user-select: all; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 600; z-index: 99; }
.toast.err { background: var(--stamp); }

@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; border-right: none; border-bottom: 2px solid var(--outline); }
  .nav nav { grid-template-columns: repeat(2, 1fr); }
  main { padding: 16px; }
  .grid2, .grid3, .module-row { grid-template-columns: 1fr; }
}
