:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #5d6875;
  --line: #d7d4cc;
  --accent: #0f7b68;
  --accent-dark: #0b5d4f;
  --blue: #235a8f;
  --amber: #9d6500;
  --danger: #a83d3d;
  --shadow: 0 10px 24px rgba(23, 32, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px 14px;
}

.timeline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: 1.55rem;
  line-height: 1.1;
}

h2 {
  font-size: 1.02rem;
}

.icon-button,
.admin-toggle,
.opportunity-actions button,
.opportunity-search button,
.section-heading button,
.tile-actions button,
.save-time-button,
.save-admin-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  font-size: 1.35rem;
  box-shadow: var(--shadow);
}

.admin-toggle {
  min-height: 40px;
  padding: 0 12px;
  font-weight: 800;
}

.opportunity-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.opportunity-actions button,
.opportunity-search button {
  min-height: 40px;
  padding: 0 11px;
  font-size: 0.84rem;
  font-weight: 750;
}

.project-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  min-height: 64px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 104, 0.16);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.compact-project-row input,
.compact-project-row select {
  min-height: 40px;
}

.opportunity-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.opportunity-panel[hidden] {
  display: none;
}

.opportunity-heading {
  margin: 0;
}

.opportunity-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.opportunity-status {
  min-height: 18px;
  margin: 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.opportunity-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.opportunity-item {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 64px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  color: var(--ink);
  text-align: left;
}

.opportunity-item strong {
  font-size: 0.92rem;
}

.opportunity-item span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 2px 10px;
}

.step-heading {
  margin-top: 12px;
}

.process-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.required-pill {
  border: 1px solid rgba(15, 123, 104, 0.2);
  border-radius: 999px;
  background: rgba(15, 123, 104, 0.08);
  color: var(--accent-dark);
  padding: 4px 8px;
  white-space: nowrap;
}

.sync-pill {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
}

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 123, 104, 0.12);
}

.sync-pill[data-state="pending"] .sync-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(157, 101, 0, 0.14);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.section-heading .section-note {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.section-heading button,
.tile-actions button,
.save-time-button,
.save-admin-button {
  min-height: 36px;
  padding: 0 11px;
  font-size: 0.84rem;
  font-weight: 750;
}

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

.step-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 5px 16px rgba(23, 32, 42, 0.08);
  overflow: hidden;
}

.step-card[data-state="active"] {
  border-color: var(--blue);
  background: #edf5ff;
}

.step-card[data-state="complete"] {
  border-color: var(--accent);
  background: #eef8f3;
}

.step-card[data-expanded="true"] {
  grid-column: 1 / -1;
}

.step-main {
  display: grid;
  gap: 7px;
  width: 100%;
  min-height: 86px;
  padding: 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.step-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.step-title {
  display: block;
  font-weight: 800;
  line-height: 1.15;
}

.step-required {
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(15, 123, 104, 0.12);
  color: var(--accent-dark);
  padding: 3px 7px;
  font-size: 0.66rem;
  font-weight: 800;
}

.step-state {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.25;
}

.step-elapsed {
  justify-self: start;
  border-radius: 999px;
  background: rgba(35, 90, 143, 0.12);
  color: var(--blue);
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 800;
}

.step-card[data-state="active"] .step-state {
  color: var(--blue);
}

.step-card[data-state="complete"] .step-state {
  color: var(--accent-dark);
}

.quick-capture {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.quick-capture[hidden],
.time-editor[hidden],
.money-field[hidden],
.select-field[hidden],
.date-field[hidden] {
  display: none;
}

.quick-capture textarea {
  min-height: 58px;
}

.money-field input,
.select-field select,
.date-field input {
  min-height: 40px;
}

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

.time-editor {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.time-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.manual-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  color: var(--ink);
}

.manual-toggle input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.save-time-button {
  justify-self: start;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.admin-panel {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.admin-panel[hidden] {
  display: none;
}

.admin-table {
  display: grid;
  gap: 10px;
}

.admin-row {
  display: grid;
  grid-template-columns: 58px minmax(170px, 1fr) 105px 105px minmax(120px, 0.75fr) minmax(120px, 0.75fr) 86px 82px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
}

.admin-row label {
  min-width: 0;
}

.admin-row input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
}

.admin-check {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
}

.admin-remove-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--danger);
  font-weight: 800;
}

.admin-status,
.export-status {
  min-height: 18px;
  margin: 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.save-admin-button {
  justify-self: start;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.timeline-heading {
  align-items: end;
}

.timeline-actions select {
  width: auto;
  min-height: 36px;
  padding: 0 34px 0 10px;
  font-size: 0.84rem;
  font-weight: 750;
}

.timeline {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0 0 28px;
  list-style: none;
}

.timeline li {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.timeline strong {
  font-size: 0.9rem;
}

.timeline span {
  color: var(--muted);
  font-size: 0.78rem;
}

.timeline .empty {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 430px) {
  .field-row,
  .opportunity-actions,
  .opportunity-search,
  .steps-grid,
  .time-field-grid {
    grid-template-columns: 1fr;
  }

  .timeline-actions {
    align-items: stretch;
  }

  .timeline-heading {
    align-items: stretch;
  }

  .timeline-actions {
    width: 100%;
  }

  .timeline-actions select,
  .timeline-actions button {
    flex: 1;
  }
}

@media (max-width: 900px) {
  .admin-row {
    grid-template-columns: 70px 1fr 1fr;
  }
}
