/* Nook Agent — admin console design system */

:root {
  --paper: #F4F6F7;
  --surface: #FFFFFF;
  --surface-2: #EBEEF0;
  --ink: #14181D;
  --slate: #5B6472;
  --border: #DDE3E6;
  --signal: #0B6E77;
  --signal-fill: #0E7C86;
  --signal-soft: #E4F1F1;
  --ok: #2E8B63;
  --ok-soft: #E4F3EC;
  --warn: #A8670F;
  --warn-soft: #FBF0DE;
  --danger: #B23A2E;
  --danger-soft: #FAE7E4;
  --mono: ui-monospace, "SFMono-Regular", "Berkeley Mono", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 1px 2px rgba(20, 24, 29, 0.06), 0 6px 20px rgba(20, 24, 29, 0.06);
  --shadow-lg: 0 8px 30px rgba(20, 24, 29, 0.16);
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14181D; --surface: #1B2026; --surface-2: #232931; --ink: #EDF0F2;
    --slate: #98A2AE; --border: #2A3138;
    --signal: #4DC7D2; --signal-fill: #1C8A93; --signal-soft: #16292B;
    --ok: #4FBE8D; --ok-soft: #142822; --warn: #D99A3D; --warn-soft: #2B2214;
    --danger: #E2685A; --danger-soft: #2C1917;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --paper: #14181D; --surface: #1B2026; --surface-2: #232931; --ink: #EDF0F2;
  --slate: #98A2AE; --border: #2A3138;
  --signal: #4DC7D2; --signal-fill: #1C8A93; --signal-soft: #16292B;
  --ok: #4FBE8D; --ok-soft: #142822; --warn: #D99A3D; --warn-soft: #2B2214;
  --danger: #E2685A; --danger-soft: #2C1917;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
}
:root[data-theme="light"] {
  --paper: #F4F6F7; --surface: #FFFFFF; --surface-2: #EBEEF0; --ink: #14181D;
  --slate: #5B6472; --border: #DDE3E6;
  --signal: #0B6E77; --signal-fill: #0E7C86; --signal-soft: #E4F1F1;
  --ok: #2E8B63; --ok-soft: #E4F3EC; --warn: #A8670F; --warn-soft: #FBF0DE;
  --danger: #B23A2E; --danger-soft: #FAE7E4;
  --shadow: 0 1px 2px rgba(20,24,29,.06), 0 6px 20px rgba(20,24,29,.06);
  --shadow-lg: 0 8px 30px rgba(20,24,29,.16);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
code, kbd, pre { font-family: var(--mono); }
a { color: var(--signal); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: 3px;
}
h1, h2, h3, h4 { font-family: var(--mono); font-weight: 700; margin: 0; text-wrap: balance; }
p { margin: 0 0 10px; }
::selection { background: var(--signal-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }

/* ---------- app shell ---------- */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar .brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar .brand-mark .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
  flex: none;
}
.sidebar .brand-sub { font-size: 11.5px; color: var(--slate); margin-top: 3px; }

.nav-list { list-style: none; margin: 0; padding: 10px; flex: 1; overflow-y: auto; }
.nav-list a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 7px;
  color: var(--slate);
  text-decoration: none;
  font-size: 13.6px;
  font-weight: 500;
  margin-bottom: 2px;
}
.nav-list a .glyph { font-family: var(--mono); font-size: 13px; width: 16px; text-align: center; color: var(--slate); flex: none; }
.nav-list a:hover { background: var(--surface-2); color: var(--ink); }
.nav-list a.active { background: var(--signal-soft); color: var(--signal); }
.nav-list a.active .glyph { color: var(--signal); }
.nav-list .nav-section {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--slate);
  padding: 14px 12px 6px;
}
.nav-list .nav-section:first-child { padding-top: 4px; }

