/* Eigentic.AI · Dashboard chrome
 * Inherits design tokens from ../styles.css.
 * App-shell with left sidebar, top bar, content area.
 */

@import url('../styles.css');

/* ─── Shell ─── */
body.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
  background-image: none;
}
@media (max-width: 900px) {
  body.app {
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto 1fr;
    grid-template-areas:
      "topbar"
      "sidebar"
      "main";
  }
}

.sb {
  grid-area: sidebar;
  border-right: 1px solid var(--line);
  background: var(--bg-1);
  padding: 20px 12px;
  display: flex; flex-direction: column;
  gap: 16px;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
}
@media (max-width: 900px) {
  .sb { position: static; height: auto; padding: 12px; border-right: none; border-bottom: 1px solid var(--line); }
}
.sb .brand {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px 12px;
  border-bottom: 1px solid var(--line);
}
.sb .brand img { height: 28px; width: auto; }
.sb .nav-section {
  display: flex; flex-direction: column; gap: 2px;
}
.sb .nav-section .head {
  font-family: var(--mono); font-size: 10px; color: var(--fg-3);
  letter-spacing: 0.16em; text-transform: uppercase;
  padding: 8px 10px 4px;
}
.sb a.item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg-1);
  border: 1px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
}
.sb a.item:hover { color: var(--fg); background: var(--bg-2); }
.sb a.item.active {
  color: var(--fg);
  background: var(--bg-2);
  border-color: var(--line-2);
}
.sb a.item.active::before {
  content: ""; display: block;
  width: 3px; height: 14px;
  background: var(--accent);
  border-radius: 2px;
  margin-left: -10px; margin-right: 7px;
}
.sb a.item .icn {
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg-2);
}
.sb a.item.active .icn { color: var(--accent); }
.sb a.item svg { width: 100%; height: 100%; stroke-width: 1.4; }
.sb .grow { flex: 1; }
.sb .userbox {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-2);
}
.sb .userbox .av {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px;
}
.sb .userbox .who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sb .userbox .nm { font-family: var(--mono); font-size: 12px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb .userbox .em { font-family: var(--mono); font-size: 10px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb .userbox button {
  margin-left: auto;
  background: transparent; border: 1px solid var(--line); border-radius: 3px;
  color: var(--fg-2); font-family: var(--mono); font-size: 10px;
  padding: 4px 6px; cursor: pointer;
}
.sb .userbox button:hover { color: var(--fg); border-color: var(--fg-2); }

/* ─── Topbar ─── */
.tb {
  grid-area: topbar;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  gap: 12px;
  position: sticky; top: 0; z-index: 10;
}
.tb .crumbs {
  font-family: var(--mono); font-size: 12px; color: var(--fg-2);
  display: flex; align-items: center; gap: 8px;
}
.tb .crumbs .sep { color: var(--fg-3); }
.tb .crumbs b { color: var(--fg); font-weight: 500; }
.tb .actions { display: flex; align-items: center; gap: 8px; }

/* ─── Main ─── */
main.app-main {
  grid-area: main;
  padding: 32px clamp(16px, 3vw, 40px) 80px;
  max-width: 1200px;
  width: 100%;
}

.page-head {
  display: flex; align-items: end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.page-head h1 { font-size: 30px; font-weight: 500; letter-spacing: -0.02em; }
.page-head .sub {
  margin-top: 6px;
  font-family: var(--mono); font-size: 12px; color: var(--fg-2);
}
.page-head .actions { display: flex; gap: 8px; }

/* ─── Cards / sections ─── */
.card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-1);
  overflow: hidden;
}
.card .ch {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card .ch h3 {
  font-size: 13px; font-weight: 500;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg);
}
.card .ch .meta { font-family: var(--mono); font-size: 11px; color: var(--fg-2); }
.card .cb { padding: 20px; }
.card .cb.flush { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ─── KPI tile ─── */
.kpi {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-1);
  padding: 18px;
}
.kpi .lbl { font-family: var(--mono); font-size: 11px; color: var(--fg-2); letter-spacing: 0.1em; text-transform: uppercase; }
.kpi .num {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 32px;
  color: var(--fg);
  letter-spacing: -0.02em;
  display: flex; align-items: baseline; gap: 6px;
}
.kpi .num .unit { font-size: 13px; color: var(--fg-2); }
.kpi .delta { margin-top: 8px; font-family: var(--mono); font-size: 11px; color: var(--fg-2); }
.kpi .delta.up { color: var(--accent); }
.kpi .delta.down { color: oklch(0.7 0.18 25); }

/* ─── Tables ─── */
.tbl { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12.5px; }
.tbl th, .tbl td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.tbl thead th {
  font-weight: 500;
  color: var(--fg-2);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg-2);
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--bg-2); }
.tbl td.right, .tbl th.right { text-align: right; }
.tbl td .mono { font-family: var(--mono); }
.tbl a.link { color: var(--accent); border-bottom: 1px dashed var(--accent); }

