:root {
  --blue: #0a6cb8;
  --blue-dark: #06507f;
  --blue-deeper: #063f63;
  --teal: #0fa3a3;
  --ink: #1c2733;
  --ink-soft: #55636f;
  --ink-faint: #8695a1;
  --line: #dde3e8;
  --line-soft: #eaeef1;
  --bg: #eef2f5;
  --card: #ffffff;
  --danger: #c0392b;
  --ok: #1e8e5a;
  --warn: #b7791f;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 40, 0.05), 0 6px 18px rgba(20, 30, 40, 0.06);
  --shadow-sm: 0 1px 2px rgba(20, 30, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--blue); }

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: linear-gradient(135deg, var(--blue-deeper) 0%, var(--blue-dark) 60%, var(--blue) 130%);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 10px rgba(6, 63, 99, 0.25);
}

.topbar .brand {
  font-weight: 700;
  font-size: 16.5px;
  letter-spacing: 0.2px;
}

.topbar .meta {
  font-size: 13px;
  opacity: 0.88;
}

.layout {
  flex: 1;
  display: flex;
  align-items: flex-start;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  gap: 24px;
  padding: 24px 24px 60px;
}

.steps-nav {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: 24px;
}

.steps-nav ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.steps-nav li button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.12s ease;
  font-family: inherit;
}

.steps-nav li button:hover { background: #e3eaf0; }

.steps-nav li button.active {
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.steps-nav .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #d7e3ea;
  color: var(--ink-soft);
  font-size: 11px;
  flex-shrink: 0;
}

.steps-nav li button.active .step-num { background: rgba(255,255,255,0.25); color: #fff; }
.steps-nav li button.done .step-num { background: var(--ok); color: #fff; }

.main-panel {
  flex: 1;
  min-width: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  margin-bottom: 20px;
}

.card h2 { margin-top: 0; font-size: 19.5px; letter-spacing: -0.1px; }
.card h3 { font-size: 13px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.6px; margin: 30px 0 12px; font-weight: 700; }
.card h3:first-child { margin-top: 0; }
.card p.hint { color: var(--ink-soft); font-size: 13.5px; margin-top: -6px; line-height: 1.5; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
  letter-spacing: 0.1px;
}

input[type=text], input[type=email], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  font-family: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

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

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(10,108,184,0.15);
}

.field { margin-bottom: 4px; }
.field.pct input, .field.money input { text-align: right; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s ease, transform 0.05s ease;
  font-family: inherit;
}
.btn:hover { background: var(--blue-dark); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #eef3f6; color: var(--ink); box-shadow: none; }
.btn.secondary:hover { background: #dfe7ec; }
.btn.danger { background: #fdecea; color: var(--danger); box-shadow: none; }
.btn.danger:hover { background: #fbdbd7; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 6px 12px; font-size: 13px; }

.actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.status-pill {
  font-size: 12.5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef3f6;
  color: var(--ink-soft);
  font-weight: 600;
}
.status-pill.saved { background: #e6f4ec; color: var(--ok); }
.status-pill.saving { background: #fff6e5; color: var(--warn); }
.status-pill.error { background: #fdecea; color: var(--danger); }

/* ---- Grid tables (expenses / non-monthly) ---- */
table.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.grid-table th, table.grid-table td {
  border: 1px solid var(--line);
  padding: 7px 9px;
  text-align: left;
}
table.grid-table th { background: #f2f6f8; font-weight: 600; white-space: nowrap; color: var(--ink-soft); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.3px; }
table.grid-table tbody tr:nth-child(even), table.grid-table tr:nth-child(even) { background: #fafcfd; }
table.grid-table td input { border: none; padding: 4px; width: 100%; min-width: 70px; background: transparent; }
table.grid-table td input:focus { box-shadow: none; outline: 1px solid var(--blue); border-radius: 4px; }
table.grid-table .row-remove { color: var(--danger); cursor: pointer; background: none; border: none; font-size: 16px; }
.table-scroll { overflow-x: auto; border-radius: 8px; }

/* ---- Monthly grids (12-month tables): must fit one screen, no scroll ----
   table-layout: fixed lets us size every month column equally and let the
   (optional) label column take a fixed share, instead of each <input>
   forcing a 70px+ minimum that overflows the container. */
table.monthly-grid {
  table-layout: fixed;
  width: 100%;
}
table.monthly-grid th, table.monthly-grid td {
  padding: 6px 3px;
  text-align: center;
}
table.monthly-grid th { font-size: 11px; letter-spacing: 0.2px; }
table.monthly-grid td input {
  min-width: 0;
  width: 100%;
  padding: 4px 2px;
  text-align: center;
  font-size: 12.5px;
}
table.monthly-grid.with-label th:first-child,
table.monthly-grid.with-label td:first-child {
  width: 17%;
  text-align: left;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.monthly-grid-wrap { overflow: visible; }

.roster-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-bottom: 14px;
  background: #fcfdfe;
}
.roster-card .roster-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.roster-card .roster-head strong { font-size: 14.5px; }

.identify-screen {
  max-width: 480px;
  margin: 60px auto;
  padding: 0 20px;
}
.identify-screen .card { padding: 32px; }
.identify-screen .logo-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px;
}
.identify-screen .logo-row .dot {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--blue));
}
.identify-screen .logo-row span { font-weight: 700; font-size: 18px; }

.section-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; font-size: 14px; }
.section-summary-grid .k { color: var(--ink-soft); }
.section-summary-grid .v { font-weight: 600; text-align: right; }

.badge { font-size: 11.5px; padding: 2px 8px; border-radius: 6px; background: #eef3f6; color: var(--ink-soft); font-weight: 600; }
.badge.draft { background: #fff6e5; color: var(--warn); }
.badge.submitted { background: #e6f4ec; color: var(--ok); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }

.error-banner {
  background: #fdecea; color: var(--danger); border-radius: 8px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 16px;
}

/* Sidebar collapses to a horizontal step strip below this width. Raised from
   820px to 1150px so iPad landscape (1024px) gets the reclaimed width the
   12-month grids need to fit without horizontal scrolling. */
@media (max-width: 1150px) {
  .layout { flex-direction: column; padding: 16px; }
  .steps-nav { width: 100%; position: static; }
  .steps-nav ol { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 6px; }
  .steps-nav li button { white-space: nowrap; }
  .section-summary-grid { grid-template-columns: 1fr; }
}

/* Below this, even a fixed-layout 12-month grid gets too cramped to read
   (< ~55px per column) — fall back to a scrollable table rather than
   squeezing numbers unreadably small. This only applies on narrow phones,
   not laptop/iPad. */
@media (max-width: 640px) {
  table.monthly-grid { table-layout: auto; min-width: 640px; }
  table.monthly-grid td input { min-width: 42px; }
  .monthly-grid-wrap { overflow-x: auto; }
}
