/* ═══════════════════════════════════════════════════════════
   Ferienwohnung Senne — Verwaltung
   Lokale Webfonts (npm run fonts zum Herunterladen)
═══════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Playfair Display';
  font-weight: 400; font-style: normal; font-display: swap;
  src: url('/fonts/playfair-display-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Playfair Display';
  font-weight: 700; font-style: normal; font-display: swap;
  src: url('/fonts/playfair-display-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Playfair Display';
  font-weight: 400; font-style: italic; font-display: swap;
  src: url('/fonts/playfair-display-400-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Sans 3';
  font-weight: 400; font-style: normal; font-display: swap;
  src: url('/fonts/source-sans-3-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Sans 3';
  font-weight: 600; font-style: normal; font-display: swap;
  src: url('/fonts/source-sans-3-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Code Pro';
  font-weight: 400; font-style: normal; font-display: swap;
  src: url('/fonts/source-code-pro-400.woff2') format('woff2');
}

/* ─── Custom Properties ─────────────────────────────────── */
:root {
  --bg:          #f7f4ef;
  --surface:     #ffffff;
  --surface-alt: #f0ede6;
  --border:      #ddd8ce;
  --text:        #1a1612;
  --muted:       #8a7f6e;
  --gold:        #8b6914;
  --gold-light:  #c4a35a;
  --gold-bg:     #f5edd9;
  --success:     #2d6b3a;
  --error:       #a83232;

  --sb-bg:       #1e1a14;
  --sb-text:     #c8bfaf;
  --sb-w:        240px;

  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body:    'Source Sans 3', -apple-system, 'Segoe UI', sans-serif;

  --radius:      6px;
  --radius-lg:   10px;
  --shadow:      0 1px 4px rgba(26,22,18,.08);
  --shadow-md:   0 4px 16px rgba(26,22,18,.12);
  --ease:        0.17s ease;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  line-height: 1.25;
  font-weight: 700;
}

a { color: var(--gold); }
a:hover { color: var(--gold-light); }

/* ─── Shell ─────────────────────────────────────────────── */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sb-w);
  flex-shrink: 0;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--ease);
  z-index: 200;
}

.sidebar-logo {
  padding: 1.5rem 1.25rem 1.125rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-logo h1 {
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  color: var(--gold-light);
  line-height: 1.35;
}

.sidebar-logo span {
  font-size: 0.6875rem;
  color: var(--sb-text);
  opacity: .5;
  text-transform: uppercase;
  letter-spacing: .09em;
}

.sidebar-nav { flex: 1; padding: .875rem 0; }

.nav-group { margin-bottom: 1.25rem; }

.nav-group-label {
  display: block;
  font-size: .625rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sb-text);
  opacity: .35;
  padding: 0 1.25rem .375rem;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: .4375rem 1.25rem;
  color: var(--sb-text);
  text-decoration: none;
  font-size: .875rem;
  border-left: 2px solid transparent;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
  line-height: 1.4;
}

.nav-item:hover {
  background: rgba(196,163,90,.08);
  color: var(--gold-light);
}

.nav-item.active {
  background: rgba(196,163,90,.13);
  color: var(--gold-light);
  border-left-color: var(--gold);
  font-weight: 600;
}