/* ─── Status pills ─── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-family: var(--mono); font-size: 11px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--fg-1);
}
.pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--fg-3);
}
.pill.ok    { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 30%, var(--line)); background: color-mix(in oklab, var(--accent) 8%, var(--bg-2)); }
.pill.ok::before { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.pill.warn  { color: oklch(0.78 0.16 70); border-color: oklch(0.78 0.16 70 / 0.4); }
.pill.warn::before { background: oklch(0.78 0.16 70); }
.pill.err   { color: oklch(0.7 0.2 25); border-color: oklch(0.7 0.2 25 / 0.4); }
.pill.err::before { background: oklch(0.7 0.2 25); }
.pill.muted { color: var(--fg-2); }

/* ─── Forms ─── */
.field {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-family: var(--mono); font-size: 11px; color: var(--fg-2);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field textarea,
.field select {
  height: 40px;
  padding: 0 12px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  font-family: var(--mono); font-size: 13px;
  outline: none;
}
.field textarea { height: auto; padding: 12px; line-height: 1.5; resize: vertical; min-height: 80px; }
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--accent); }
.field .hint { font-family: var(--mono); font-size: 11px; color: var(--fg-3); }

.row-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row-form .field { flex: 1 1 200px; margin-bottom: 0; }

.toggle {
  position: relative;
  display: inline-block;
  width: 36px; height: 20px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--bg-3); border: 1px solid var(--line-2);
  transition: .15s; border-radius: 999px;
}
.toggle .slider::before {
  position: absolute; content: ""; left: 2px; top: 2px;
  width: 14px; height: 14px;
  background: var(--fg-2); transition: .15s;
  border-radius: 50%;
}
.toggle input:checked + .slider { background: var(--accent-dim); border-color: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(16px); background: var(--accent); }

/* ─── Banners ─── */
.banner {
  padding: 14px 18px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  display: flex; align-items: center; gap: 14px;
  font-family: var(--mono); font-size: 12.5px;
  margin-bottom: 24px;
  background: var(--bg-1);
}
.banner.warn { border-color: oklch(0.78 0.16 70 / 0.4); background: oklch(0.78 0.16 70 / 0.06); }
.banner.err { border-color: oklch(0.7 0.2 25 / 0.4); background: oklch(0.7 0.2 25 / 0.06); }
.banner.info { border-color: color-mix(in oklab, var(--accent) 30%, var(--line)); background: color-mix(in oklab, var(--accent) 6%, var(--bg-1)); }
.banner .ic { width: 18px; height: 18px; flex-shrink: 0; }
.banner .grow { flex: 1; }
.banner .grow b { color: var(--fg); }
.banner a { color: var(--accent); border-bottom: 1px dashed var(--accent); }

