:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --panel-2: #182235;
  --line: #2a364d;
  --text: #e8eef9;
  --muted: #93a0b8;
  --accent: #3db8a8;
  --accent-2: #5ec8bb;
  --danger: #e57373;
  --warn: #e0b15b;
  --ok: #6bcf8e;
  --info: #6aa8e8;
  --shadow: 0 18px 40px rgba(0, 0, 0, .35);
  --radius: 14px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(61, 184, 168, .16), transparent 55%),
    radial-gradient(800px 380px at 100% 0%, rgba(106, 168, 232, .12), transparent 50%),
    var(--bg);
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86em;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: color-mix(in srgb, var(--panel) 92%, black);
  border-right: 1px solid var(--line);
  padding: 1.1rem .9rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: .75rem;
  align-items: center;
  padding: .35rem .4rem .7rem;
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800;
  letter-spacing: .04em;
  color: #06241f;
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
}
.brand-name { font-weight: 750; font-size: 1.05rem; }
.brand-sub { color: var(--muted); font-size: .75rem; }

.side-nav { display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.nav-link {
  display: block;
  padding: .7rem .85rem;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
}
.nav-link:hover { background: var(--panel-2); text-decoration: none; }
.nav-link.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--panel-2));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  color: #dffaf5;
  font-weight: 650;
}

.side-footer { border-top: 1px solid var(--line); padding-top: .9rem; }
.user-chip { display: flex; gap: .7rem; align-items: center; margin-bottom: .75rem; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: #243149; font-weight: 700; font-size: .9rem;
}
.user-name { font-weight: 650; font-size: .9rem; }
.user-role { color: var(--muted); font-size: .75rem; }

.main-wrap { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.35rem .2rem;
}
.topbar-title { font-size: 1.35rem; font-weight: 750; }
.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  width: 40px; height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
}
.content { padding: 1rem 1.35rem 2rem; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.panel {
  background: color-mix(in srgb, var(--panel) 94%, black);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-pad { padding: 1.2rem 1.25rem; }
.panel-title {
  margin: 0 0 .35rem;
  font-size: 1.05rem;
  font-weight: 700;
}
.panel-sub {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
}

.login-card {
  width: min(420px, 100%);
  padding: 1.6rem 1.45rem 1.35rem;
}
.login-card h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: .01em;
}
.login-card .lead {
  margin: .35rem 0 1.25rem;
  color: var(--muted);
  font-size: .95rem;
}

label.field {
  display: block;
  margin: 0 0 .35rem;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
}
.input, select, textarea {
  width: 100%;
  margin: 0 0 .9rem;
  padding: .72rem .8rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a1220;
  color: var(--text);
  font: inherit;
}
.input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-color: var(--accent);
}
.checkline {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: .9rem;
}
.checkline input { margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 0;
  border-radius: 10px;
  padding: .7rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  color: #06241f;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: .4rem .65rem; font-size: .8rem; border-radius: 8px; }
.btn-secondary {
  color: var(--text);
  background: #2a364d;
}
.btn-ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
}
.btn-danger {
  color: #fff;
  background: #c62828;
}
.btn-warn {
  color: #1f1605;
  background: linear-gradient(180deg, #f0c875, var(--warn));
}

.alert {
  margin: 0 0 1rem;
  padding: .8rem .95rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: .92rem;
  line-height: 1.4;
}
.alert-ok { background: #163526; border-color: #2f6b4a; color: #c8f0d8; }
.alert-err { background: #3a1717; border-color: #7a3030; color: #ffd0d0; }
.alert-info { background: #14263a; border-color: #2f567a; color: #d3e8ff; }
.alert-title { font-weight: 700; margin-bottom: .4rem; }
.token-row { display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; }
.token-row code { word-break: break-all; }

.grid-cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.action-card {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: 1.15rem 1.15rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 94%, black);
  text-decoration: none;
  color: inherit;
  min-height: 140px;
  transition: border-color .15s ease, transform .15s ease;
}
.action-card:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  transform: translateY(-1px);
  text-decoration: none;
}
.action-card .kicker {
  color: var(--accent-2);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.action-card h2 { margin: 0; font-size: 1.15rem; }
.action-card p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.4; flex: 1; }
.action-card .go { font-weight: 700; color: var(--accent-2); font-size: .9rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.toolbar .left, .toolbar .right { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.search {
  min-width: min(280px, 100%);
  margin: 0;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}
.stat {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 999px;
  padding: .35rem .75rem;
  font-size: .82rem;
  color: var(--muted);
}
.stat strong { color: var(--text); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 94%, black);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
table.data th, table.data td {
  text-align: left;
  padding: .75rem .8rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data th {
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  background: #101827;
  position: sticky;
  top: 0;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: rgba(255,255,255,.02); }
table.data tr.is-selected td {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
table.data a.row-link {
  color: inherit;
  font-weight: 650;
  text-decoration: none;
}
table.data a.row-link:hover { color: var(--accent-2); text-decoration: underline; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: .18rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .03em;
}
.chip-ok { background: #1d4a33; color: #b8f0cc; }
.chip-off { background: #3a3a3a; color: #d4d4d4; }
.chip-lock { background: #5a2d12; color: #ffd7b5; }
.chip-admin { background: #1e3a5f; color: #c8ddff; }
.chip-p1 { background: #5c1a1a; color: #ffc9c9; }
.chip-p2 { background: #5a3a10; color: #ffe1a8; }
.chip-p3 { background: #1d3f5c; color: #c7e4ff; }
.chip-run { background: #163a5c; color: #b9ddff; }
.chip-done { background: #1d4a33; color: #b8f0cc; }
.chip-yes { background: #1d4a33; color: #b8f0cc; }
.chip-no { color: var(--muted); background: transparent; border: 1px solid var(--line); }
.chip-ai {
  min-width: 1.5rem;
  justify-content: center;
  background: #5a3a10;
  color: #ffe1a8;
}

.layout-split {
  display: grid;
  gap: 1rem;
}
@media (min-width: 980px) {
  .layout-split.users {
    grid-template-columns: 1.35fr .9fr;
    align-items: start;
  }
}

.muted { color: var(--muted); }
.small { font-size: .8rem; }
.stack > * + * { margin-top: .75rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .25rem; }
.hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.section-label {
  margin: 0 0 .45rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
}

.help-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  line-height: 1.55;
  font-size: .9rem;
}
.help-list code { color: #d5e6ff; }

.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 20;
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    z-index: 30;
    transform: translateX(-105%);
    transition: transform .18s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .nav-toggle { display: inline-grid; place-items: center; }
}

pre.code-block {
  margin: 0 0 .85rem;
  padding: .85rem .95rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a1220;
  color: #d7e6ff;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
