/* RouteAI — admin UI. Restrained, legible, no external dependencies. */
:root {
  --bg:        #f4f6fb;
  --surface:   #ffffff;
  --ink:       #1c2230;
  --ink-soft:  #5a6678;
  --line:      #e2e7f0;
  --brand:     #2f4ad0;
  --brand-ink: #1b2f9c;
  --brand-bg:  #eef1fe;
  --ok:        #1f8a52;
  --ok-bg:     #e7f6ee;
  --warn:      #b54708;
  --warn-bg:   #fdf0e6;
  --danger:    #c2362f;
  --danger-bg: #fbeceb;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(20,30,60,.06), 0 8px 24px rgba(20,30,60,.05);
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: #161d2e; color: #c4cce0; padding: 18px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.brand {
  display: flex; align-items: baseline; gap: 6px;
  font-weight: 700; font-size: 19px; color: #fff;
  padding: 6px 10px 16px; letter-spacing: -.2px;
}
.brand .dot { color: #8aa0ff; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  color: #c4cce0; padding: 9px 11px; border-radius: 8px;
  font-size: 14.5px; font-weight: 500;
}
.nav a:hover { background: #1f2940; color: #fff; text-decoration: none; }
.nav a.active { background: var(--brand); color: #fff; }
.nav .group { color: #7e89a6; font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; padding: 16px 11px 6px; font-weight: 700; }
.sidebar .spacer { flex: 1; }
.sidebar .who { font-size: 12.5px; color: #8a93ad; padding: 10px 11px; border-top: 1px solid #232c44; }
.sidebar .who b { color: #dfe4f0; display: block; font-weight: 600; }

.main { padding: 26px 30px 60px; max-width: 1100px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar h1 { font-size: 22px; margin: 0; letter-spacing: -.3px; }
.topbar .sub { color: var(--ink-soft); font-size: 13.5px; margin-top: 2px; }

/* ---- Account picker ---- */
.scope { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-soft); }
.scope select { min-width: 200px; }

/* ---- Cards ---- */
.card { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card .hd { padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; }
.card .hd h2 { font-size: 15px; margin: 0; }
.card .bd { padding: 18px; }
.card .bd.tight { padding: 0; }

/* ---- Tables ---- */
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); background: #fafbfe; font-weight: 700; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr:hover td { background: #fafbff; }
.muted { color: var(--ink-soft); }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ---- Forms ---- */
label.fld { display: block; margin-bottom: 14px; }
label.fld > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
label.fld > .hint { font-weight: 400; color: var(--ink-soft); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 14px; padding: 9px 15px;
  border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.btn:hover { background: #f5f7fc; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.danger { color: var(--danger); border-color: #f0c8c5; background: #fff; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

/* ---- Badges / pills ---- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.on { background: var(--ok-bg); color: var(--ok); }
.pill.off { background: #eef0f5; color: var(--ink-soft); }
.pill.brand { background: var(--brand-bg); color: var(--brand-ink); }

/* ---- Flash / alerts ---- */
.flash { padding: 11px 15px; border-radius: 9px; margin-bottom: 18px; font-size: 14px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--danger-bg); color: var(--danger); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

.notice { background: var(--brand-bg); color: var(--brand-ink); border-radius: 9px; padding: 12px 15px; font-size: 13.5px; }
.empty { text-align: center; color: var(--ink-soft); padding: 38px 18px; }
.empty p { margin: 6px 0 14px; }

/* ---- Login ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1200px 600px at 70% -10%, #e9edff 0%, var(--bg) 55%); padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; }
.auth-card .brand { justify-content: center; color: var(--ink); padding-top: 0; }
.auth-card .brand .dot { color: var(--brand); }
.auth-card p.lead { text-align: center; color: var(--ink-soft); margin: -6px 0 20px; font-size: 14px; }

/* checkbox grid for permissions */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 8px 18px; }
.perm-grid label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.perm-grid input { width: auto; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .spacer, .sidebar .who { display: none; }
  .nav { display: flex; flex-wrap: wrap; }
  .main { padding: 18px; }
  .row2, .row3 { grid-template-columns: 1fr; }
}
