/* ============================================================
   Costfix Web-App – Design-Tokens und Grundbausteine
   Übernommen aus dem Klick-Dummy (costfix-web-client-dummy, src/styles/global.css
   und src/layouts/AppLayout.astro). Farben: Marke aus costfix-astro, Formular- und
   Button-Optik aus der Costfix-App.
   ============================================================ */

/* Inter Variable, selbst gehostet (latin, SIL Open Font License: fonts/OFL-Inter.txt) */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal-Gz7AlRl.woff2") format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Marke (Website) */
  --c-petrol: #034752;
  --c-petrol-deep: #023138;
  --c-green: #008264;
  --c-green-dark: #006d54;
  --c-green-bright: #14d278;
  --c-green-soft: #e2f1f4;
  --c-cream: #f8f4ee;

  /* App-Optik */
  --c-primary: #0e3138;          /* Buttons in der App */
  --c-primary-hover: #034752;
  --c-primary-disabled: #93a6a8;
  --c-bg: #f7f7f5;               /* Seitenhintergrund (App: #F9F9F9, leicht warm wie die Website) */
  --c-surface: #ffffff;
  --c-success-bg: #c4eacd;       /* "1 Datei(en) erfolgreich hochgeladen" */
  --c-success-ink: #0e4b24;
  --c-success: #23a55a;          /* erledigte Schritte */
  --c-tint: #def0ed;             /* Kreis der Verarbeitung */
  --c-danger: #b42318;
  --c-danger-bg: #fdecea;
  --c-warn-bg: #fff4e5;
  --c-warn-ink: #8a4b0f;
  --c-info: #1f7fbf;

  --c-ink: #1b1917;
  --c-ink-soft: #3d4447;
  --c-gray: #6b7280;
  --c-gray-light: #9ca3af;
  --c-border: #e3e5e1;
  --c-border-strong: #a9afb1;    /* Eingabefelder (App: #A0A0A0) */

  --font: 'Inter Variable', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  --radius-card: 16px;
  --radius-field: 10px;
  --radius-btn: 10px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.04);
  --shadow-pop: 0 24px 64px rgba(2, 49, 56, 0.24);

  --max-width: 1160px;
  --gutter: clamp(16px, 4vw, 32px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--c-bg);
  color: var(--c-ink);
  font: 400 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: inherit;
}

img,
svg {
  display: block;
}

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

/* `hidden` muss gegen display:flex/grid aus Klassen gewinnen (Banner, Zahlungsfelder …). */
[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--c-green-bright);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

html.no-scroll {
  overflow: hidden;
}

@media (max-width: 560px) {
  .hide-sm {
    display: none !important;
  }
}

/* ---------- Layout ---------- */

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.container-narrow {
  max-width: 760px;
}

.page {
  flex: 1;
  padding: clamp(24px, 4vw, 48px) 0 72px;
}

/* ---------- Typografie ---------- */

.eyebrow {
  font: 800 12.5px/1 var(--font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-green-dark);
}

.h1 {
  font: 800 clamp(28px, 4.4vw, 44px) / 1.12 var(--font);
  letter-spacing: -0.025em;
  color: var(--c-petrol);
}

.h2 {
  font: 750 clamp(22px, 2.6vw, 28px) / 1.2 var(--font);
  letter-spacing: -0.015em;
  color: var(--c-ink);
}

.h3 {
  font: 700 19px/1.3 var(--font);
  color: var(--c-ink);
}

.lead {
  font-size: clamp(16px, 1.6vw, 18px);
  line-height: 1.6;
  color: var(--c-ink-soft);
}

.muted {
  color: var(--c-gray);
}

.small {
  font-size: 14px;
}

/* ---------- Karten ---------- */

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: clamp(20px, 3vw, 28px);
}

.card + .card {
  margin-top: 16px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 24px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-btn);
  font: 600 16.5px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--c-primary-hover);
}

.btn-primary:disabled {
  background: var(--c-primary-disabled);
  cursor: not-allowed;
}

.btn-outline {
  background: var(--c-surface);
  border-color: var(--c-primary);
  color: var(--c-primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--c-green-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--c-primary);
  padding: 0 12px;
  min-height: 44px;
}

.btn-ghost:hover {
  background: rgba(14, 49, 56, 0.06);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  min-height: 58px;
  font-size: 17px;
}

.btn .spinner {
  width: 18px;
  height: 18px;
}

.link {
  color: var(--c-petrol);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}

.link:hover {
  color: var(--c-green);
}

/* Zurück-Link über dem Seitentitel (Angaben, Kostenpositionen) */
.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--c-ink-soft);
  text-decoration: none;
  margin-bottom: 18px;
}

.back:hover {
  color: var(--c-petrol);
}

