:root {
  --color-primary: #0f4c81;
  --color-primary-dark: #0a3862;
  --color-primary-light: #e8f1f8;
  --color-accent: #d99a2b;
  --color-bg: #f4f6f9;
  --color-card: #ffffff;
  --color-text: #1e2733;
  --color-text-muted: #64748b;
  --color-border: #e0e5eb;
  --color-success: #1c7c3f;
  --color-success-bg: #e7f6ec;
  --color-danger: #c0392b;
  --color-danger-bg: #fdecea;
  --color-warning: #b9760a;
  --color-warning-bg: #fdf3e0;
  --radius: 10px;
  --topbar-h: 58px;
  --max-width: 1200px;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Update-Banner ---------- */
.update-banner {
  position: sticky; top: 0; z-index: 200;
  background: var(--color-accent); color: #2b1c00;
  padding: 10px 16px; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  text-align: center;
}
.update-banner.hidden { display: none; }
.update-banner button#update-banner-btn {
  background: #2b1c00; color: #fff; border: none; border-radius: 6px;
  padding: 6px 12px; font-weight: 600; cursor: pointer; font-size: 0.85rem;
}
.update-banner-close {
  background: none; border: none; color: #2b1c00; font-size: 1rem; cursor: pointer;
  position: absolute; right: 12px;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--color-primary);
  color: #fff;
  height: var(--topbar-h);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.topbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 1.3rem; }

