:root {
  --bg: #f4efe6;
  --ink: #192126;
  --muted: #5c6a70;
  --line: #d8cec0;
  --accent: #0f766e;
  --accent-strong: #0a4f4a;
  --warm: #cb6b2d;
  --danger: #b43d2a;
  --card: rgba(255, 252, 246, 0.88);
  --shadow: 0 14px 38px rgba(29, 39, 44, 0.12);
  --radius-lg: 24px;
  --radius-md: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.16), transparent 28%),
    radial-gradient(circle at bottom left, rgba(203, 107, 45, 0.16), transparent 24%),
    linear-gradient(180deg, #f5eee3 0%, #ede5d8 100%);
}

.app-shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 22px;
  border-right: 1px solid rgba(25, 33, 38, 0.08);
  background: rgba(248, 244, 238, 0.92);
  backdrop-filter: blur(12px);
}

.sidebar,
.content,
.panel,
.brand,
.hero,
.saved-project,
.record-card,
.ops-card,
.planner-form,
.mini-form,
label,
input,
select,
textarea,
button {
  min-width: 0;
}

.content { padding: 28px; min-width: 0; }

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

.toolbar-left,
.toolbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

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

.tab-btn {
  border: 1px solid rgba(25, 33, 38, 0.12);
  background: rgba(255,255,255,0.7);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

.tab-btn.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  border-color: transparent;
}

#moduleSearch {
  min-width: 260px;
}

.brand, .panel, .hero {
  background: var(--card);
  border: 1px solid rgba(25, 33, 38, 0.08);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
}

.brand, .panel { padding: 20px; margin-bottom: 18px; }

.hero {
  padding: 28px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.eyebrow {
  margin: 0 0 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

h1, h2, h3, h4, p { margin-top: 0; }
h1 { font-size: 1.9rem; line-height: 1.05; margin-bottom: 12px; }
h2 { font-size: 1.35rem; margin-bottom: 8px; }
h3 { font-size: 1.02rem; margin-bottom: 12px; }

.subtitle, .hero-copy, .section-heading p, .bullet-board li, .law-card p, .stage-meta li, .stage-card p, .simple-steps li, .table-shell td, .table-shell th, .control-item li, blockquote {
  color: var(--muted);
}

.planner-form, .planner-form label { display: grid; gap: 8px; }
.planner-form { gap: 16px; }
input, select, textarea, button { font: inherit; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
}

textarea { resize: vertical; }
.actions,
.record-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.25);
}

.btn-secondary {
  background: #fff4eb;
  color: var(--warm);
  border: 1px solid rgba(203, 107, 45, 0.18);
}

.mini-btn {
  border: 1px solid rgba(25, 33, 38, 0.12);
  background: rgba(255,255,255,0.75);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}

.quick-nav ul, .bullet-board ul, .critical-list, .control-list, .stage-checklist, .stage-meta, .risk-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.quick-nav a {
  display: block;
  padding: 9px 0;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dashed rgba(25, 33, 38, 0.08);
  border-left: 3px solid transparent;
  padding-left: 10px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.quick-nav a:hover,
.quick-nav a.is-active {
  background: rgba(15, 118, 110, 0.08);
  border-left-color: var(--accent);
  color: var(--accent-strong);
}

.hero-stats { min-width: 260px; display: grid; gap: 10px; }
.saved-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.saved-projects {
  display: grid;
  gap: 10px;
}

.saved-project {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(25, 33, 38, 0.08);
  background: rgba(255,255,255,0.72);
}

.saved-project h3 {
  margin-bottom: 6px;
  font-size: 0.98rem;
}

.saved-project p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  word-break: break-word;
}

.saved-project button {
  margin-right: 8px;
  margin-top: 6px;
}

.stat-card {
  padding: 14px;
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(15, 118, 110, 0.02));
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 118, 110, 0.12);
}

.stat-card strong { display: block; font-size: 1.15rem; color: var(--accent-strong); }
.output-section { margin-bottom: 22px; padding: 22px; }
.section-heading { margin-bottom: 16px; }

.collapsible-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.collapsible-section.is-collapsed .collapsible-body {
  display: none;
}
.ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

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

.kanban-col {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(25, 33, 38, 0.08);
  min-height: 180px;
}

.kanban-col.drop-target {
  border-color: var(--accent);
  background: rgba(15, 118, 110, 0.08);
}

.kanban-col h3 {
  margin-bottom: 10px;
}

.kanban-card {
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(248,244,236,0.9));
  border: 1px solid rgba(25, 33, 38, 0.08);
  margin-bottom: 10px;
  cursor: grab;
}

.kanban-card.dragging {
  opacity: 0.55;
}

.kanban-card p {
  margin: 0;
}

.mini-form {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

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

.record-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(25, 33, 38, 0.08);
  background: rgba(255,255,255,0.86);
}

.record-card.alert-danger {
  border-left: 5px solid var(--danger);
}

