:root {
  --blue-900: #0f2f57;
  --blue-700: #1b4f8a;
  --blue-100: #e8f0fa;
  --green: #2e7d32;
  --red: #c62828;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-500: #64748b;
  --gray-800: #1e293b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 47, 87, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
}

a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: min(1100px, 92vw);
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.site-header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  background: var(--blue-700);
  color: white;
  font-weight: 700;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
}

.brand-text { font-weight: 600; }

nav a {
  margin-left: 1rem;
  font-weight: 500;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-header h1 { margin: 0.15rem 0; font-size: 1.75rem; }

.subtitle, .muted { color: var(--gray-500); }
.eyebrow { margin: 0; font-size: 0.85rem; color: var(--gray-500); }

.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
}

.btn-primary { background: var(--blue-700); color: white; }
.btn-primary:hover { background: var(--blue-900); text-decoration: none; }
.btn-secondary { background: white; border-color: var(--gray-200); color: var(--gray-800); }
.btn-ghost { background: transparent; border-color: var(--gray-200); }
.btn-danger { background: #fef2f2; color: var(--red); border-color: #fecaca; }
.btn-small { padding: 0.35rem 0.65rem; font-size: 0.8rem; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--gray-100);
}
.data-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-500); }
.actions { text-align: right; white-space: nowrap; }

.flash-messages { margin-bottom: 1rem; }
.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}
.flash-success { background: #ecfdf5; color: #065f46; }
.flash-error { background: #fef2f2; color: #991b1b; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
}

input, textarea, select {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-weight: 400;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--blue-100);
  border-color: var(--blue-700);
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.hidden { display: none !important; }

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.form-actions.stacked { flex-direction: column; }

.detail-list { margin: 0; }
.detail-list > div {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--gray-100);
}
.detail-list dt { color: var(--gray-500); font-weight: 500; }
.detail-list dd { margin: 0; font-weight: 600; }

.badge {
  display: inline-block;
  background: var(--blue-100);
  color: var(--blue-700);
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  text-transform: capitalize;
  margin-right: 0.35rem;
}

.account-list { list-style: none; padding: 0; margin: 0; }
.account-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--gray-100); }

.status { font-size: 0.75rem; padding: 0.2rem 0.5rem; border-radius: 999px; text-transform: capitalize; }
.status-complete { background: #dcfce7; color: #166534; }
.status-draft { background: #fef9c3; color: #854d0e; }

.empty-state { text-align: center; padding: 2.5rem; }

.account-row {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--gray-50);
}

.account-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.report-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  align-items: start;
}

.calc-panel {
  position: sticky;
  top: 1rem;
}

.calc-section { margin-bottom: 1rem; }
.calc-section h3 { margin: 0 0 0.5rem; font-size: 0.9rem; color: var(--gray-500); }
.calc-section dl > div {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  font-size: 0.9rem;
}
.calc-section dt { color: var(--gray-500); }
.calc-section dd { margin: 0; font-weight: 600; }
.highlight { color: var(--blue-700); font-size: 1.05rem; }

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

.balance-field {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--gray-50);
}

.field-incomplete {
  border-color: #f59e0b;
  background: #fffbeb;
}

.hint {
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 400;
}

.balance-field .use-last {
  margin-top: 0.35rem;
  align-self: flex-start;
}

label .use-last {
  margin-top: 0.35rem;
  align-self: flex-start;
  font-weight: 500;
}

.muted-box { background: var(--blue-100); border-color: transparent; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

@media (max-width: 900px) {
  .report-layout { grid-template-columns: 1fr; }
  .calc-panel { position: static; }
}
