:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #18212f;
  --muted: #667085;
  --line: #d8dee8;
  --primary: #176b87;
  --primary-dark: #0f5066;
  --ok: #1f7a4d;
  --warn: #9a6400;
  --bad: #b42318;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
.topbar { height: 56px; display: flex; align-items: center; gap: 24px; padding: 0 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; }
nav { display: flex; gap: 8px; flex: 1; }
nav a { padding: 8px 10px; border-radius: 6px; color: var(--text); }
nav a.active { background: #e8f3f7; color: var(--primary-dark); }
.logout button { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.page { max-width: 1400px; margin: 0 auto; padding: 24px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head.compact { margin-top: 24px; }
h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: 0; }
h2 { margin: 24px 0 10px; font-size: 18px; letter-spacing: 0; }
p { margin: 0; color: var(--muted); }
.button, button { border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 6px; padding: 8px 10px; min-height: 34px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }
.button:disabled, button:disabled { cursor: wait; opacity: 0.65; }
.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.primary:hover { background: var(--primary-dark); }
.danger-text { color: var(--bad); }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: auto; }
.table-wrap.narrow { max-width: 760px; }
.table-wrap.log-table { max-height: 420px; margin-bottom: 20px; }
.log-table th { position: sticky; top: 0; z-index: 1; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f9fafb; color: #344054; font-weight: 600; white-space: nowrap; }
td { max-width: 520px; }
.models { word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 8px; margin: 2px; background: #eef2f6; color: var(--muted); white-space: nowrap; }
.badge.ok { background: #e7f6ee; color: var(--ok); }
.badge.warn { background: #fff4df; color: var(--warn); }
.badge.bad { background: #fde8e6; color: var(--bad); }
.badge.muted { background: #eef2f6; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 280px; }
.actions form { margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 32px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
label { display: flex; flex-direction: column; gap: 6px; color: #344054; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; min-height: 36px; font: inherit; background: #fff; color: var(--text); }
textarea { min-height: 86px; resize: vertical; }
.wide { grid-column: 1 / -1; }
.checks { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.checks label { flex-direction: row; align-items: center; font-weight: 500; }
.checks input { width: auto; }
.actions-row { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.log-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.log-section-head h2 { margin: 0; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.pagination .button { min-height: 30px; padding: 6px 9px; }
.pagination .disabled { opacity: 0.45; cursor: default; }
.manual-switch { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 16px; }
.manual-switch form { display: flex; gap: 12px; align-items: end; }
.manual-switch label { max-width: 260px; }
.alert { border-radius: 6px; padding: 10px 12px; margin-bottom: 14px; border: 1px solid transparent; }
.alert.danger { background: #fde8e6; color: var(--bad); }
.alert.ok { background: #e7f6ee; color: var(--ok); }
.login-body { min-height: 100vh; display: grid; place-items: center; background: #eef2f6; }
.login-panel { width: min(420px, calc(100vw - 32px)); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.login-panel h1 { margin-bottom: 18px; }
.login-panel form { display: grid; gap: 14px; }
.full { width: 100%; }
@media (max-width: 900px) {
  .topbar { padding: 0 12px; gap: 10px; overflow-x: auto; }
  .page { padding: 16px; }
  .section-head { flex-direction: column; }
  .log-section-head { flex-direction: column; align-items: stretch; }
  .pagination { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .manual-switch form { flex-direction: column; align-items: stretch; }
}