.sidebar .user-box {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--surface-2);
  margin-bottom: 6px;
}
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--signal-fill); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 11.5px; font-weight: 700;
  flex: none;
}
.user-chip .email { font-size: 12.3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.user-chip .role { font-family: var(--mono); font-size: 9.5px; color: var(--signal); text-transform: uppercase; letter-spacing: .05em; }
.btn-logout {
  width: 100%;
  font-family: var(--mono);
  font-size: 12px;
  background: none;
  border: 1px solid var(--border);
  color: var(--slate);
  border-radius: 6px;
  padding: 7px 0;
  cursor: pointer;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .crumbs { font-family: var(--mono); font-size: 12px; color: var(--slate); margin-bottom: 4px; }
.topbar .crumbs a { color: var(--slate); text-decoration: none; }
.topbar .crumbs a:hover { color: var(--signal); }
.topbar h1 { font-size: 19px; }
.topbar .topbar-actions { display: flex; gap: 8px; flex: none; }

.content { padding: 24px 28px 64px; flex: 1; min-width: 0; }
.content-narrow { max-width: 720px; }

@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 20; transform: translateX(-100%); transition: transform .18s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .menu-toggle { display: inline-flex !important; }
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--sans);
  font-size: 13.3px;
  font-weight: 600;
  border-radius: 7px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:hover { border-color: var(--slate); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--signal-fill); border-color: var(--signal-fill); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--signal-fill); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--slate); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { padding: 5px 10px; font-size: 12.2px; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; }
.menu-toggle { display: none; }

/* ---------- cards / surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }
.card + .card { margin-top: 16px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14.5px; }
.card-head .hint { font-size: 12px; color: var(--slate); font-family: var(--sans); font-weight: 400; margin-top: 2px; }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--slate);
}
.empty-state .glyph { font-family: var(--mono); font-size: 26px; margin-bottom: 10px; opacity: .6; }
.empty-state p { max-width: 40ch; margin: 0 auto; }

.spinner-row { display: flex; align-items: center; gap: 10px; padding: 20px; color: var(--slate); font-size: 13px; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--signal);
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.4px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th {
  font-family: var(--mono);
  font-size: 10.6px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--slate);
  background: var(--surface-2);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.mono, th.mono { font-family: var(--mono); font-size: 12.6px; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }

/* ---------- pills / badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 11px;
  padding: 2.5px 9px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.pill-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill-ok .dot { background: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill-warn .dot { background: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill-danger .dot { background: var(--danger); }
.pill-neutral { background: var(--surface-2); color: var(--slate); border-color: transparent; }

.level-chip { font-family: var(--mono); font-size: 11px; padding: 2px 9px; border-radius: 100px; border: 1px solid var(--border); background: var(--surface-2); }
.level-viewer { color: var(--slate); }
.level-editor { color: var(--signal); border-color: color-mix(in srgb, var(--signal) 30%, var(--border)); }
.level-deployer { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, var(--border)); }
.level-admin { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab-btn {
  font-family: var(--mono);
  font-size: 12.6px;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--slate);
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--signal); border-bottom-color: var(--signal); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.6px; font-weight: 600; margin-bottom: 5px; }
.field .field-hint { font-size: 11.6px; color: var(--slate); margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], select, textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 13.6px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
textarea { font-family: var(--mono); font-size: 12.8px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--signal); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.2px; }
.checkbox-row input { width: auto; }
.form-actions { display: flex; gap: 8px; margin-top: 18px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* ---------- code / pre ---------- */
pre.code-block {
  background: var(--ink);
  color: #E7ECEE;
  font-size: 12.6px;
  line-height: 1.6;
  padding: 14px 16px;
  border-radius: 7px;
  overflow-x: auto;
  margin: 0;
}
:root[data-theme="light"] pre.code-block, @media (prefers-color-scheme: light) { }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 14, 18, 0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 16px;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  overflow-y: auto;
}
.modal.modal-wide { max-width: 720px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15px; }
.modal-close { background: none; border: none; color: var(--slate); cursor: pointer; font-size: 18px; font-family: var(--mono); line-height: 1; padding: 2px 6px; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 20px; }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  padding: 11px 16px;
  border-radius: 7px;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.toast-error { background: var(--danger); color: #fff; }
.toast.toast-ok { background: var(--ok); color: #fff; }

/* ---------- misc ---------- */
.muted { color: var(--slate); }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.section-title { font-size: 13px; color: var(--slate); font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 13.3px; }
.kv dt { color: var(--slate); }
.kv dd { margin: 0; font-family: var(--mono); }
.inline-code { font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1.5px 6px; font-size: .9em; }
.breadcrumb-path { font-family: var(--mono); font-size: 12.8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.breadcrumb-path a { text-decoration: none; }
.breadcrumb-path a:hover { text-decoration: underline; }
.breadcrumb-path .sep { color: var(--slate); }