.record-card.alert-warn {
  border-left: 5px solid var(--warm);
}

body.compact-mode .record-card,
body.compact-mode .kanban-card,
body.compact-mode .ops-card,
body.compact-mode .saved-project {
  padding: 10px;
}

body.compact-mode .record-list,
body.compact-mode .saved-projects,
body.compact-mode .control-list,
body.compact-mode .stage-cards {
  gap: 8px;
}

.record-card h4 {
  margin-bottom: 6px;
}

.record-meta {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 8px;
}

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

.compact-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.pill {
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-family: "IBM Plex Mono", monospace;
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent-strong);
}

.floating-nav {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 30;
}

.floating-nav .mini-btn {
  box-shadow: var(--shadow);
  background: rgba(255, 252, 246, 0.96);
}

.toast-host {
  position: fixed;
  left: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 35;
}

.toast {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(25, 33, 38, 0.92);
  color: white;
  box-shadow: var(--shadow);
  max-width: 320px;
}

.pill.warn {
  background: rgba(203, 107, 45, 0.14);
  color: #8b4a1f;
}

.pill.danger {
  background: rgba(180, 61, 42, 0.14);
  color: #8c2d1f;
}

.recommendation-list .record-card {
  border-left: 5px solid var(--accent);
}

@media print {
  .sidebar,
  .floating-nav,
  .top-toolbar,
  .mini-btn,
  button,
  select,
  input,
  textarea {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .content {
    padding: 0;
  }

.panel,
.hero {
  box-shadow: none;
  border: 1px solid #ccc;
  break-inside: avoid;
  }

  body {
    background: white;
  }
}

.role-focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  outline-offset: 2px;
}

.ops-card {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(25, 33, 38, 0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(247,243,236,0.92));
}

.ops-card h3 {
  margin-bottom: 10px;
}
.flow-map { display: flex; flex-wrap: wrap; gap: 12px; }

.flow-step {
  position: relative;
  flex: 1 1 210px;
  min-height: 110px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,248,240,0.92));
  border-radius: var(--radius-md);
  border: 1px solid rgba(25, 33, 38, 0.08);
}

.flow-step::after {
  content: "→";
  position: absolute;
  right: -11px;
  top: 42px;
  color: var(--warm);
  font-size: 1.4rem;
  font-weight: 800;
}

.flow-step:last-child::after { display: none; }
.flow-step span { display: block; margin-bottom: 8px; font-family: "IBM Plex Mono", monospace; font-size: 0.75rem; color: var(--accent); }
.stage-cards, .critical-grid, .law-cards, .maturity-cards, .control-list { display: grid; gap: 18px; }

.stage-card, .critical-card, .law-card, .maturity-card, .control-item {
  border: 1px solid rgba(25, 33, 38, 0.08);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  background: rgba(255,255,255,0.84);
}

.stage-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent-strong);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
}

.stage-grid, .two-col, .wbs-grid, .law-cards, .simple-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.stage-checklist li, .stage-meta li, .risk-list li, .bullet-board li, .simple-steps li, .control-item li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 10px;
}

.stage-checklist li::before, .bullet-board li::before, .simple-steps li::before, .control-item li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(15, 118, 110, 0.55);
  border-radius: 4px;
  background: white;
}

.risk-list li::before, .stage-meta li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warm);
}

.critical-card.delay { border-left: 6px solid var(--warm); }
.critical-card.cost { border-left: 6px solid var(--danger); }

.accent-board {
  background: linear-gradient(180deg, rgba(203, 107, 45, 0.06), rgba(255,255,255,0));
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid rgba(203, 107, 45, 0.14);
}

.training-box {
  padding: 20px;
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(255,255,255,0.85));
  border-radius: var(--radius-lg);
  border: 1px solid rgba(15, 118, 110, 0.12);
}

blockquote {
  margin: 0;
  padding: 18px;
  border-left: 5px solid var(--accent);
  background: rgba(255,255,255,0.82);
  border-radius: 0 14px 14px 0;
  line-height: 1.7;
}

.table-shell {
  width: 100%;
  border-collapse: collapse;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255,255,255,0.84);
}

.table-shell th, .table-shell td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(25, 33, 38, 0.08);
  text-align: left;
  vertical-align: top;
}

.table-shell th {
  font-size: 0.85rem;
  color: var(--accent-strong);
  background: rgba(15, 118, 110, 0.06);
}

@media (max-width: 1200px) {
  .app-shell, .two-col, .wbs-grid, .law-cards, .simple-steps, .stage-grid, .ops-grid, .kanban-board { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .hero { flex-direction: column; }
  .flow-step::after { display: none; }
  .sidebar {
    overflow: visible;
    height: auto;
  }
  .top-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }
  #moduleSearch {
    min-width: 0;
    width: 100%;
  }
  .floating-nav {
    right: 10px;
    bottom: 10px;
  }
  .toast-host {
    left: 10px;
    right: 10px;
  }
  .toast {
    max-width: none;
  }
}
