:root {
  color-scheme: light;
  --ink: #121816;
  --muted: #66716d;
  --line: #dfe5df;
  --panel: #ffffff;
  --canvas: #f5f7f4;
  --sidebar: #111c18;
  --accent: #12765a;
  --accent-2: #315f9f;
  --gold: #b1812f;
  --warn: #9a3f2d;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(18, 118, 90, 0.07), transparent 34%),
    linear-gradient(315deg, rgba(49, 95, 159, 0.06), transparent 30%),
    var(--canvas);
  color: var(--ink);
  letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }

.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: #eef4ee;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  box-shadow: 18px 0 60px rgba(17, 28, 24, 0.12);
}

.brand, .login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #e7f2cf;
  color: #17201c;
  font-weight: 800;
}

.brand-mark.admin {
  background: #dce7fb;
}

.brand small, .login-brand small {
  display: block;
  color: #aab7af;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a, .logout button {
  min-height: 42px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #eef4ee;
  background: transparent;
  border: 0;
  text-align: left;
  font: inherit;
}

.nav a:hover, .logout button:hover {
  background: rgba(255,255,255,0.1);
}

.logout {
  margin-top: auto;
}

.main {
  padding: 34px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  font-weight: 700;
  margin: 0 0 8px;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: 34px; line-height: 1.12; margin-bottom: 0; }
h2 { font-size: 18px; margin-bottom: 14px; }
p { line-height: 1.55; }

.button, button, .primary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 15px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.metric span {
  font-size: 30px;
  font-weight: 800;
  display: block;
}

.metric small, .muted {
  color: var(--muted);
}

.two-col, .builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  margin-bottom: 28px;
}

.panel, .item, .goal-card, .table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(18, 24, 22, 0.055);
}

.panel { padding: 20px; }

.section-head, .card-top, .row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.section-head {
  margin-bottom: 12px;
}

.section-head a {
  color: var(--accent-2);
  font-weight: 700;
}

.list, .goal-grid {
  display: grid;
  gap: 10px;
}

.goal-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.item, .goal-card {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.item:hover, .goal-card:hover {
  border-color: #9cb6ad;
  box-shadow: 0 20px 60px rgba(18, 24, 22, 0.085);
}

.item span, .goal-card p, .goal-card small {
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eaf1ed;
  color: #225547;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.pill.quiet {
  background: #eef1f0;
  color: #5d6763;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th, td {
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
}

tr:last-child td { border-bottom: 0; }
td a { color: var(--accent-2); font-weight: 700; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(360px, 1.18fr);
  gap: 18px;
  align-items: start;
}

.settings-prompt {
  grid-row: span 2;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.78fr) minmax(420px, 1.22fr);
  gap: 18px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 16px;
}

label, fieldset {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

textarea { resize: vertical; }

.span-2 { grid-column: 1 / -1; }

.narrow-form {
  max-width: 620px;
}

.actions {
  display: flex;
  justify-content: flex-end;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.danger {
  background: #9a3f2d;
  border-color: #9a3f2d;
  color: #fff;
}

.danger:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.tool-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.tool-box label {
  grid-template-columns: 18px 1fr;
  display: grid;
  align-items: center;
  font-weight: 600;
  margin-top: 8px;
}

.tool-box input {
  width: 18px;
  min-height: 18px;
}

.tool-list {
  display: grid;
  gap: 10px;
}

.tool-list label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfa;
}

.tool-list input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.tool-list small {
  color: var(--muted);
  display: block;
  margin-top: 3px;
  line-height: 1.35;
}

.check-row {
  grid-template-columns: 20px minmax(0, 1fr);
  align-content: center;
  align-items: center;
  min-height: 42px;
  padding-top: 22px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.chat-log {
  min-height: 320px;
  max-height: 420px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8faf7;
}

.chat-message {
  padding: 10px 12px;
  border-radius: 8px;
  max-width: 88%;
  background: #fff;
  border: 1px solid var(--line);
}

.chat-message.user {
  margin-left: auto;
  background: #e8f2ee;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips span {
  background: #edf0f6;
  color: #283c61;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.details {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
}

.details dt {
  color: var(--muted);
  font-weight: 800;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8faf7;
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid var(--line);
}

.transcript {
  display: grid;
  gap: 10px;
}

.transcript p {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.transcript strong {
  display: inline-block;
  min-width: 82px;
  color: var(--accent);
}

.empty {
  color: var(--muted);
  padding: 14px;
}

.alert, .notice {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.alert {
  background: #fff1ed;
  color: var(--warn);
  border: 1px solid #f0c4b9;
}

.notice {
  background: #edf8f0;
  color: #1d674f;
  border: 1px solid #bcdcc8;
}

.call-console {
  background: #101b18;
  color: #eff6f1;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 28px;
  border: 1px solid #263833;
  box-shadow: 0 22px 60px rgba(16, 27, 24, 0.18);
}

.call-stage {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
}

.call-stage h2 {
  font-size: 25px;
  margin-bottom: 8px;
}

.call-stage .eyebrow,
.call-stage .muted {
  color: #a9bab2;
}

.call-orb {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #1f342f;
  border: 1px solid #34534b;
}

.call-orb span {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #7cb69d;
  transform: scale(0.6);
  transition: transform 120ms ease, background 160ms ease;
}

.call-console.is-live .call-orb span {
  background: #d8f2cc;
}

.call-state {
  min-width: 92px;
  text-align: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: #20372f;
  color: #d8f2cc;
}

.meter {
  height: 10px;
  margin: 22px 0;
  border-radius: 999px;
  background: #243833;
  overflow: hidden;
}

.meter span {
  display: block;
  width: 4%;
  height: 100%;
  border-radius: inherit;
  background: #d8f2cc;
  transition: width 80ms ease;
}

.call-actions button {
  min-width: 170px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef2ee;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 18px 70px rgba(20, 32, 28, 0.12);
}

.login-brand {
  margin-bottom: 26px;
}

.login-brand small {
  color: var(--muted);
}

.login-link {
  margin: 18px 0 0;
  text-align: center;
  font-weight: 800;
}

.login-link a {
  color: var(--accent-2);
}

@media (max-width: 880px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .main {
    padding: 22px;
  }
  .metric-grid, .two-col, .builder-layout, .form-grid {
    grid-template-columns: 1fr;
  }
  .settings-layout, .admin-grid {
    grid-template-columns: 1fr;
  }
  .settings-prompt {
    grid-row: auto;
  }
  .call-stage {
    grid-template-columns: 72px minmax(0, 1fr);
  }
  .call-state {
    grid-column: 1 / -1;
    width: fit-content;
  }
  .call-orb {
    width: 72px;
    height: 72px;
  }
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  h1 { font-size: 27px; }
  .nav { grid-template-columns: 1fr 1fr; }
  .chat-form { grid-template-columns: 1fr; }
  .details { grid-template-columns: 1fr; }
  .call-actions button { width: 100%; }
}
