:root {
  color-scheme: light;
  --bg: #ffffff;
  --subtle: #f7f7f9;
  --hover: #f1f1f4;
  --line: #e6e6eb;
  --line-strong: #d4d4dc;
  --text: #17171c;
  --muted: #676773;
  --faint: #8f8f9b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eeedfd;
  --green: #137a4b;
  --green-soft: #e7f6ee;
  --amber: #96600a;
  --amber-soft: #fdf3dc;
  --red: #c02b3c;
  --red-soft: #fdecee;
  --radius: 10px;
  --sidebar: 256px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.3; font-weight: 650; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -.005em; margin: 0; }
p { margin: 0; }
code, .code { font: 12.5px ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Shell */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--bg); padding: 18px 12px 12px;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; color: var(--text); font-weight: 650; font-size: 15.5px; letter-spacing: -.015em; }
.logo:hover { text-decoration: none; }
.logo img { width: 32px; height: 32px; display: block; }
.nav { flex: 1; overflow-y: auto; }
.nav-label { padding: 14px 10px 5px; font-size: 11.5px; font-weight: 550; color: var(--faint); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin-bottom: 1px;
  border-radius: 8px; color: var(--muted); font-weight: 500;
}
.nav a svg { width: 17px; height: 17px; flex: none; }
.nav a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.account { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 12px 8px 2px; margin-top: 8px; }
.avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--hover); font-weight: 600; font-size: 13px; }
.account-text { flex: 1; min-width: 0; line-height: 1.3; }
.account-text b { display: block; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-text span { font-size: 12px; color: var(--muted); }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; background: none; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: var(--hover); color: var(--text); }
.icon-button svg { width: 17px; height: 17px; }
.main { min-width: 0; padding: 32px 40px 56px; }
.content { max-width: 1160px; margin: 0 auto; }
.mobile-bar, #nav-toggle, .nav-backdrop { display: none; }

/* Page furniture */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 680px; }
.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; }
.notice { border-radius: 8px; padding: 10px 14px; margin-bottom: 18px; background: var(--subtle); border: 1px solid var(--line); }
.notice.flash { background: var(--green-soft); border-color: #c4e9d5; color: #0e5c39; }
.notice.error { background: var(--red-soft); border-color: #f6cdd2; color: #94202e; }
.notice.warn { background: var(--amber-soft); border-color: #f3dfae; color: #754b08; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; }

/* Metrics */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 28px; overflow: hidden; }
.metric { padding: 16px 20px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.metric span { display: block; color: var(--muted); font-size: 12.5px; }
.metric b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* Status list */
.checks { border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: hidden; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; color: inherit; }
a.check:hover { background: var(--subtle); text-decoration: none; }
.check b { display: block; font-weight: 550; }
.check span.detail { display: block; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 7px; background: var(--faint); }
.dot.ok { background: #1fa268; }
.dot.warn { background: #e0a019; }
.dot.fail { background: #dc3548; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 550; color: var(--muted); background: var(--subtle); white-space: nowrap; }
tbody tr:last-child > td { border-bottom: 0; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; }
td.sub { background: var(--subtle); }

/* Badges */
.badge { display: inline-block; border-radius: 6px; padding: 1px 8px; background: var(--hover); color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }

/* Forms */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; background: var(--accent); color: #fff;
  font: inherit; font-weight: 550; padding: 7px 14px; cursor: pointer; white-space: nowrap;
}
button:hover, .button:hover { background: var(--accent-hover); text-decoration: none; }
button.secondary, .button.secondary { background: var(--bg); color: var(--text); border-color: var(--line-strong); }
button.secondary:hover, .button.secondary:hover { background: var(--hover); }
button.block { width: 100%; padding: 9px 14px; }
input, textarea, select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 7px 10px; font: inherit; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { min-height: 84px; resize: vertical; }
textarea.mono { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; min-height: 120px; }
input[type=checkbox] { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--accent); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label { font-size: 13px; font-weight: 550; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field .help { font-size: 12.5px; color: var(--muted); }
.check-line { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters input { width: 260px; }
.filters select { width: auto; }

/* Expanding rows */
details.row-edit > summary { list-style: none; cursor: pointer; color: var(--accent); font-weight: 500; }
details.row-edit > summary::-webkit-details-marker { display: none; }
details.row-edit > summary:hover { text-decoration: underline; }
details.row-edit[open] > summary { margin-bottom: 12px; }
.row-form { min-width: 230px; }
.item { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.item > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; cursor: pointer; list-style: none; }
.item > summary::-webkit-details-marker { display: none; }
.item > summary:hover { background: var(--subtle); border-radius: var(--radius); }
.item[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.item-title { min-width: 0; }
.item-title b { display: block; font-weight: 550; }
.item-title span { display: block; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.item-side { display: flex; align-items: center; gap: 8px; flex: none; }
.item-body { padding: 16px; }

/* Settings */
.tabs { display: flex; gap: 2px; box-shadow: inset 0 -1px 0 var(--line); margin-bottom: 22px; overflow: auto hidden; scrollbar-width: none; }
.tabs a { padding: 8px 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.settings-form { max-width: 760px; }

/* Pagination */
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 32px; padding: 4px 9px; text-align: center; border-radius: 7px; color: var(--muted); }
.pagination a:hover { background: var(--hover); text-decoration: none; color: var(--text); }
.pagination .current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pagination .disabled { color: var(--line-strong); }

/* Standalone pages: sign-in, password reset, errors */
.single { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--subtle); }
.single-card { width: min(400px, 100%); background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 32px; }
.single-card .brand { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.single-card .brand img { width: 52px; height: 52px; display: block; }
.single-card h1 { margin-bottom: 4px; }
.single-card .lead { color: var(--muted); margin-bottom: 20px; }
.single-card .field { margin-bottom: 14px; }
.single-card .note { color: var(--muted); font-size: 12.5px; margin-top: 16px; }

@media (max-width: 1000px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .checks { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .app { display: block; }
  .mobile-bar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20; height: 54px; padding: 0 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .mobile-bar .logo { padding: 0; }
  .mobile-bar label { display: grid; place-items: center; width: 36px; height: 36px; cursor: pointer; }
  .mobile-bar svg { width: 20px; height: 20px; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 272px; transform: translateX(-100%); }
  #nav-toggle:checked ~ .app .sidebar { transform: none; }
  #nav-toggle:checked ~ .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(23, 23, 28, .32); }
  .main { padding: 22px 16px 40px; }
  .page-head { flex-direction: column; }
  .fields { grid-template-columns: 1fr; }
}
@media (max-width: 460px) {
  .metrics { grid-template-columns: 1fr; }
  .filters input { width: 100%; }
}