/* ---------- Formulare (App-Optik) ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 14.5px;
  color: var(--c-ink-soft);
}

.field-label .req {
  color: var(--c-danger);
}

.input,
.select {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-field);
  font-size: 17px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:hover,
.select:hover {
  border-color: var(--c-gray);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(14, 49, 56, 0.14);
}

.input[aria-invalid='true'] {
  border-color: var(--c-danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}

.select {
  appearance: none;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231B1917' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

.input-affix {
  position: relative;
}

.input-affix .input {
  padding-right: 40px;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.input-affix::after {
  content: '€';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-gray);
  pointer-events: none;
}

.field-error {
  font-size: 14px;
  color: var(--c-danger);
}

.checkbox {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 14px;
  align-items: start;
  cursor: pointer;
  font-size: 15px;
  line-height: 1.5;
  color: var(--c-ink-soft);
}

.checkbox input {
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border: 1.5px solid var(--c-border-strong);
  border-radius: 6px;
  background: var(--c-surface);
  cursor: pointer;
  display: grid;
  place-content: center;
}

.checkbox input:checked {
  background: var(--c-primary);
  border-color: var(--c-primary);
}

.checkbox input:checked::after {
  content: '';
  width: 12px;
  height: 7px;
  border: 2.5px solid #fff;
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px);
}

/* ---------- Hinweise ---------- */

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 16px;
  line-height: 1.4;
}

.banner svg {
  flex: none;
}

.banner-success {
  background: var(--c-success-bg);
  color: var(--c-success-ink);
}

.banner-warn {
  background: var(--c-warn-bg);
  color: var(--c-warn-ink);
  align-items: flex-start;
  font-size: 15px;
}

.banner-error {
  background: var(--c-danger-bg);
  color: var(--c-danger);
}

.info-list {
  list-style: none;
  display: grid;
  gap: 12px;
}

.info-list li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: start;
  color: var(--c-ink-soft);
  line-height: 1.45;
}

.info-list svg {
  margin-top: 1px;
}

/* Spinner */
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Dialoge (src/lib/dialog.ts und Bearbeiten-Dialoge) ---------- */

.cfx-dialog {
  margin: auto;
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: var(--c-surface);
  color: var(--c-ink);
  box-shadow: var(--shadow-pop);
}

.cfx-dialog-wide {
  width: min(640px, calc(100vw - 32px));
}

.cfx-dialog::backdrop {
  background: rgba(2, 30, 34, 0.55);
}

.cfx-dialog-inner {
  padding: 24px;
  display: grid;
  gap: 14px;
}

.cfx-dialog-inner p {
  color: var(--c-ink-soft);
}

