:root {
  --ink: #263238;
  --paper: #f0f4f8;
  --panel: #ffffff;
  --green: #00a676;
  --yellow: #ffcf56;
  --line: #c9d6df;
  --muted: #60717b;
  --danger: #d85f45;
  --shadow: 0 24px 60px rgba(38, 50, 56, 0.12);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(rgba(38, 50, 56, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(38, 50, 56, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.rail {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: var(--ink);
  color: #f8fbfd;
  border-right: 4px solid var(--green);
}

.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
}

.brand small {
  color: #b8c8d1;
  margin-top: 2px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: #f8fbfd;
  text-align: left;
  background: transparent;
  border: 1px solid rgba(240, 244, 248, 0.18);
  border-radius: 8px;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.tab:hover,
.tab.is-active {
  background: rgba(0, 166, 118, 0.2);
  border-color: var(--green);
  transform: translateX(2px);
}

.resource-widget {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(240, 244, 248, 0.18);
}

.resource-widget .mono,
.topbar .mono,
.screen > .mono,
.detail-grid .mono {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.rail .mono {
  color: #b8c8d1;
}

.resource-widget strong {
  display: block;
  margin: 8px 0;
  font-size: 40px;
  line-height: 1;
}

.meter {
  height: 10px;
  overflow: hidden;
  background: rgba(240, 244, 248, 0.14);
  border-radius: 999px;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--yellow);
  transition: width 420ms ease;
}

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

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 0.96;
}

h2 {
  margin-bottom: 16px;
  font-size: clamp(24px, 3vw, 34px);
}

h3 {
  font-size: 18px;
}

.search {
  display: grid;
  gap: 6px;
  min-width: min(340px, 100%);
  color: var(--muted);
  font-size: 13px;
}

.search input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.screen {
  display: none;
  animation: rise 220ms ease both;
}

.screen.is-visible {
  display: block;
}

.case-board,
.detail-grid,
.report-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
}

.active-case,
.decision-lane,
.notebook,
.contractor-panel,
.calendar-board,
.report-main,
.report-log {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.active-case {
  min-height: 360px;
  padding: clamp(20px, 4vw, 42px);
  position: relative;
  overflow: hidden;
}

.active-case::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 166, 118, 0.08), transparent 32%),
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(38, 50, 56, 0.08) 39px 40px);
  pointer-events: none;
}

.active-case > * {
  position: relative;
}

.case-head,
.case-actions,
.case-metrics,
.vote-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.badge,
.status,
.row-status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 4px 9px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
}

.status-voting,
.status-contractor {
  background: var(--yellow);
}

.status-report,
.status-closed {
  color: #ffffff;
  background: var(--green);
  border-color: var(--green);
}

.active-case h2 {
  max-width: 780px;
  margin: 18px 0 14px;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 0.98;
}

.active-case p {
  max-width: 780px;
  color: #3e4d54;
  font-size: 18px;
  line-height: 1.55;
}

.case-metrics {
  margin: 26px 0;
}

.case-metrics span,
.vote-strip span {
  min-width: 118px;
  padding: 12px;
  background: rgba(240, 244, 248, 0.86);
  border-left: 4px solid var(--green);
  border-radius: 8px;
}

.case-metrics b,
.vote-strip b {
  display: block;
  font-size: 22px;
}

.case-metrics small,
.vote-strip small,
.contractor small,
.row-main small {
  display: block;
  color: var(--muted);
}

.decision-note {
  max-width: 760px;
  padding: 14px 0 14px 18px;
  border-left: 4px solid var(--yellow);
  line-height: 1.5;
}

.primary-action,
.ghost-action {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--ink);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.primary-action {
  color: #ffffff;
  background: var(--ink);
}

.primary-action:not(:disabled):hover,
.ghost-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(38, 50, 56, 0.18);
}

.primary-action.is-muted {
  color: var(--muted);
  background: #dde7ed;
  border-color: var(--line);
  cursor: default;
}

.ghost-action {
  color: var(--ink);
  background: #ffffff;
}

.decision-lane {
  padding: 20px;
}

.workflow {
  display: grid;
  gap: 12px;
}

.workflow-step {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 10px;
  text-align: left;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.workflow-step.is-done {
  background: rgba(0, 166, 118, 0.12);
}

.workflow-step.is-current {
  border-color: var(--ink);
  box-shadow: inset 4px 0 0 var(--yellow);
}

.step-index {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-family: "SFMono-Regular", Consolas, monospace;
  background: var(--paper);
  border-radius: 8px;
}

.case-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.case-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 72px;
  padding: 12px 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.case-row.is-selected {
  border-color: var(--green);
  box-shadow: inset 4px 0 0 var(--green);
}

.row-main {
  min-width: 0;
}

.row-main strong {
  display: block;
  overflow-wrap: anywhere;
}

.notebook,
.contractor-panel,
.report-main,
.report-log {
  padding: 22px;
}

.notebook dl {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px 18px;
  margin: 0;
}

.notebook dt {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  text-transform: uppercase;
}

.notebook dd {
  margin: 0;
  line-height: 1.45;
}

#contractorList {
  display: grid;
  gap: 12px;
}

.contractor {
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.contractor > div {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.contractor span {
  display: inline-block;
  margin: 10px 0 4px;
  padding: 4px 8px;
  background: var(--yellow);
  border-radius: 8px;
}

.contractor p {
  margin-bottom: 0;
  color: #3e4d54;
}

.calendar-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 0;
  min-height: 440px;
  overflow-x: auto;
}

.lane {
  min-width: 180px;
  padding: 16px;
  border-right: 1px solid var(--line);
}

.lane:last-child {
  border-right: 0;
}

.lane h3 {
  margin-bottom: 18px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
}

.event {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 88px;
  margin-bottom: 12px;
  padding: 12px;
  text-align: left;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 4px 0 0 var(--green);
}

.event-watch {
  box-shadow: inset 4px 0 0 var(--yellow);
}

.event-conflict {
  box-shadow: inset 4px 0 0 var(--danger);
  background: #fff7f3;
}

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

.report-main h3 {
  margin: 14px 0;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1.05;
}

.report-main p,
.report-log li {
  line-height: 1.55;
}

.report-log ul {
  display: grid;
  gap: 14px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.report-log li {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.report-log strong,
.report-log span {
  display: block;
}

.report-log span {
  color: #3e4d54;
}

.loading {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  color: #ffffff;
  background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tab {
    text-align: center;
  }

  .resource-widget {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .case-board,
  .detail-grid,
  .report-layout {
    grid-template-columns: 1fr;
    display: grid;
  }
}

@media (max-width: 620px) {
  .brand {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: stretch;
  }

  .active-case {
    min-height: 0;
    padding: 20px;
  }

  .active-case p {
    font-size: 16px;
  }

  .case-row {
    grid-template-columns: 1fr;
  }

  .notebook dl {
    grid-template-columns: 1fr;
  }

  .calendar-board {
    grid-template-columns: repeat(4, 78vw);
  }
}

