:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --ink: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --teal: #0f766e; /* Deep corporate teal with robust contrast */
  --teal-accent: #14b8a6; /* Vibrant secondary teal for icons/non-text accents */
  --teal-2: #f0fdfa; /* Soft teal tinted background */
  --blue: #0369a1; /* Trust blue for actions */
  --green: #15803d; /* On-chain positive success color (contrast >= 4.5:1) */
  --green-bg: #f0fdf4;
  --amber: #b45309; /* Warn color (contrast >= 4.5:1) */
  --amber-bg: #fffbeb;
  --red: #b91c1c; /* Critical alert color (contrast >= 4.5:1) */
  --red-bg: #fef2f2;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.01), 0 4px 12px rgba(15, 23, 42, 0.03), 0 16px 32px -4px rgba(15, 23, 42, 0.02);
  --shadow-hover: 0 8px 24px -4px rgba(15, 23, 42, 0.06), 0 20px 40px -8px rgba(15, 23, 42, 0.04);
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom scrollbar for modern browsers */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

button, input, select, textarea { 
  font: inherit; 
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

a { 
  color: var(--teal); 
  text-decoration: none; 
  transition: color 0.15s ease;
}
a:hover { 
  color: var(--blue);
  text-decoration: underline; 
}

.grid-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.sidebar-brand .mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  font-weight: 800;
  letter-spacing: -.02em;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.1);
}

.sidebar-brand h2 {
  font-size: 17px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px; /* Accessibility: 44px tap target height min */
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-link:hover {
  color: var(--ink);
  background: var(--surface-2);
  text-decoration: none;
  transform: translateX(2px);
}

.sidebar-link.active {
  color: var(--teal);
  background: var(--teal-2);
  font-weight: 700;
  position: relative;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  height: 50%;
  width: 4px;
  background: var(--teal);
  border-radius: 0 4px 4px 0;
}

.main-viewport {
  padding: 32px 40px 96px;
  overflow-y: auto;
  max-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand h1 {
  font-size: 26px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.subtle {
  color: var(--muted);
  margin: 4px 0 0 0;
}

.internal-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  padding: 24px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.section-head h2 {
  font-size: 18px;
  font-weight: 700;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 92px;
  background: #fafcfc;
}

.chip-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.dot.green { background: var(--green); }
.dot.amber { background: var(--amber); }
.dot.red { background: var(--red); }

.chip strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

.chip p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.move-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.move-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcfc;
}

.move-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.move-card strong {
  font-size: 14px;
  font-weight: 700;
}

.move-card p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.move-card a {
  align-self: flex-start;
  font-size: 13px;
  font-weight: 700;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.ops-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcfc;
}

.ops-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.ops-card strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.ops-card p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }

.row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
}