.cfx-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.btn-danger {
  background: var(--c-danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #8f1c13;
}

@media (max-width: 480px) {
  .cfx-dialog-actions .btn {
    flex: 1 1 100%;
  }
}

/* ---------- Schalter, Textfeld, Info-Hinweis (Schritt 5 und Bearbeiten) ---------- */

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-weight: 600;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch-track {
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: 99px;
  background: var(--c-border-strong);
  position: relative;
  transition: background 0.2s ease;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-track {
  background: var(--c-primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 3px solid var(--c-green-bright);
  outline-offset: 2px;
}

.textarea {
  height: auto;
  min-height: 100px;
  padding: 12px 16px;
  line-height: 1.5;
  resize: vertical;
}

.banner-info {
  background: #e8f2fa;
  color: #134a6e;
  align-items: flex-start;
  font-size: 15px;
}

/* ---------- Liste der Abrechnungen (App: InvoiceListItem) ---------- */
.bill-list {
  list-style: none;
  display: grid;
  gap: 10px;
}

.bill-row {
  display: flex;
  align-items: stretch;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 14px;
}

.bill-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 18px;
  color: inherit;
  text-decoration: none;
  border-radius: 14px;
}

.bill-link:hover {
  background: var(--c-green-soft);
}

.bill-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.bill-title {
  font-size: 17px;
  font-weight: 700;
  overflow-wrap: break-word;
  hyphens: auto;
}

.bill-sub {
  font-size: 14.5px;
  color: var(--c-ink-soft);
}

.bill-sub.is-placeholder {
  font-style: italic;
  color: var(--c-gray);
}

.bill-date {
  font-size: 13px;
  color: var(--c-gray);
}

.bill-chevron {
  flex: none;
  color: var(--c-gray);
}

.bill-delete {
  flex: none;
  width: 48px;
  border: 0;
  border-left: 1px solid var(--c-border);
  background: none;
  color: var(--c-danger);
  cursor: pointer;
  border-radius: 0 14px 14px 0;
  display: grid;
  place-items: center;
}

.bill-delete:hover {
  background: var(--c-danger-bg);
}

.badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.badge-ok {
  background: var(--c-success-bg);
  color: var(--c-success-ink);
}

.badge-draft {
  background: var(--c-warn-bg);
  color: var(--c-warn-ink);
}

/* Formular-Seiten (Anmelden, Registrieren, Konto) */
.narrow {
  max-width: 520px;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 12px;
  font-size: 14px;
  color: var(--c-gray);
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

/* ---------- Abrechnungen nach Jahr (Startseite und Liste, per innerHTML erzeugt) ---------- */
.year-group + .year-group {
  margin-top: 24px;
}

.year-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--c-gray);
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

/* Schmale Bildschirme: Listenzeilen brauchen die Breite für den Titel */
@media (max-width: 560px) {
  .bill-link {
    gap: 8px;
    padding: 12px 10px 12px 14px;
  }

  .bill-chevron {
    display: none;
  }

  .bill-delete {
    width: 42px;
  }
}

.bill-stage {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--c-petrol);
}

/* ---------- Rahmen: Skip-Link, Kopfzeile, Konto-Menü, Fußzeile, Toast (AppLayout) ---------- */

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 12px 18px;
  background: var(--c-primary);
  color: #fff;
  font-weight: 700;
  border-radius: var(--radius-btn);
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.topbar {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inner {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  min-height: 40px;
  padding: 0 12px;
  font-size: 15px;
  gap: 8px;
  text-decoration: none;
}

.user-menu {
  position: relative;
}

/* <details>: ohne Dreieck, der Knopf öffnet und schließt */
.user-menu > summary {
  list-style: none;
  cursor: pointer;
}

.user-menu > summary::-webkit-details-marker {
  display: none;
}

.user-logout {
  display: grid;
}

.user-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 950;
  min-width: 250px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  padding: 8px;
  display: grid;
}

.user-who {
  display: grid;
  gap: 2px;
  padding: 8px 10px 12px;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 6px;
  font-size: 14px;
}

.user-who span {
  color: var(--c-gray);
  overflow-wrap: anywhere;
}

.user-pop a,
.user-pop button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 0;
  background: none;
  border-radius: 10px;
  color: var(--c-ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}

.user-pop a:hover,
.user-pop button:hover {
  background: var(--c-green-soft);
}

.btn-sm {
  min-height: 40px;
  padding: 0 14px;
  font-size: 15px;
  gap: 8px;
}

.site-footer {
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
  font-size: 14px;
  color: var(--c-gray);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.footer-inner nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
}

.footer-inner a {
  text-decoration: none;
}

.footer-inner a:hover {
  color: var(--c-petrol);
  text-decoration: underline;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 950;
  max-width: min(520px, calc(100vw - 32px));
  transform: translate(-50%, 12px);
  opacity: 0;
  background: var(--c-primary);
  color: #fff;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 15px;
  box-shadow: var(--shadow-pop);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 560px) {
  .topbar-inner {
    height: 60px;
  }

  .brand svg {
    height: 28px;
    width: auto;
  }

  .brand-group {
    gap: 10px;
  }
}


/* ---- Schrittanzeige (Klick-Dummy: components/Stepper.astro) ---- */

.stepper {
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}

.stepper ol {
  list-style: none;
  display: flex;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px var(--gutter);
  gap: 8px;
}

.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--c-gray);
  white-space: nowrap;
}

.step:not(:last-child)::after {
  content: '';
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: var(--c-border);
  margin: 0 4px;
  min-width: 12px;
}

.step-done:not(:last-child)::after {
  background: var(--c-success);
}

.step-dot {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  border: 1.5px solid var(--c-border-strong);
  background: var(--c-surface);
}

.step-done {
  color: var(--c-ink-soft);
}

.step-done .step-dot {
  background: var(--c-success);
  border-color: var(--c-success);
  color: #fff;
}

.step-current {
  color: var(--c-primary);
}

.step-current .step-dot {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(14, 49, 56, 0.12);
}

.stepper-mobile {
  display: none;
}

@media (max-width: 760px) {
  .stepper ol {
    padding-bottom: 6px;
    gap: 4px;
  }

  .step-label {
    display: none;
  }

  .step {
    gap: 4px;
  }

  .stepper-mobile {
    display: block;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gutter) 12px;
    font-size: 14px;
    color: var(--c-gray);
  }

  .stepper-mobile strong {
    color: var(--c-primary);
  }
}

/* ---- Hinweis auf die Smartphone-App (Klick-Dummy: components/AppBanner.astro) ---- */

.app-banner {
  display: grid;
  grid-template-columns: 28px 48px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 8px;
  background: #f3f4f2;
  border-bottom: 1px solid var(--c-border);
}


.ab-close {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  border-radius: 50%;
  color: var(--c-gray);
  cursor: pointer;
}

.ab-icon {
  width: 48px;
  height: 48px;
  border-radius: 11px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.ab-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 13px;
  line-height: 1.3;
  color: var(--c-ink-soft);
}

.ab-text strong {
  font-size: 14.5px;
  color: var(--c-ink);
}

.ab-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ab-store {
  color: var(--c-gray);
}

.ab-cta {
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--c-primary);
  color: #fff;
  font-size: 14.5px;
  font-weight: 700;
  text-decoration: none;
}

@media print {
  .app-banner {
    display: none !important;
  }
}
