:root {
  --paper: #f4f2ec;
  --paper-deep: #e8e4da;
  --ink: #23211c;
  --muted: #6f6a60;
  --indigo: #4a6275;
  --indigo-deep: #344957;
  --rust: #9b3a2b;
  --green: #446552;
  --line: rgba(35, 33, 28, 0.18);
  --shadow: 0 18px 48px rgba(35, 33, 28, 0.08);
  --serif: Georgia, "Times New Roman", serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; }
h1 { font-size: 2.2rem; }
h2 { font-size: clamp(2rem, 4vw, 3.4rem); }
h3 { font-size: 1.3rem; }
p { line-height: 1.55; }
.eyebrow {
  color: var(--indigo);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  margin: 0 0 0.5rem;
}
.muted { color: var(--muted); font-size: 0.9rem; }
.hidden { display: none !important; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 2rem 1.5rem;
  position: sticky;
  top: 0;
}
.sidebar .eyebrow { color: #9fb1bf; }
.sidebar-subtitle { color: #bdb7aa; font-size: 0.82rem; margin: 0.5rem 0 2.5rem; }
.sidebar nav { display: grid; gap: 0.3rem; }
.sidebar nav a {
  border-left: 2px solid transparent;
  color: #cfc9bd;
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.8rem 0.85rem;
  text-decoration: none;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(255, 255, 255, 0.06);
  border-left-color: #9fb1bf;
  color: white;
}
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.16); margin-top: auto; padding-top: 1rem; }
.sidebar-footer p { margin: 0.25rem 0; }
.text-button {
  background: transparent;
  border: 0;
  color: #d7d1c5;
  cursor: pointer;
  padding: 0.6rem 0;
  text-decoration: underline;
}

.main { min-width: 0; padding: 2rem clamp(1.2rem, 4vw, 4rem) 4rem; }
.topbar {
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
}
.source-state {
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.55rem 0.8rem;
}
.summary-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1.5rem;
}
.metric, .panel, .opportunity, .case-card, .alert-card {
  background: rgba(255,255,255,0.34);
  border: 1px solid var(--line);
}
.metric { padding: 1.2rem; }
.metric strong { display: block; font-family: var(--serif); font-size: 2rem; font-weight: 500; }
.metric span { color: var(--muted); font-size: 0.76rem; }
.panel { margin-bottom: 1.5rem; padding: 1.25rem; }
.panel-header {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.urgent-lane { border-left: 4px solid var(--rust); }
.card-grid { display: grid; gap: 0.9rem; }
.opportunity, .case-card, .alert-card { padding: 1rem 1.15rem; }
.opportunity-header, .case-header, .alert-header {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}
.meta-row { color: var(--muted); display: flex; flex-wrap: wrap; font-size: 0.78rem; gap: 0.55rem 1rem; margin-top: 0.8rem; }
.badge {
  border: 1px solid currentColor;
  border-radius: 999px;
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.66rem;
  padding: 0.25rem 0.48rem;
  text-transform: uppercase;
}
.badge.critical, .badge.urgent { color: var(--rust); }
.badge.sent, .badge.submitted, .badge.won { color: var(--green); }
.badge.pending, .badge.failed, .badge.reviewing { color: #936d24; }
.badge.new, .badge.go, .badge.ready { color: var(--indigo); }
.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.tab {
  background: transparent;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0.55rem 0.8rem;
}
.tab.active { background: var(--ink); color: var(--paper); }
.switch {
  align-items: center;
  display: inline-flex;
  font-size: 0.8rem;
  gap: 0.45rem;
}
.button {
  border: 1px solid var(--ink);
  cursor: pointer;
  display: inline-block;
  padding: 0.65rem 0.9rem;
  text-decoration: none;
}
.button.primary { background: var(--ink); color: var(--paper); }
.button.secondary { background: transparent; color: var(--ink); }
.button.small { font-size: 0.75rem; padding: 0.45rem 0.65rem; }
.notice { border: 1px solid var(--indigo); margin-bottom: 1rem; padding: 0.8rem 1rem; }
.notice.danger { border-color: var(--rust); color: var(--rust); }
.empty { border: 1px dashed var(--line); padding: 2rem; text-align: center; }
.empty p { color: var(--muted); }
.stack { display: grid; gap: 1rem; }
.field-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; font-size: 0.78rem; gap: 0.35rem; }
input, select, textarea {
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.65rem 0.7rem;
  width: 100%;
}
textarea { min-height: 100px; resize: vertical; }
.details-layout { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr) minmax(280px, 0.6fr); }
.event-list { border-left: 1px solid var(--line); list-style: none; margin: 0; padding: 0 0 0 1rem; }
.event-list li { margin-bottom: 0.85rem; }
.event-list time { color: var(--muted); display: block; font-family: var(--mono); font-size: 0.68rem; }
.operations-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check-list { list-style: none; padding: 0; }
.check-list li { border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding: 0.65rem 0; }

.login-page { align-items: center; display: grid; min-height: 100vh; padding: 1rem; }
.login-card {
  background: rgba(255,255,255,0.42);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin: auto;
  max-width: 430px;
  padding: 2rem;
  width: 100%;
}
.brand-mark {
  align-items: center;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  font-family: var(--serif);
  font-size: 1.6rem;
  height: 48px;
  justify-content: center;
  margin-bottom: 1.4rem;
  width: 48px;
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; position: static; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-footer { margin-top: 1.5rem; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .details-layout, .operations-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .summary-grid, .field-grid { grid-template-columns: 1fr; }
  .opportunity-header, .case-header, .alert-header { flex-direction: column; }
}