.row p {
  margin: 4px 0 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.badge.green { color: var(--green); background: var(--green-bg); }
.badge.amber { color: var(--amber); background: var(--amber-bg); }
.badge.red { color: var(--red); background: var(--red-bg); }
.badge.neutral { color: var(--muted); background: var(--surface-2); }

.proof-tile {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.proof-tile:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.proof-tile span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.proof-tile strong {
  display: block;
  margin-top: 6px;
  font-size: 19px;
  font-weight: 800;
  color: var(--ink);
}
.proof-tile p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.45;
}

.guardrail {
  padding: 16px;
  border-left: 4px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 12px 12px 0;
  margin-bottom: 12px;
}
.guardrail.amber {
  border-left-color: var(--amber);
  background: var(--amber-bg);
}
.guardrail.red {
  border-left-color: var(--red);
  background: var(--red-bg);
}
.guardrail strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.guardrail p {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 0 0;
  line-height: 1.4;
}

.content-story {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: 10px;
  background: var(--teal-2);
}
.content-story strong {
  display: block;
  font-size: 14px;
  color: var(--ink);
}
.content-story p {
  font-size: 13px;
  color: #115e59;
  margin: 6px 0 0 0;
  line-height: 1.45;
}

.proof-line {
  font-size: 12.5px;
  color: var(--muted);
  margin: 8px 0 0 0;
  line-height: 1.4;
}
.proof-line span {
  font-weight: 700;
  color: var(--ink);
}

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

.mini-btn {
  width: 40px; /* Accessibility: 40px minimum tap target width */
  height: 40px; /* Accessibility: 40px minimum tap target height */
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  display: grid;
  place-items: center;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s;
}
.mini-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-2);
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.search-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 40px;
  background: var(--surface);
  color: var(--ink);
  transition: all 0.2s;
}
.search-row input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.primary-btn, .ghost-btn {
  min-height: 40px; /* Accessibility: >= 40px */
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
  padding: 0 20px;
  font-size: 14px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.primary-btn {
  color: white;
  background: var(--teal);
  box-shadow: 0 2px 4px rgba(15, 118, 110, 0.1);
}
.primary-btn:hover {
  background: #0d9488;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.2);
}
.primary-btn:active {
  transform: translateY(0);
}
.ghost-btn {
  background: white;
  color: var(--ink);
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.ghost-btn:hover {
  background: var(--teal-2);
  border-color: var(--teal);
  color: var(--teal);
  transform: translateY(-1px);
}
.ghost-btn:active {
  transform: translateY(0);
}

.segmented {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.segmented button {
  min-height: 40px; /* Accessibility: >= 40px */
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  padding: 0 16px;
  font-size: 13px;
  transition: all 0.2s;
}
.segmented button:hover {
  border-color: var(--teal);
  color: var(--teal);
}
.segmented button.active {
  border-color: var(--teal);
  background: var(--teal-2);
  color: var(--teal);
}

.studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.field input, .field select, .field textarea {
  min-height: 40px; /* Accessibility: >= 40px */
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
  transition: all 0.2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
  outline: none;
}
.field textarea {
  min-height: 80px;
  resize: vertical;
}

.diagnosis {
  padding: 16px;
  border-radius: 10px;
  background: var(--teal-2);
  border: 1px solid rgba(13, 148, 136, 0.25);
  line-height: 1.45;
}

.timeline {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
}
.event {
  border-left: 3px solid var(--teal);
  padding-left: 12px;
  transition: border-color 0.2s;
}
.event:hover {
  border-left-color: var(--blue);
}
.event strong { display: block; font-size: 14px; color: var(--ink); }
.event p { color: var(--muted); font-size: 12.5px; margin: 4px 0 0 0; }

.year-chart {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.year-chart-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
  align-items: end;
  min-height: 120px;
}
.month-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.month-bar-fill {
  width: 100%;
  border-radius: 4px 4px 0 0;
  background: var(--line);
  transition: height 0.3s ease, background-color 0.2s;
}
.month-bar-fill.up { background: var(--green); }
.month-bar-fill.down { background: var(--red); }
.month-bar-fill.quiet { background: var(--muted); }
.month-bar span { font-size: 10px; font-weight: 700; color: var(--muted); margin-top: 4px; }

/* Proof Engine dynamic cards */
.proof-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.proof-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.proof-card:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.proof-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.proof-card-header h3 {
  font-size: 17px;
  font-weight: 800;
  margin: 0;
  color: var(--ink);
}
.proof-card-gain {
  font-size: 26px;
  font-weight: 800;
  color: var(--green);
  line-height: 1.1;
}
.proof-card-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  font-size: 13px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.proof-card-details div span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 2px;
}
.proof-card-details div strong {
  font-size: 14px;
  color: var(--ink);
}
.proof-card-caveat {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
}

/* LPX vs V2 comparison section */
.vs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.vs-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: all 0.2s;
}
.vs-card:hover {
  box-shadow: var(--shadow-hover);
}
.vs-card.lpx {
  border-color: var(--teal);
  background: var(--teal-2);
}
.vs-card h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}
.vs-card ul {
  margin: 0;
  padding-left: 20px;
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  line-height: 1.45;
}

/* Responsive sidebar */
@media (max-width: 900px) {
  .grid-layout {
    /* minmax(0, 1fr) so the single column can shrink below its content's
       min-content width — a plain 1fr keeps grid items at min-width:auto
       and pins the track open, forcing horizontal overflow on phones. */
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    height: auto;
    min-width: 0;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
  }
  .sidebar-link span {
    display: none;
  }
  .main-viewport {
    padding: 24px 16px;
    min-width: 0;
    max-width: 100%;
  }
  .topbar {
    flex-wrap: wrap;
  }
  .status-grid, .move-grid, .ops-grid, .proof-cards, .vs-grid, .studio-grid {
    grid-template-columns: 1fr;
  }
}