/* ==========================================================
   Gartensparte – Stylesheet
   ========================================================== */
:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-2: #eef1e8;
  --border: #dde3d4;
  --text: #1d2a1f;
  --muted: #5d6b5f;
  --primary: #2f6b3a;
  --primary-hover: #25562e;
  --primary-soft: #e3efe2;
  --on-primary: #ffffff;
  --accent: #d98c2b;
  --strom: #e0a100;
  --strom-soft: #fdf3d4;
  --wasser: #2b7fc4;
  --wasser-soft: #dcecf9;
  --danger: #c0392b;
  --danger-soft: #fbe3e0;
  --success: #2e8b57;
  --success-soft: #dff3e7;
  --warning: #b7791f;
  --warning-soft: #fdf0d8;
  --shadow: 0 1px 2px rgba(20, 40, 20, .05), 0 4px 16px rgba(20, 40, 20, .06);
  --shadow-lg: 0 10px 40px rgba(20, 40, 20, .18);
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111612; --surface: #1a211b; --surface-2: #222b23; --border: #2f3a30;
    --text: #e6ede6; --muted: #9aab9c; --primary: #6fbf7d; --primary-hover: #86cf93;
    --primary-soft: #203224; --on-primary: #0e1a10; --strom-soft: #3a3115; --wasser-soft: #16293a;
    --danger-soft: #3b1f1c; --success-soft: #17301f; --warning-soft: #3a2d14;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111612; --surface: #1a211b; --surface-2: #222b23; --border: #2f3a30;
  --text: #e6ede6; --muted: #9aab9c; --primary: #6fbf7d; --primary-hover: #86cf93;
  --primary-soft: #203224; --on-primary: #0e1a10; --strom-soft: #3a3115; --wasser-soft: #16293a;
  --danger-soft: #3b1f1c; --success-soft: #17301f; --warning-soft: #3a2d14;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; min-height: 100vh;
}
main { flex: 1; }
img { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1, h2 { font-family: var(--font-display); letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); }
h3 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.icon { width: 1.1em; height: 1.1em; vertical-align: -0.18em; flex-shrink: 0; }

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.section { padding: 48px 0; }
.section-sm { padding: 28px 0; }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 16px; top: 16px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary); color: var(--on-primary);
}
.brand-mark .icon { width: 20px; height: 20px; }
.brand-text { font-family: var(--font-display); font-size: 1.1rem; }
.main-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.main-nav > a {
  padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: .95rem;
}
.main-nav > a:hover { color: var(--text); background: var(--surface-2); }
.main-nav > a.active { color: var(--primary); background: var(--primary-soft); }
.nav-actions { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.nav-toggle { display: none; margin-left: auto; }

.icon-btn, .nav-toggle {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover, .nav-toggle:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .icon, .nav-toggle .icon { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

@media (max-width: 900px) {
  .nav-toggle { display: inline-grid; }
  .main-nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px; padding: 12px 16px 16px;
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg);
  }
  .main-nav.open { display: flex; }
  .main-nav > a { padding: 12px; font-size: 1rem; }
  .nav-actions { margin: 8px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .95rem;
  text-decoration: none; cursor: pointer; transition: background .15s, transform .05s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 7px 12px; font-size: .875rem; border-radius: 8px; }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn .spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 400px at 85% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, color-mix(in srgb, var(--primary) 30%, transparent), transparent 60%),
    var(--primary-soft);
  padding: 72px 0 64px;
}
.hero h1 { max-width: 16ch; font-size: clamp(2.2rem, 5.5vw, 3.6rem); }
.hero p.lead { font-size: 1.15rem; max-width: 52ch; color: var(--muted); }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.hero-leaf {
  position: absolute; right: -40px; bottom: -60px; width: 360px; height: 360px; color: var(--primary); opacity: .09;
}
@media (max-width: 700px) { .hero { padding: 48px 0 40px; } .hero-leaf { width: 220px; height: 220px; } }

/* ---------- Cards & Grid ---------- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-header h2, .card-header h3 { margin: 0; }
a.card { text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; display: block; }
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
a.card.stat { display: flex; }

.feature-icon {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary); margin-bottom: 12px;
}
.feature-icon .icon { width: 22px; height: 22px; }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

/* News */
.news-item { display: flex; flex-direction: column; gap: 6px; height: 100%; }
.news-item .date { font-size: .85rem; color: var(--muted); }
.news-item h3 { margin: 0; }
.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.4em; }
.prose h3 { margin-top: 1.2em; }
.prose ul { padding-left: 1.2em; }