.sidebar-footer {
  padding: .875rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.sidebar-user {
  font-size: .8125rem;
  color: var(--sb-text);
  opacity: .6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── App Body ──────────────────────────────────────────── */
.app-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ─── Topbar ────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 52px;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-title {
  font-family: var(--font-heading);
  font-size: 1.0625rem;
  font-weight: 700;
  flex: 1;
}

.topbar-actions { display: flex; gap: .5rem; align-items: center; }

.burger {
  display: none;
  background: none; border: none;
  cursor: pointer;
  padding: .25rem;
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
}

/* ─── Main Content ──────────────────────────────────────── */
.main-content { flex: 1; overflow-y: auto; padding: 1.75rem 1.5rem; }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .4375rem .875rem;
  border: none; border-radius: var(--radius);
  font-size: .875rem; font-weight: 600; font-family: inherit;
  cursor: pointer; text-decoration: none;
  transition: background var(--ease), opacity var(--ease);
  white-space: nowrap; line-height: 1.4;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary   { background: var(--gold);        color: #fff; }
.btn-primary:hover  { background: #7a5c12; }

.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-danger    { background: var(--error);       color: #fff; }
.btn-danger:hover { background: #8c2929; }

.btn-warning   { background: #b06800; color: #fff; }
.btn-warning:hover { background: #8a5100; }

.btn-ghost     { background: transparent;        color: var(--muted); }
.btn-ghost:hover { background: var(--surface-alt); }

.btn-sm  { padding: .25rem .625rem; font-size: .8125rem; }
.btn-xs  { padding: .125rem .5rem;  font-size: .75rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-action-icon { display: none; }

.btn-logout {
  background: transparent;
  border: 1px solid rgba(255,255,255,.15);
  color: var(--sb-text);
  padding: .25rem .625rem;
  border-radius: var(--radius);
  font-size: .75rem; cursor: pointer; font-family: inherit;
  transition: background var(--ease);
}
.btn-logout:hover { background: rgba(255,255,255,.08); }

/* ─── Forms ─────────────────────────────────────────────── */
.form-group { margin-bottom: 1.125rem; }

.form-group label {
  display: block;
  font-size: .75rem; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: .375rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="number"],
textarea, select {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .9375rem; font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color var(--ease), box-shadow var(--ease);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(139,105,20,.12);
}

input[type="number"] { font-family: 'Source Code Pro', monospace; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

.form-inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.form-inline input[type="text"],
.form-inline select { width: auto; flex: 1 1 180px; }

.checkbox-label {
  display: flex; align-items: center; gap: .375rem;
  font-size: .875rem; cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: auto; }

/* ─── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.card-link {
  text-decoration: none; color: var(--text); display: block;
  transition: box-shadow var(--ease), border-color var(--ease);
}
.card-link:hover { box-shadow: var(--shadow-md); border-color: var(--gold-light); }
.card-link:hover .card-title { color: var(--gold); }

.card-title { font-weight: 600; margin-bottom: .25rem; }
.card-desc  { font-size: .8125rem; color: var(--muted); }

/* ─── KPI Cards ─────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: .6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin-bottom: .5rem;
}

.kpi-value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.625rem; font-weight: 700; line-height: 1;
}

.kpi-value.pos  { color: var(--success); }
.kpi-value.neg  { color: var(--error); }
.kpi-value.gold { color: var(--gold); }

.kpi-sub { font-size: .8125rem; color: var(--muted); margin-top: .375rem; }

/* ─── Tables ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; font-size: .875rem; background: var(--surface); }

thead th {
  text-align: left;
  padding: .625rem .875rem;
  font-size: .6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  white-space: nowrap;
}

th.num, td.num {
  text-align: right;
  font-family: 'Source Code Pro', monospace;
}

tbody td {
  padding: .6875rem .875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #faf8f4; }

tfoot td {
  padding: .6875rem .875rem;
  border-top: 2px solid var(--border);
  background: var(--surface-alt);
  vertical-align: middle;
}

.num-pos { color: var(--success); }
.num-neg { color: var(--error); }

/* ─── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .125rem .5rem; border-radius: 999px;
  font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap;
}

.badge-green  { background: #daf0e0; color: #1a5c29; }
.badge-red    { background: #f5e0e0; color: #8c1c1c; }
.badge-gray   { background: var(--surface-alt); color: var(--muted); }
.badge-gold   { background: var(--gold-bg); color: var(--gold); }
.badge-blue   { background: #e3eeff; color: #1d46a8; }

/* ─── Alerts ────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius);
  margin-bottom: 1rem; font-size: .875rem;
  border-left: 3px solid;
}
.alert-success { background: #eef7f1; color: #1a5c29; border-color: var(--success); }
.alert-error   { background: #f8eaea; color: #8c1c1c; border-color: var(--error); }

/* ─── Toast ─────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: 1rem; right: 1rem; z-index: 9999;
  display: flex; flex-direction: column; gap: .5rem;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem 1.125rem;
  font-size: .875rem; font-weight: 500;
  box-shadow: var(--shadow-md);
  pointer-events: all; max-width: 320px;
  animation: toast-in .18s ease;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--error); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(.75rem); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Login ─────────────────────────────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1.5rem;
  background: var(--bg);
}

.login-wrap {
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; align-items: center; gap: 1.5rem;
}

.login-brand {
  display: flex; align-items: center; gap: .875rem;
}
.login-brand-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--sb-bg); color: var(--gold-light);
  font-family: var(--font-heading); font-size: 1.375rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.login-brand-name {
  font-family: var(--font-heading); font-size: 1.125rem;
  color: var(--text); font-weight: 600;
}
.login-brand-sub { font-size: .8125rem; color: var(--muted); margin-top: 1px; }

.login-box {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 2rem 2rem 1.75rem; width: 100%;
  box-shadow: var(--shadow-md);
}

.login-title {
  font-family: var(--font-heading);
  font-size: 1.1875rem; color: var(--text);
  margin-bottom: 1.5rem; font-weight: 600;
}

.login-remember {
  display: flex; align-items: center; gap: .5rem;
  margin-top: .875rem; cursor: pointer;
  font-size: .875rem; color: var(--text-secondary);
}
.login-remember input[type="checkbox"] {
  width: 15px; height: 15px; cursor: pointer; accent-color: var(--gold);
}

.login-footer {
  font-size: .75rem; color: var(--muted); text-align: center;
}

/* ─── Einstellungen ─────────────────────────────────────── */
.settings-section { margin-bottom: 2.5rem; }
.settings-section h2 { font-size: 1.0625rem; margin-bottom: 1.125rem; }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 2.25rem 0; }

/* ─── Page Header ───────────────────────────────────────── */
.page-header { margin-bottom: 1.75rem; }
.page-header h2 { font-size: 1.625rem; }
.page-header p  { color: var(--muted); margin-top: .25rem; font-size: .9375rem; }

.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* ─── Utilities ─────────────────────────────────────────── */
.text-muted    { color: var(--muted); font-size: .875rem; }
.mwst-info     { font-size: .8125rem; color: var(--muted); margin-top: .375rem; }
.ppn-row { display: flex; align-items: center; gap: .375rem; margin-top: .375rem; }
.ppn-row input { width: 130px; font-size: .8125rem; padding: .25rem .5rem; }
.text-right    { text-align: right; }
.mono          { font-family: 'Source Code Pro', monospace; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem;  }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; align-items: center; }

/* ─── Design Picker ─────────────────────────────────────── */
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 1rem;
  margin-bottom: .25rem;
}

.color-field label {
  display: block;
  font-size: .75rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: .375rem;
}

.color-input-row { display: flex; align-items: center; gap: .625rem; }

.color-picker {
  width: 44px; height: 36px;
  padding: 2px 3px;
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; background: var(--surface);
}

.color-hex {
  font-family: 'Source Code Pro', monospace;
  font-size: .8125rem; color: var(--muted);
}

.settings-sub-heading {
  font-size: .75rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: .875rem;
}

/* ─── Detail List ───────────────────────────────────────── */
.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .25rem .875rem;
  font-size: .875rem;
}
.detail-list dt {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding-top: .125rem;
}
.detail-list dd { color: var(--text); }

/* ─── Rechnung Totals ───────────────────────────────────── */
.rechnung-totals {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  border-top: 1px solid var(--border);
  padding-top: .75rem;
  margin-top: .75rem;
}
.rechnung-total-row {
  display: flex;
  justify-content: space-between;
  font-size: .875rem;
  padding: .125rem 0;
}
.rechnung-total-sum {
  border-top: 1px solid var(--border);
  padding-top: .5rem;
  margin-top: .25rem;
  font-weight: 700;
  font-size: .9375rem;
}
.rechnung-total-final {
  border-top: 2px solid var(--gold);
  padding-top: .5rem;
  margin-top: .25rem;
  font-weight: 700;
  color: var(--gold);
  font-size: 1rem;
}

/* ─── Mobile ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }

  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45); z-index: 199;
  }
  .sidebar-overlay.open { display: block; }

  .burger { display: block; }

  /* Topbar: Burger links, Titel absolut zentriert, Aktionen rechts */
  .topbar { position: relative; padding: 0 .875rem; }
  .topbar-title {
    position: absolute; left: 50%; transform: translateX(-50%);
    flex: none; max-width: 55%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }

  .main-content { padding: 1.25rem 1rem; }
  .kpi-grid, .card-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .color-grid { grid-template-columns: 1fr 1fr; }

  /* Touch-Targets: mind. 44px */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .btn-xs { min-height: 32px; }
  input[type="text"], input[type="password"], input[type="email"],
  input[type="date"], input[type="number"], textarea, select { min-height: 44px; }

  /* Tabellen horizontal scrollen */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .table-wrap table { white-space: nowrap; }

  /* Tabellenaktionen: nur Icons auf Mobile */
  .btn-action-text { display: none; }
  .btn-action-icon { display: inline; }
}

@media (max-width: 480px) {
  .kpi-grid, .card-grid { grid-template-columns: 1fr; }
  .color-grid { grid-template-columns: 1fr; }
}
