@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #0e1216;
  --surface: #151b21;
  --surface-raised: #1c242c;
  --surface-hover: #202a33;
  --border: #29323b;
  --border-strong: #3a4753;
  --text: #e7ebef;
  --text-secondary: #9aa7b2;
  --text-muted: #61707c;
  --accent: #4fb8d6;
  --accent-strong: #7dd0e8;
  --accent-contrast: #06232b;
  --status-good: #5fbe8b;
  --status-good-bg: rgba(95, 190, 139, 0.14);
  --status-warn: #d9a253;
  --status-warn-bg: rgba(217, 162, 83, 0.16);
  --status-bad: #d9695c;
  --status-bad-bg: rgba(217, 105, 92, 0.15);
  --status-neutral: #8b98a3;
  --status-neutral-bg: rgba(139, 152, 163, 0.14);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f1f4f6; --surface: #fff; --surface-raised: #f6f9fa; --surface-hover: #edf1f3;
    --border: #dce2e6; --border-strong: #c4ccd2;
    --text: #1b2226; --text-secondary: #4e5a62; --text-muted: #7c8890;
    --accent: #197b93; --accent-strong: #0f6379; --accent-contrast: #fff;
    --status-good: #2e9a63; --status-good-bg: rgba(46, 154, 99, 0.12);
    --status-warn: #a86c17; --status-warn-bg: rgba(168, 108, 23, 0.13);
    --status-bad: #bb4531; --status-bad-bg: rgba(187, 69, 49, 0.12);
    --status-neutral: #62707c; --status-neutral-bg: rgba(98, 112, 124, 0.12);
  }
}
:root[data-theme="light"] {
  --bg: #f1f4f6; --surface: #fff; --surface-raised: #f6f9fa; --surface-hover: #edf1f3;
  --border: #dce2e6; --border-strong: #c4ccd2;
  --text: #1b2226; --text-secondary: #4e5a62; --text-muted: #7c8890;
  --accent: #197b93; --accent-strong: #0f6379; --accent-contrast: #fff;
  --status-good: #2e9a63; --status-good-bg: rgba(46, 154, 99, 0.12);
  --status-warn: #a86c17; --status-warn-bg: rgba(168, 108, 23, 0.13);
  --status-bad: #bb4531; --status-bad-bg: rgba(187, 69, 49, 0.12);
  --status-neutral: #62707c; --status-neutral-bg: rgba(98, 112, 124, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.mono { font-family: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace; font-variant-numeric: tabular-nums; }
a { color: inherit; }
button { font-family: inherit; }
h1, h2, h3 { text-wrap: balance; }

.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 18px; font-weight: 600; font-size: 15px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 5px; background: var(--accent); color: var(--accent-contrast);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none;
}
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px;
  color: var(--text-secondary); text-decoration: none; font-size: 13.5px; font-weight: 500;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
}
.nav-item svg { width: 16px; height: 16px; flex: none; opacity: 0.8; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--surface-hover); color: var(--text); }
.nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 600; background: var(--status-warn-bg); color: var(--status-warn);
  border-radius: 20px; padding: 1px 7px; font-family: 'IBM Plex Mono', monospace;
}
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.admin-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface-raised); border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--text-secondary); flex: none;
}
.admin-name { font-size: 12.5px; font-weight: 500; }
.admin-role { font-size: 11px; color: var(--text-muted); }
.icon-btn {
  margin-left: auto; width: 26px; height: 26px; border-radius: 6px; border: 1px solid transparent;
  background: none; color: var(--text-muted); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; }

