:root {
  --bg: #f5f6f8; --panel: #fff; --line: #e4e6eb; --text: #1d2129; --muted: #6b7280;
  --accent: #2563eb; --accent-soft: #e8efff; --ok: #15803d; --ok-soft: #e7f6ec;
  --warn: #b45309; --warn-soft: #fdf3e2; --bad: #b91c1c; --bad-soft: #fdeaea;
  --radius: 8px; --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text); background: var(--bg); display: flex; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; }

.side { width: 200px; flex: none; background: #111827; color: #d1d5db; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 16px; padding: 20px 18px; color: #fff; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, #f58529, #dd2a7b, #515bd4); }
nav a { display: block; padding: 9px 18px; color: #d1d5db; border-left: 3px solid transparent; }
nav a:hover { background: #1f2937; }
nav a.on { background: #1f2937; color: #fff; border-left-color: #60a5fa; }
nav .sep { font-size: 12px; color: #6b7280; padding: 14px 18px 4px; }
.side-foot { margin-top: auto; padding: 16px 18px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.side-foot .link { color: #9ca3af; text-align: left; }

main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
h1 { font-size: 20px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.bar .grow { flex: 1; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel.pad { padding: 16px; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c7cbd3; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 8px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: #fafbfc; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
.tablewrap { overflow-x: auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #f1f2f4; color: #4b5563; white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.blue { background: var(--accent-soft); color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
h2 { font-size: 15px; margin: 0 0 10px; }

/* daily */
.daily td { padding: 6px 6px; }
.daily input, .daily select { width: 100%; padding: 4px 6px; }
.daily .w60 { width: 64px; } .daily .w80 { width: 86px; }
.daily textarea { width: 100%; min-width: 160px; height: 32px; padding: 4px 6px; }
.daily tr.saved { background: #f6fbf7; }
.daily tr.dirty { background: #fffbeb; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }

/* dialog */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(640px, 94vw); max-height: 90vh; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(17,24,39,.45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dlg-head h3 { margin: 0; font-size: 16px; }
.dlg-body { padding: 16px 18px; overflow-y: auto; max-height: calc(90vh - 120px); }
.dlg-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form label.full { grid-column: 1 / -1; }
.form input, .form select, .form textarea { color: var(--text); }
.kv { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px 10px; align-items: center; }
.kv .v { font-family: var(--mono); word-break: break-all; }

.code-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; display: flex; gap: 14px; align-items: center; }
.code-item .code { font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: 3px; color: var(--accent); min-width: 130px; }
.code-item .code.none { font-size: 13px; letter-spacing: 0; color: var(--muted); font-weight: 400; }
.code-item .meta { flex: 1; min-width: 0; }
.code-item .meta div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-item.fresh { border-color: var(--accent); background: #f8faff; }

#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #111827; color: #fff;
  padding: 8px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 99; }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); }

.login-body { align-items: center; justify-content: center; background: #111827; }
.login-card { width: 320px; background: #fff; border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { color: var(--text); padding: 0 0 6px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input { padding: 8px 10px; }
.login-card .btn { padding: 9px; }
.err { color: var(--bad); margin: 0; min-height: 1.5em; font-size: 13px; }

@media (max-width: 760px) {
  body { flex-direction: column; }
  .side { width: auto; height: auto; position: static; }
  nav { display: flex; overflow-x: auto; } nav a { border-left: 0; white-space: nowrap; } nav .sep { display: none; }
  .side-foot { flex-direction: row; gap: 12px; padding: 8px 18px; }
  main { padding: 16px; }
  .form { grid-template-columns: 1fr; }
}
