:root {
  --ink: #152238;
  --muted: #68758b;
  --line: #dfe5ee;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --navy: #0b1830;
  --navy-2: #132542;
  --blue: #2563eb;
  --blue-soft: #e8efff;
  --teal: #0f8f83;
  --teal-soft: #e2f6f2;
  --amber: #b7791f;
  --amber-soft: #fff4dc;
  --red: #c2414b;
  --red-soft: #ffe9eb;
  --shadow: 0 10px 30px rgba(21, 34, 56, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 4px; color: #7f8da4; font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(25px, 3vw, 34px); line-height: 1.15; letter-spacing: -.03em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(37, 99, 235, .35), transparent 38%),
    radial-gradient(circle at 80% 0%, rgba(15, 143, 131, .25), transparent 36%),
    var(--navy);
}
.login-card {
  width: min(440px, 100%);
  padding: 38px;
  border-radius: 24px;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .3);
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #0f8f83);
  font-weight: 900;
  letter-spacing: -.05em;
}
.login-card .brand-mark { margin-bottom: 18px; }
.login-card form { display: grid; gap: 14px; margin-top: 22px; }
label { display: grid; gap: 6px; color: #39475e; font-weight: 650; }
label.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: #39475e;
}
label.check-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 18px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid #cfd8e6;
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea { min-height: 82px; resize: vertical; }
.error-text { min-height: 20px; margin: 0; color: var(--red); font-size: 13px; }
.link-button { margin-top: 16px; border: 0; color: var(--blue); background: transparent; padding: 0; font-weight: 700; }

.app-view { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--navy), #091426);
  color: #dbe6ff;
  z-index: 20;
}
.brand-row { display: flex; align-items: center; gap: 12px; padding: 4px 10px 16px; }
.brand-row small { display: block; color: #8fa4ca; font-size: 12px; letter-spacing: .08em; }
.side-nav { display: grid; gap: 8px; min-height: 0; flex: 1; overflow-y: auto; padding-right: 2px; }
.nav-group { display: grid; gap: 3px; }
.nav-group-title {
  padding: 0 12px 3px;
  color: #6f86ad;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.nav-link, .mobile-link {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  color: #b8c8e7;
  background: transparent;
  text-align: left;
  padding: 9px 12px;
  border-radius: 10px;
  font-weight: 650;
  text-decoration: none;
}
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(94, 139, 255, .18); }
.nav-icon { width: 22px; text-align: center; opacity: .9; }
.nav-sheet { display: grid; gap: 18px; }
.nav-sheet-group { display: grid; gap: 4px; }
.nav-sheet a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
}
.nav-sheet a:hover { background: var(--blue-soft); color: #2454b5; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; color: #8fa4ca; font-size: 12px; padding: 16px 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #2ed3b7; box-shadow: 0 0 0 4px rgba(46, 211, 183, .12); }
.main { margin-left: 248px; padding: 24px 30px 50px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.user-chip { padding: 7px 11px; border-radius: 999px; background: var(--blue-soft); color: #234ca8; font-size: 12px; font-weight: 750; }
.page-content { display: grid; gap: 18px; }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 750;
  background: #eef2f8;
  color: #2a3a53;
}
.btn:hover { filter: brightness(.98); }
.btn.primary { color: #fff; background: var(--blue); }
.btn.danger { color: var(--red); background: var(--red-soft); }
.btn.success { color: #087467; background: var(--teal-soft); }
.btn.ghost { background: transparent; border-color: var(--line); color: #42536c; }
.btn.small { padding: 6px 9px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.grid { display: grid; gap: 16px; }
.grid.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 4px 16px rgba(21, 34, 56, .035);
}
.metric-card { display: grid; gap: 6px; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 650; }
.metric-value { font-size: 30px; line-height: 1.05; font-weight: 850; letter-spacing: -.04em; }
.metric-note { color: var(--muted); font-size: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 2px 0 0; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; background: #fff; }
th, td { padding: 12px 13px; border-bottom: 1px solid #edf1f6; text-align: left; vertical-align: top; }
th { color: #617089; background: #f7f9fc; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
td { font-size: 14px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; background: #edf2f8; color: #4d5d75; font-size: 12px; font-weight: 800; white-space: nowrap; }
.pill.published, .pill.success, .pill.active { color: #087467; background: var(--teal-soft); }
.pill.testing, .pill.draft { color: #2659b5; background: var(--blue-soft); }
.pill.failed, .pill.offline, .pill.revoked { color: var(--red); background: var(--red-soft); }
.pill.warning { color: var(--amber); background: var(--amber-soft); }
.bar { height: 8px; border-radius: 999px; background: #edf1f6; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--teal)); }
.empty-state { padding: 32px; text-align: center; color: var(--muted); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #edf1f6; }
.list-row:last-child { border-bottom: 0; }
.mobile-cards { display: none; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8, 18, 35, .55); z-index: 60;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: min(720px, 100%); max-height: 90vh; overflow: auto;
  border-radius: 20px; background: #fff; box-shadow: 0 30px 90px rgba(0, 0, 0, .28);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 12px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 8px 22px 22px; }
.modal-close { border: 0; background: #edf2f8; border-radius: 9px; width: 34px; height: 34px; font-size: 19px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 16px; }

.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast { padding: 12px 15px; border-radius: 11px; color: #fff; background: #1d2e4a; box-shadow: var(--shadow); max-width: 360px; }
.toast.error { background: var(--red); }
.toast.success { background: #087467; }

.mobile-nav { display: none; }
.inline-note { padding: 12px 14px; border-radius: 12px; background: var(--blue-soft); color: #2b4d93; font-size: 13px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: #fff; color: #53637b; border-radius: 999px; padding: 8px 12px; font-weight: 700; }
.tab.active { border-color: var(--blue); color: #fff; background: var(--blue); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters > * { max-width: 240px; }
.drawer-label { display: grid; gap: 4px; }

@media (max-width: 1080px) {
  .grid.metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 18px 16px 92px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  .grid.two { grid-template-columns: 1fr; }
  .mobile-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; gap: 2px; overflow-x: auto; padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .98); border-top: 1px solid var(--line); backdrop-filter: blur(12px);
  }
  .mobile-link { min-width: 64px; flex-direction: column; gap: 2px; padding: 6px 8px; text-align: center; font-size: 12px; border-radius: 10px; color: #65738a; }
  .mobile-link.active { background: var(--blue-soft); color: #2454b5; }
  .mobile-link .nav-icon { font-size: 18px; }
  .mobile-cards { display: grid; gap: 10px; }
  .table-wrap { display: none; }
  .mobile-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 8px; }
  .mobile-card .card-title { font-weight: 800; }
  .mobile-card .kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
  .mobile-card .kv strong { color: var(--ink); font-weight: 650; text-align: right; }
  .form-grid { grid-template-columns: 1fr; }
  .top-actions #help-toggle { display: none; }
}

@media (max-width: 520px) {
  .grid.metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-value { font-size: 24px; }
  .card { padding: 15px; }
  .login-card { padding: 28px 22px; }
  .top-actions .btn { padding: 8px 10px; font-size: 12px; }
}