.main { padding: 28px 32px 60px; max-width: 1180px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.page-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; padding: 7px 13px;
  border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; line-height: 1.2; text-decoration: none;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { color: var(--status-bad); border-color: var(--status-bad); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn:focus-visible, .nav-item:focus-visible, .icon-btn:focus-visible, a:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

section { margin-bottom: 34px; }
.section-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.section-head h2 { font-size: 13px; font-weight: 600; margin: 0; }
.section-count { font-size: 12px; color: var(--text-muted); }

.attn-list { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.attn-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; flex-wrap: wrap; }
.attn-row:last-child { border-bottom: none; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot-warn { background: var(--status-warn); }
.dot-bad { background: var(--status-bad); }
.attn-what { font-weight: 500; }
.attn-who { color: var(--text-muted); }
.attn-meta { margin-left: auto; color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
.attn-action { color: var(--accent); font-size: 12.5px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.attn-action:hover { text-decoration: underline; }
.empty-note { color: var(--text-muted); font-size: 13px; padding: 14px; }

.table-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
thead th { text-align: left; font-weight: 500; color: var(--text-muted); font-size: 11.5px; padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
thead th a:hover { color: var(--text); }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-hover); }
.cell-app { font-weight: 500; }
.cell-client { color: var(--text-secondary); }
.cell-muted { color: var(--text-muted); }
.row-link { display: block; color: inherit; text-decoration: none; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; }
.badge-good { background: var(--status-good-bg); color: var(--status-good); }
.badge-warn { background: var(--status-warn-bg); color: var(--status-warn); }
.badge-bad { background: var(--status-bad-bg); color: var(--status-bad); }
.badge-neutral { background: var(--status-neutral-bg); color: var(--status-neutral); }

.filters { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.chip { font-size: 12.5px; font-weight: 500; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); cursor: pointer; text-decoration: none; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.search { margin-left: auto; display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; background: var(--surface); min-width: 220px; }
.search svg { width: 14px; height: 14px; color: var(--text-muted); flex: none; }
.search input { border: none; background: none; color: var(--text); font-size: 13px; width: 100%; outline: none; }
.search input::placeholder { color: var(--text-muted); }

.pagination { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 14px; font-size: 12.5px; }
.pagination a, .pagination span { padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border); color: var(--text-secondary); text-decoration: none; }
.pagination a:hover { border-color: var(--border-strong); color: var(--text); }
.pagination .current { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12.5px; text-decoration: none; margin-bottom: 14px; }
.back-link:hover { color: var(--text); }
.back-link svg { width: 13px; height: 13px; }

.detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.detail-head h1 { font-size: 21px; margin: 0; font-weight: 600; }
.detail-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }

.notice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--status-warn); background: var(--status-warn-bg); border-radius: 8px; padding: 12px 14px; font-size: 13px; margin-bottom: 22px; }
.notice svg { width: 16px; height: 16px; color: var(--status-warn); flex: none; margin-top: 1px; }
.notice-meta { color: var(--text-secondary); font-size: 12px; margin-top: 3px; }
.notice-actions { margin-top: 8px; }

.detail-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
.panel { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 18px; }
.panel + .panel { margin-top: 20px; }
.panel h3 { font-size: 12.5px; font-weight: 600; margin: 0 0 14px; color: var(--text-secondary); }

.field-list { display: flex; flex-direction: column; gap: 0; }
.field-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.field-row:last-child { border-bottom: none; }
.field-label { color: var(--text-muted); flex: none; }
.field-value { text-align: right; }
.key-row { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.copy-btn { border: 1px solid var(--border-strong); background: var(--surface-raised); color: var(--text-secondary); border-radius: 5px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.copy-btn:hover { color: var(--text); }
.copy-btn svg { width: 12px; height: 12px; }

textarea, input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: 6px; color: var(--text);
  font-family: inherit; font-size: 13px; padding: 9px 11px; width: 100%;
}
textarea { min-height: 64px; resize: vertical; }
label { display: block; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 5px; font-weight: 500; }
.field { margin-bottom: 14px; }
.field-hint { color: var(--text-muted); font-size: 11.5px; margin-top: 4px; }
.note-actions { display: flex; justify-content: flex-end; margin-top: 10px; }

.renew-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.renew-custom { display: flex; gap: 8px; align-items: center; }
.renew-custom input { width: 64px; font-family: 'IBM Plex Mono', monospace; }
.renew-custom span { font-size: 12.5px; color: var(--text-muted); }

.history-row { font-size: 12.5px; }
.history-result-ok { color: var(--status-good); }
.history-result-new { color: var(--status-warn); font-weight: 600; }
.history-result-bad { color: var(--status-bad); }

.form-card { max-width: 560px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.radio-group { display: flex; gap: 10px; }
.radio-option { flex: 1; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; cursor: pointer; }
.radio-option input { width: auto; margin-right: 8px; }
.error-banner { background: var(--status-bad-bg); border: 1px solid var(--status-bad); color: var(--status-bad); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 18px; }

/* Auth / setup shell */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 32px; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; margin-bottom: 22px; }
.auth-card h1 { font-size: 18px; margin: 0 0 6px; }
.auth-sub { color: var(--text-muted); font-size: 12.5px; margin-bottom: 22px; }
.setup-steps { display: flex; gap: 6px; margin-bottom: 22px; }
.setup-step { flex: 1; height: 3px; border-radius: 2px; background: var(--border); }
.setup-step.done, .setup-step.current { background: var(--accent); }

[hidden] { display: none !important; }

.nav-overlay { display: none; }
.menu-toggle { display: none; }
.topbar { display: none; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 234px; transform: translateX(-100%); transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1); z-index: 40; box-shadow: 0 8px 28px rgba(2, 6, 10, 0.45); }
  body[data-nav-open="true"] .sidebar { transform: translateX(0); }
  .nav-overlay { position: fixed; inset: 0; background: rgba(4, 8, 12, 0.5); z-index: 30; }
  body[data-nav-open="true"] .nav-overlay { display: block; }
  .main { padding: 18px 16px 48px; }
  .topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
  .menu-toggle { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; }
  .menu-toggle svg { width: 16px; height: 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .search { min-width: 0; width: 100%; margin-left: 0; }
  .form-grid-2 { grid-template-columns: 1fr; }
}