/* ─── Plan cards (subscription page) ─── */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 900px) { .plans-grid { grid-template-columns: 1fr; } }
.plan-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-1);
  padding: 24px;
  display: flex; flex-direction: column;
  position: relative;
}
.plan-card.current { border-color: var(--accent); }
.plan-card.current::after {
  content: "CURRENT PLAN";
  position: absolute; top: 12px; right: 12px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em;
  color: var(--accent-ink); background: var(--accent);
  padding: 3px 7px; border-radius: 2px;
}
.plan-card .nm { font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; color: var(--fg-2); }
.plan-card .pr { margin-top: 12px; font-family: var(--mono); font-size: 36px; color: var(--fg); letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 4px; }
.plan-card .pr .per { font-size: 12px; color: var(--fg-2); }
.plan-card .ds { margin-top: 10px; font-size: 13px; color: var(--fg-1); min-height: 3em; text-wrap: pretty; }
.plan-card .features {
  list-style: none; padding: 0; margin: 20px 0 0;
  font-family: var(--mono); font-size: 12px; color: var(--fg-1);
}
.plan-card .features li {
  padding: 8px 0; border-top: 1px dashed var(--line);
  display: flex; gap: 8px;
}
.plan-card .features li::before { content: "+"; color: var(--accent); }
.plan-card .cta { margin-top: 20px; }

/* ─── Usage chart (CSS bar chart) ─── */
.bars {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  gap: 3px;
  height: 180px;
  align-items: end;
  padding: 16px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.bars .bar {
  background: color-mix(in oklab, var(--accent) 40%, transparent);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  position: relative;
  transition: background .15s;
}
.bars .bar:hover { background: var(--accent); }
.bars .bar.over { background: color-mix(in oklab, oklch(0.7 0.2 25) 60%, transparent); }

/* ─── Auth page ─── */
body.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background-image: radial-gradient(800px 400px at 50% 0%, var(--accent-dim), transparent 60%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 40px;
}
.auth-card .brand {
  display: flex; justify-content: center; margin-bottom: 28px;
}
.auth-card .brand img { height: 40px; width: auto; }
.auth-card h1 {
  font-size: 24px; font-weight: 500; letter-spacing: -0.02em;
  text-align: center; margin-bottom: 6px;
}
.auth-card .sub {
  font-family: var(--mono); font-size: 12px; color: var(--fg-2);
  text-align: center; margin-bottom: 28px;
}
.auth-card .oauth { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.auth-card .oauth button {
  width: 100%; height: 42px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--bg-2); color: var(--fg);
  border: 1px solid var(--line-2); border-radius: 4px;
  font-family: var(--mono); font-size: 13px;
  cursor: pointer; transition: border-color .12s, background .12s;
}
.auth-card .oauth button:hover { border-color: var(--fg-2); }
.auth-card .oauth button svg { width: 16px; height: 16px; }
.auth-card .divider {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  margin-bottom: 20px;
  font-family: var(--mono); font-size: 10px; color: var(--fg-3); letter-spacing: 0.16em;
}
.auth-card .divider::before, .auth-card .divider::after { content: ""; height: 1px; background: var(--line); }
.auth-card .submit { width: 100%; height: 44px; justify-content: center; }
.auth-card .alt {
  margin-top: 20px;
  text-align: center;
  font-family: var(--mono); font-size: 12px; color: var(--fg-2);
}
.auth-card .alt a { color: var(--accent); border-bottom: 1px dashed var(--accent); }

/* ─── Misc ─── */
.empty {
  padding: 40px;
  text-align: center;
  font-family: var(--mono); font-size: 13px;
  color: var(--fg-2);
}
.empty .big { font-size: 28px; color: var(--fg-3); margin-bottom: 12px; }

.code-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--mono); font-size: 12px;
  color: var(--fg);
}
.code-row .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-row button {
  background: transparent; border: 1px solid var(--line-2); border-radius: 3px;
  color: var(--fg-2); padding: 4px 8px; cursor: pointer;
  font-family: var(--mono); font-size: 11px;
}
.code-row button:hover { color: var(--fg); border-color: var(--fg-2); }

/* mobile sidebar collapse */
@media (max-width: 900px) {
  .sb { gap: 8px; }
  .sb .nav-section .head { padding-top: 0; }
  .sb .userbox { display: none; }
}