/* Termine */
.event { display: flex; gap: 16px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--border); }
.event:last-child { border-bottom: 0; }
.event-date {
  flex-shrink: 0; width: 58px; text-align: center; border-radius: 12px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
}
.event-date .m { background: var(--primary); color: var(--on-primary); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 0; }
.event-date .d { font-size: 1.4rem; font-weight: 700; padding: 2px 0 4px; }
.event h3 { margin: 0 0 2px; font-size: 1.05rem; }
.event .meta { font-size: .88rem; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------- Page header ---------- */
.page-head { background: var(--primary-soft); padding: 40px 0 32px; border-bottom: 1px solid var(--border); }
.page-head h1 { margin: 0; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .82rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
.field.invalid input, .field.invalid textarea { border-color: var(--danger); }
.field .error { color: var(--danger); font-size: .85rem; }
.checkbox { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--primary); }
.input-group { position: relative; }
.input-group .unit { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
.input-group input { padding-right: 56px; font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.hp { position: absolute !important; left: -9999px !important; }

/* Segmented control (Strom / Wasser) */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 12px; background: var(--surface-2); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border-radius: 9px;
  cursor: pointer; font-weight: 600; color: var(--muted); transition: background .15s, color .15s;
}
.segmented input:checked + label { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input[value=strom]:checked + label .icon { color: var(--strom); }
.segmented input[value=wasser]:checked + label .icon { color: var(--wasser); }
.segmented input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); }

/* Foto-Upload */
.dropzone {
  display: flex; align-items: center; gap: 14px; padding: 16px; border: 2px dashed var(--border);
  border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input { display: none; }
.dropzone .preview { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; display: none; }
.dropzone.has-file .preview { display: block; }
.dropzone .feature-icon { margin: 0; }
.dropzone.has-file .feature-icon { display: none; }

/* ---------- Alerts / Badges ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: .95rem; }
.alert .icon { margin-top: 3px; }
.alert-info { background: var(--primary-soft); color: var(--text); }
.alert-warning { background: var(--warning-soft); }
.alert-danger { background: var(--danger-soft); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge-strom { background: var(--strom-soft); color: var(--warning); }
.badge-wasser { background: var(--wasser-soft); color: var(--wasser); }
.badge-offen { background: var(--warning-soft); color: var(--warning); }
.badge-bestaetigt { background: var(--success-soft); color: var(--success); }
.badge-abgelehnt { background: var(--danger-soft); color: var(--danger); }

/* ---------- Stats / Meter cards ---------- */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { font-size: .85rem; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .value small { font-size: .9rem; font-weight: 600; color: var(--muted); }
.stat .sub { font-size: .85rem; color: var(--muted); }
.meter-strom { border-top: 4px solid var(--strom); }
.meter-wasser { border-top: 4px solid var(--wasser); }
.meter-strom .label .icon { color: var(--strom); }
.meter-wasser .label .icon { color: var(--wasser); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { padding: 11px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: var(--surface-2); }
.table .actions { display: flex; gap: 4px; justify-content: flex-end; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }

/* Toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .search { position: relative; flex: 1 1 220px; }
.toolbar .search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search input { padding-left: 38px; }
.toolbar select { width: auto; }

/* ---------- Admin layout ---------- */
.admin-tabs { display: flex; gap: 4px; overflow-x: auto; padding: 12px 0 0; scrollbar-width: none; }
.admin-tabs a {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px 10px 0 0;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.admin-tabs a:hover { color: var(--text); }
.admin-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-tabs .count { background: var(--accent); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 7px; }
.page-head.admin { padding-bottom: 0; }

/* ---------- Modal ---------- */
dialog.modal {
  border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(10, 20, 10, .45); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 22px; max-height: 70vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }
dialog.modal[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-weight: 500;
  animation: toast-in .25s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success .icon { color: var(--primary); }
.toast.hide { opacity: 0; transform: translateY(8px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Login ---------- */
.auth-wrap { display: grid; place-items: center; padding: 56px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand-mark { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 16px; }
.auth-card .brand-mark .icon { width: 28px; height: 28px; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 48px; background: var(--surface); border-top: 1px solid var(--border); }
.footer-inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; padding-top: 32px; padding-bottom: 20px; }
.footer-inner h4 { margin: 0 0 8px; font-size: .9rem; }
.footer-inner a { color: var(--text); text-decoration: none; }
.footer-inner a:hover { color: var(--primary); }
.footer-bottom { padding-top: 14px; padding-bottom: 24px; border-top: 1px solid var(--border); font-size: .85rem; }
.footer-bottom a { color: inherit; }

/* Utils */
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }
.chart-box { position: relative; height: 260px; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; cursor: zoom-in; border: 1px solid var(--border); }
code.pw { font-size: 1.2rem; padding: 6px 10px; background: var(--surface-2); border-radius: 8px; letter-spacing: .05em; user-select: all; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
