:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #637168;
  --line: #d8ddd5;
  --paper: #f7f8f4;
  --panel: #ffffff;
  --accent: #116b5f;
  --accent-strong: #0d544b;
  --danger: #a12c2c;
  --gold: #c28b2c;
  --blue: #326d9c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
}

body.authenticated .auth-shell,
body.shared-view .auth-shell,
body.shared-view .user-actions,
body.shared-view .sidebar,
body.shared-view .screen-tabs,
body.shared-view #candidateScreen,
body.shared-view #scenarioScreen,
body.shared-view .app-only {
  display: none;
}

body.shared-view .app-shell {
  grid-template-columns: 1fr;
}

button,
input,
textarea {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#userIdentity {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.auth-shell {
  display: grid;
  min-height: calc(100vh - 84px);
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(440px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.auth-panel h2 {
  margin-bottom: 16px;
  font-size: 1.45rem;
}

.auth-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.google-link {
  display: block;
  min-height: 38px;
  margin-top: 14px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  font-weight: 800;
}

.google-link.disabled {
  color: var(--muted);
  background: #f2f3ef;
  pointer-events: none;
}

.auth-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.8rem;
}

h2 {
  font-size: 1rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(210px, 260px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.sidebar,
.editor,
.content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sidebar {
  min-height: calc(100vh - 104px);
  padding: 14px;
}

.sidebar-title,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.sidebar-title span {
  min-width: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--accent);
  text-align: center;
  font-size: 0.8rem;
  font-weight: 800;
}

.boat-list {
  display: grid;
  gap: 8px;
}

.boat-item {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  text-align: left;
  cursor: pointer;
}

.boat-item.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.boat-item strong,
.boat-item span {
  display: block;
}

.boat-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
}

.editor,
.content {
  padding: 16px;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-header h2 {
  font-size: 1.35rem;
}

.detail-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.screen-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.tab-button {
  min-height: 32px;
  padding: 6px 10px;
  color: var(--muted);
  background: transparent;
}

.tab-button.active {
  color: #ffffff;
  background: var(--accent);
}

.screen {
  display: none;
  padding-top: 16px;
}

.screen.active {
  display: block;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: #ffffff;
}

textarea {
  resize: vertical;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding-top: 21px;
}

.checkbox input,
.segmented input {
  width: auto;
  min-height: auto;
}

fieldset {
  margin: 16px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.segmented {
  display: flex;
  width: fit-content;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 11px;
  border-right: 1px solid var(--line);
  color: var(--ink);
}

.segmented label:last-child {
  border-right: 0;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}

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

.primary:hover {
  background: var(--accent-strong);
}

.ghost {
  background: #ffffff;
  border-color: var(--line);
}

.danger {
  color: var(--danger);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 88px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.metric span,
dt {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
}

.metric em {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 800;
  line-height: 1.25;
}

.summary-block {
  margin-top: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1fr);
  gap: 18px;
}

dl {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.breakout-list {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.breakout-row {
  display: grid;
  grid-template-columns: 118px 1fr 62px;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ebe5;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 18px;
}

.table-wrap.compact {
  margin-top: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 320px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--ink);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.share-output {
  min-height: 38px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fbfcfa;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.share-output a {
  color: var(--accent);
  font-weight: 800;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

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

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .detail-header {
    align-items: stretch;
    flex-direction: column;
  }

  .screen-tabs {
    width: 100%;
  }

  .tab-button {
    flex: 1;
  }

  .sidebar {
    min-height: auto;
  }

  .grid.two,
  .grid.three,
  .metric-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
