:root, [data-theme="light"] {
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #eef1f4;
  --text: #1a2330; --text-dim: #5b6b7d; --border: #dde3ea;
  --accent: #0b6bcb; --accent-soft: #e3effb;
  --ok: #1a7f37; --ok-soft: #e2f5e9;
  --warn: #9a6700; --warn-soft: #fff3d6;
  --shadow: 0 1px 3px rgba(16,24,40,.08);
}
[data-theme="dark"] {
  --bg: #10151c; --surface: #1a212b; --surface-2: #232c38;
  --text: #e6ebf1; --text-dim: #94a3b5; --border: #2e3947;
  --accent: #4da3ff; --accent-soft: #16334f;
  --ok: #3fb950; --ok-soft: #12351c;
  --warn: #d29922; --warn-soft: #3a2d10;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
.brand { font-weight: 700; font-size: 17px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 6px 12px; border-radius: 8px; color: var(--text-dim); }
.topbar nav a.active, .topbar nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.user-chip { color: var(--text-dim); font-size: 13px; }
.user-chip .role { background: var(--accent-soft); color: var(--accent);
  padding: 2px 8px; border-radius: 99px; font-size: 12px; margin-left: 6px; }
#theme-toggle { background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px; cursor: pointer; color: var(--text); font-size: 14px; }

main { max-width: 1100px; margin: 0 auto; padding: 24px; }
footer { text-align: center; color: var(--text-dim); font-size: 12px; padding: 24px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px; margin-bottom: 28px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; box-shadow: var(--shadow); }
.card .num { font-size: 26px; font-weight: 700; }
.card .label { color: var(--text-dim); font-size: 13px; }

h2 { font-size: 16px; margin: 26px 0 10px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 18px; }
.panel .panel-head { padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; }
.panel .muted { color: var(--text-dim); font-weight: 400; font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 9px 16px; color: var(--text-dim); font-weight: 600;
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); background: var(--surface-2); }
td { padding: 9px 16px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.neutral { background: var(--surface-2); color: var(--text-dim); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.dim { color: var(--text-dim); }
.empty { padding: 28px; text-align: center; color: var(--text-dim); }

.login-wrap { display: flex; justify-content: center; padding-top: 10vh; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 36px; width: 400px; text-align: center; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card p { color: var(--text-dim); }
.ms-btn { display: inline-flex; align-items: center; gap: 10px; margin-top: 18px;
  background: var(--accent); color: #fff; padding: 10px 22px; border-radius: 9px; font-weight: 600; }
.ms-btn:hover { text-decoration: none; filter: brightness(1.08); }
.error-box { background: var(--warn-soft); color: var(--warn); border-radius: 9px;
  padding: 10px 14px; margin-top: 16px; font-size: 14px; }
.setup-box { background: var(--surface-2); border-radius: 9px; padding: 14px;
  margin-top: 16px; text-align: left; font-size: 13px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 24px; padding: 14px 16px; }
.meta-grid .k { color: var(--text-dim); font-size: 12px; text-transform: uppercase; }

/* settings */
.settings-wrap { display: flex; gap: 22px; align-items: flex-start; }
.settings-side { width: 190px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 10px; }
.settings-side .side-title { font-weight: 700; padding: 6px 10px 10px; color: var(--text-dim);
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.settings-side a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--text); }
.settings-side a.active, .settings-side a:hover { background: var(--accent-soft);
  color: var(--accent); text-decoration: none; }
.settings-content { flex: 1; min-width: 0; }
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.subnav a { padding: 8px 14px; color: var(--text-dim); border-bottom: 2px solid transparent; }
.subnav a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.subnav a:hover { text-decoration: none; color: var(--text); }
.settings-fields { padding: 6px 16px 16px; }
.field-row { margin-top: 14px; }
.field-row label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.field-row input { width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 14px; }
.field-row input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field-help { color: var(--text-dim); font-size: 12px; margin-top: 4px; }
.saved-box { background: var(--ok-soft); color: var(--ok); border-radius: 9px;
  padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
