:root {
  color-scheme: light;
  --bg: #f7f8f4;
  --ink: #16202a;
  --muted: #66717e;
  --line: #d7ddd4;
  --panel: #ffffff;
  --navy: #17324d;
  --green: #247b5a;
  --amber: #b96d16;
  --red: #b63232;
  --blue: #246b93;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 2.65rem;
  line-height: 0.95;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--navy);
  font-weight: 800;
}

.summary-band,
.tax-band {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.summary-band {
  grid-template-columns: repeat(3, 1fr);
}

.tax-band {
  grid-template-columns: repeat(2, 1fr);
  margin-top: 10px;
}

.summary-band div,
.tax-band div {
  min-width: 0;
  padding: 14px 10px;
  background: var(--panel);
}

.summary-band span,
.tax-band span,
label,
legend {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.summary-band strong,
.tax-band strong {
  display: block;
  margin-top: 6px;
  color: var(--navy);
  font-size: 1.28rem;
}

.alert-panel {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: var(--panel);
}

.rules-panel {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.action-item {
  padding: 10px 12px;
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: #f2f7f8;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.35;
}

.action-item.warning {
  border-left-color: var(--amber);
  background: #fff7ec;
}

.action-item.danger {
  border-left-color: var(--red);
  background: #fff1f1;
}

.alert-panel.warning {
  border-left-color: var(--amber);
}

.alert-panel.danger {
  border-left-color: var(--red);
}

.alert-panel div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-panel p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.warning .status-dot {
  background: var(--amber);
}

.danger .status-dot {
  background: var(--red);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin: 18px 0;
}

.tab,
.secondary-action {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--navy);
  font-weight: 800;
}

.tab.active {
  background: var(--navy);
  color: white;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.active-dash-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.active-dash-panel span,
.form-note {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.active-dash-panel strong {
  display: block;
  margin-top: 4px;
  color: var(--navy);
  font-size: 2rem;
}

.active-dash-panel.running {
  border-color: #7fb39b;
  background: #eef8f1;
}

.dash-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

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

.import-panel h2 {
  margin: 0;
  font-size: 1.15rem;
}

.copy-grid {
  display: grid;
  gap: 10px;
}

.copy-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbf8;
}

.copy-card code {
  overflow-wrap: anywhere;
  color: var(--navy);
  font-size: 0.86rem;
  line-height: 1.35;
}

.step-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink);
  line-height: 1.45;
}

.step-list li + li {
  margin-top: 8px;
}

.reconcile-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.reconcile-panel h2 {
  margin-bottom: 12px;
  font-size: 1.15rem;
}

.time-row,
.money-row,
.month-tools,
.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.duration-selects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.duration-selects select {
  min-height: 48px;
  margin-top: 0;
  font-weight: 800;
}

textarea {
  resize: vertical;
}

.evidence-box {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.deduction-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.deduction-preview div {
  min-width: 0;
  padding: 12px;
  background: #eef8f1;
}

.deduction-preview span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.deduction-preview strong {
  display: block;
  margin-top: 4px;
  color: var(--green);
  font-size: 1.12rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  color: var(--ink);
}

.check-row input {
  width: 20px;
  height: 20px;
  margin: 0;
}

.primary-action {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 900;
}

.primary-action:disabled,
.secondary-action:disabled {
  opacity: 0.55;
}

.reset-action {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-weight: 900;
}

.danger-action {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: white;
  font-weight: 900;
}

.danger-action:disabled {
  opacity: 0.45;
}

.danger-zone {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #efb7b7;
  border-radius: 8px;
  background: #fff6f6;
}

.danger-zone h2 {
  margin: 0;
  color: var(--red);
  font-size: 1.1rem;
}

.danger-zone p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.save-message {
  min-height: 1.4em;
  margin: 0;
  color: var(--green);
  font-weight: 800;
}

.file-action {
  display: grid;
  min-height: 48px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--navy);
  font-weight: 900;
  text-align: center;
}

.file-action input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.entries-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.entry-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.entry-card strong {
  color: var(--navy);
}

.entry-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.delete-entry,
.entry-evidence {
  border: 0;
  background: transparent;
  font-weight: 900;
}

.delete-entry {
  color: var(--red);
}

.entry-evidence {
  margin-top: 10px;
  color: var(--blue);
}

#reviewText {
  min-height: 260px;
  margin-top: 14px;
}

dialog {
  width: min(90vw, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(15 23 42 / 0.42);
}

@media (max-width: 440px) {
  .app-shell {
    padding: 14px;
  }

  .time-row,
  .money-row,
  .month-tools,
  .export-actions,
  .dash-actions,
  .form-actions,
  .deduction-preview {
    grid-template-columns: 1fr;
  }

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

  .summary-band strong {
    font-size: 1.08rem;
  }

  h1 {
    font-size: 2rem;
  }
}