.nav-desktop { display: none; gap: 4px; }
.nav-desktop a {
  color: #cfe2f0; padding: 8px 14px; border-radius: 8px; font-weight: 500; font-size: 0.92rem;
  white-space: nowrap;
}
.nav-desktop a:hover { background: rgba(255,255,255,0.12); text-decoration: none; color: #fff; }
.nav-desktop a.active { background: rgba(255,255,255,0.18); color: #fff; }

.hamburger-btn {
  display: flex; flex-direction: column; justify-content: center; gap: 5px;
  width: 40px; height: 40px; background: transparent; border: none; cursor: pointer;
  padding: 0;
}
.hamburger-btn span {
  display: block; width: 24px; height: 2.5px; background: #fff; border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* ---------- Mobile Nav Drawer ---------- */
.nav-mobile {
  position: fixed; top: 0; right: -280px; width: 260px; height: 100%;
  background: #fff; z-index: 300; box-shadow: -2px 0 12px rgba(0,0,0,0.18);
  display: flex; flex-direction: column; padding: calc(var(--topbar-h) + 12px) 0 20px;
  transition: right 0.25s ease;
}
.nav-mobile.open { right: 0; }
.nav-mobile a {
  padding: 14px 22px; color: var(--color-text); font-weight: 500; font-size: 1rem;
  border-bottom: 1px solid var(--color-border);
}
.nav-mobile a.active { color: var(--color-primary); background: var(--color-primary-light); }
.nav-mobile a:hover { text-decoration: none; background: var(--color-primary-light); }

.nav-mobile-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 250;
  display: none;
}
.nav-mobile-overlay.open { display: block; }

/* ---------- Layout ---------- */
.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 18px 14px 60px;
  width: 100%;
}

.site-footer {
  text-align: center; color: var(--color-text-muted); font-size: 0.78rem;
  padding: 18px 14px 40px;
}

h1 { font-size: 1.5rem; margin: 4px 0 18px; }
h2 { font-size: 1.15rem; margin: 22px 0 10px; }
h3 { font-size: 1rem; margin: 16px 0 8px; color: var(--color-primary-dark); }

.page-intro { color: var(--color-text-muted); margin: -10px 0 20px; font-size: 0.94rem; }

/* ---------- Flash messages ---------- */
.flash { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.92rem; }
.flash-success { background: var(--color-success-bg); color: var(--color-success); }
.flash-error { background: var(--color-danger-bg); color: var(--color-danger); }
.flash-info { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* ---------- Cards ---------- */
.card {
  background: var(--color-card); border-radius: var(--radius); border: 1px solid var(--color-border);
  padding: 16px; margin-bottom: 16px;
}
.card-title { font-weight: 700; margin-bottom: 4px; }
.card-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) {
  .card-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .card-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ---------- Dashboard Year Tiles ---------- */
.year-grid {
  display: grid; grid-template-columns: 1fr; gap: 14px;
}
@media (min-width: 640px) {
  .year-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 980px) {
  .year-grid { grid-template-columns: repeat(3, 1fr); }
}
.year-card {
  background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 16px; position: relative; display: flex; flex-direction: column; gap: 8px;
}
.year-card.is-current { border-color: var(--color-primary); box-shadow: 0 0 0 2px var(--color-primary-light); }
.year-card.is-empty { opacity: 0.7; border-style: dashed; }
.year-card-header { display: flex; justify-content: space-between; align-items: baseline; }
.year-card-label { font-weight: 700; font-size: 1.05rem; }
.year-card-badge {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 20px; background: var(--color-primary-light); color: var(--color-primary-dark);
}
.year-card-badge.estimate { background: var(--color-warning-bg); color: var(--color-warning); }
.year-card-amount { font-size: 1.7rem; font-weight: 800; color: var(--color-primary); }
.year-card-amount small { font-size: 0.85rem; font-weight: 500; color: var(--color-text-muted); }
.year-card-sub { font-size: 0.82rem; color: var(--color-text-muted); display: flex; justify-content: space-between; }
.year-card a.details-link { font-size: 0.85rem; font-weight: 600; margin-top: 6px; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 0.85rem; margin: 12px 0 4px; }
label .hint { font-weight: 400; color: var(--color-text-muted); font-size: 0.78rem; display: block; }
input[type=text], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: 8px;
  font-size: 0.95rem; background: #fff; color: var(--color-text); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.form-row { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 640px) {
  .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 500; }

fieldset { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px 14px 14px; margin: 18px 0; }
legend { font-weight: 700; padding: 0 6px; color: var(--color-primary-dark); }

.btn {
  display: inline-block; background: var(--color-primary); color: #fff; border: none;
  padding: 11px 20px; border-radius: 8px; font-weight: 700; cursor: pointer; font-size: 0.95rem;
  text-align: center;
}
.btn:hover { background: var(--color-primary-dark); text-decoration: none; color: #fff; }
.btn.secondary { background: #fff; color: var(--color-primary); border: 1px solid var(--color-primary); }
.btn.secondary:hover { background: var(--color-primary-light); }
.btn.danger { background: var(--color-danger); }
.btn.danger:hover { background: #99291d; }
.btn.small { padding: 6px 12px; font-size: 0.82rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; border-radius: var(--radius); }
table.result-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: #fff; }
table.result-table th, table.result-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--color-border); text-align: left;
}
table.result-table th { background: var(--color-primary-light); color: var(--color-primary-dark); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
table.result-table td.num, table.result-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.result-table tr.total-row td { font-weight: 700; background: var(--color-primary-light); }
table.result-table tr.sub-row td { color: var(--color-text-muted); font-size: 0.85rem; }
table.result-table tr.diff-row.diff-match td { background: var(--color-success-bg); }
table.result-table tr.diff-row.diff-mismatch td { background: var(--color-danger-bg); }

/* ---------- Result Summary ---------- */
.result-summary {
  display: grid; grid-template-columns: 1fr; gap: 12px; margin: 18px 0;
}
@media (min-width: 640px) {
  .result-summary { grid-template-columns: repeat(3, 1fr); }
}
.result-box {
  background: var(--color-primary); color: #fff; border-radius: var(--radius); padding: 16px; text-align: center;
}
.result-box.alt { background: var(--color-primary-dark); }
.result-box .value { font-size: 1.6rem; font-weight: 800; }
.result-box .label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; opacity: 0.85; margin-top: 2px; }

/* ---------- Gesetz page ---------- */
.law-search { margin-bottom: 18px; }
.law-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.law-toc a {
  background: var(--color-primary-light); color: var(--color-primary-dark); padding: 5px 10px;
  border-radius: 20px; font-size: 0.8rem; font-weight: 600;
}
.law-toc a:hover { background: var(--color-primary); color: #fff; text-decoration: none; }
.law-section { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.law-section h3 { margin-top: 0; }
.law-section .law-text { white-space: pre-line; font-size: 0.92rem; color: var(--color-text); }
.law-section .law-abschnitt { color: var(--color-text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
mark { background: #fde68a; padding: 0 2px; border-radius: 3px; }

/* ---------- Settings year tabs ---------- */
.year-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.year-tabs a {
  padding: 7px 14px; border-radius: 20px; font-size: 0.85rem; font-weight: 600;
  background: #fff; border: 1px solid var(--color-border); color: var(--color-text);
}
.year-tabs a.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

.two-col { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 860px) { .two-col { grid-template-columns: 1fr 1fr; } }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; }
.badge.ok { background: var(--color-success-bg); color: var(--color-success); }
.badge.warn { background: var(--color-warning-bg); color: var(--color-warning); }
.badge.err { background: var(--color-danger-bg); color: var(--color-danger); }

.muted { color: var(--color-text-muted); }
.text-right { text-align: right; }

/* ---------- Desktop breakpoint: full topbar nav ---------- */
@media (min-width: 900px) {
  .nav-desktop { display: flex; }
  .hamburger-btn { display: none; }
  .page { padding: 28px 24px 70px; }
}
