:root {
  --bg: #f0eadf;
  --ink: #181514;
  --muted: #625b55;
  --line: rgba(24, 21, 20, 0.14);
  --panel: rgba(255, 250, 243, 0.84);
  --panel-strong: rgba(255, 250, 243, 0.95);
  --accent: #a2291f;
  --accent-soft: rgba(162, 41, 31, 0.1);
  --good: #13644d;
  --warn: #ac6b00;
  --bad: #962d26;
  --shadow: 0 18px 60px rgba(37, 28, 17, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(162, 41, 31, 0.12), transparent 30%),
    radial-gradient(circle at bottom right, rgba(19, 100, 77, 0.12), transparent 28%),
    linear-gradient(180deg, #f5f0e8 0%, #ece4d5 100%);
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(transparent 0, rgba(24, 21, 20, 0.04) 100%),
    radial-gradient(rgba(24, 21, 20, 0.2) 0.6px, transparent 0.6px);
  background-size: auto, 6px 6px;
  mix-blend-mode: multiply;
}

.app-shell {
  position: relative;
  max-width: 1520px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.masthead,
.panel,
.login-panel {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  border-radius: 28px;
  padding: 28px 30px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}

h1, h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
  letter-spacing: -0.03em;
}

h1 { font-size: clamp(40px, 7vw, 68px); line-height: 0.96; max-width: 10ch; }
h2 { font-size: 34px; line-height: 1; }

.subhead {
  max-width: 58ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.auth-chip,
.ghost-btn,
button,
input,
textarea,
select {
  font-family: "IBM Plex Sans", sans-serif;
}

.auth-chip {
  align-self: flex-start;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  color: var(--muted);
}

.login-panel {
  margin-top: 24px;
  border-radius: 24px;
  padding: 24px;
}

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

.login-form { margin-top: 18px; }

.data-form label,
.login-form label {
  display: grid;
  gap: 7px;
}

.wide { grid-column: 1 / -1; }

.data-form span,
.login-form span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

input,
textarea,
select,
button {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(24, 21, 20, 0.14);
  background: rgba(255, 252, 247, 0.88);
  color: var(--ink);
  padding: 14px 15px;
  font-size: 14px;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

button {
  cursor: pointer;
  background: var(--ink);
  color: #f9f5ee;
  font-weight: 600;
  transition: transform 140ms ease, background 140ms ease;
}

button:hover { transform: translateY(-1px); background: #2c2521; }

.ghost-btn {
  width: auto;
  background: transparent;
  color: var(--ink);
}

.status-line {
  grid-column: 1 / -1;
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.dashboard.hidden { display: none; }
.hidden { display: none !important; }

.summary-grid,
.workspace-grid,
.ledger-grid,
.copilot-grid,
.tables-grid {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.workspace-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ledger-grid { grid-template-columns: 1.1fr 0.9fr; }
.copilot-grid { grid-template-columns: 1fr; }
.tables-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.summary-card,
.panel {
  border-radius: 24px;
  padding: 22px;
}

.summary-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.summary-card strong,
.metric-stack strong {
  display: block;
  font-family: "Cormorant Garamond", serif;
  font-size: 38px;
  line-height: 0.95;
  margin-top: 8px;
}

.summary-card span,
.metric-row span,
.catalog-card p,
td,
th,
.empty-state,
.status-pill {
  font-size: 13px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.metric-stack {
  display: grid;
  gap: 12px;
}

.metric-stack.compact { margin-top: 16px; }

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.metric-row:first-child { border-top: none; }

.stack-list {
  display: grid;
  gap: 14px;
}

.catalog-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.45);
}

.catalog-capabilities {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.status-pill.good { background: rgba(19, 100, 77, 0.12); color: var(--good); }
.status-pill.warn { background: rgba(172, 107, 0, 0.12); color: var(--warn); }
.status-pill.bad { background: rgba(150, 45, 38, 0.12); color: var(--bad); }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding: 0 0 10px;
}

td {
  padding: 11px 0;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
}

.subtable {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.empty-state {
  padding: 18px 0;
  color: var(--muted);
}

.copilot-answer {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.52);
  white-space: pre-wrap;
  line-height: 1.6;
}

.copilot-toolbar {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.copilot-toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.copilot-sources {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.copilot-source {
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.copilot-source strong {
  display: block;
  margin-bottom: 6px;
}

.copilot-source p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.copilot-session {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
}

.copilot-session.active {
  border-color: rgba(18, 92, 73, 0.4);
  background: rgba(18, 92, 73, 0.08);
}

.copilot-session strong {
  display: block;
  margin-bottom: 6px;
}

.copilot-session span {
  display: block;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 1120px) {
  .summary-grid,
  .workspace-grid,
  .ledger-grid,
  .copilot-grid,
  .tables-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell { padding: 18px 14px 40px; }
  .masthead { padding: 20px; border-radius: 20px; }
  .panel, .summary-card, .login-panel { padding: 18px; border-radius: 20px; }
  .login-form, .data-form { grid-template-columns: 1fr; }
}
