:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #faf9fa;
  --text: #2b2d33;
  --muted: #5e616b;
  --faint: #8d929c;
  --line: #e9eaef;
  --line-strong: #d8dbe2;
  --primary: #007aff;
  --primary-soft: #e5f0ff;
  --success: #30a46c;
  --success-soft: #e5f4ed;
  --danger: #e54d2e;
  --danger-soft: #fce8e4;
  --warning: #f5a524;
  --warning-soft: #fff4d6;
  --shadow: 0 18px 50px rgba(28, 32, 40, 0.08);
  font-family: Manrope, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-weight: 800;
}

.brand-copy strong {
  display: block;
  font-size: 15px;
}

.brand-copy span {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button,
.icon-button {
  border: 0;
  background: transparent;
}

.nav button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  color: var(--muted);
  padding: 11px 12px;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.nav .glyph {
  width: 18px;
  text-align: center;
}

.main {
  min-width: 0;
  padding: 22px 24px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 14px;
}

.admin-chip,
.status,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-chip {
  border: 1px solid var(--line);
  background: var(--surface);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.field {
  min-width: 180px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 13px;
  font-weight: 800;
  gap: 8px;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.button.danger {
  border-color: var(--danger-soft);
  background: var(--danger-soft);
  color: var(--danger);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 114px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 27px;
  line-height: 1;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 16px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td {
  font-size: 13px;
}

tr.clickable:hover {
  background: var(--surface-soft);
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.status.ok {
  background: var(--success-soft);
  color: var(--success);
}

.status.warn {
  background: var(--warning-soft);
  color: #9a6700;
}

.status.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.status.neutral {
  background: var(--surface-soft);
  color: var(--muted);
}

.login {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card .brand {
  padding: 0 0 20px;
}

.login-card form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.notice {
  border: 1px solid var(--primary-soft);
  border-radius: 8px;
  background: var(--primary-soft);
  color: #064c9f;
  font-size: 13px;
  line-height: 1.5;
  padding: 12px;
}

.error {
  border-color: var(--danger-soft);
  background: var(--danger-soft);
  color: var(--danger);
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  background: rgba(25, 27, 32, 0.36);
}

.drawer.open {
  display: block;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(560px, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 18px;
}

.drawer-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.kv {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  font-size: 13px;
}

.kv span:first-child {
  color: var(--muted);
  font-weight: 800;
}

.pre {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101114;
  color: #f8f8f8;
  padding: 12px;
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  background: rgba(25, 27, 32, 0.36);
  padding: 20px;
}

.modal.open {
  display: grid;
}

.modal-card {
  width: min(460px, 100%);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal-card textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .main {
    padding: 18px 14px 32px;
  }

  .topbar,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .field,
  .button {
    width: 100%;
  }

  .filters {
    width: 100%;
  }
}
