 :root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f172a;
  --primary-contrast: #ffffff;
  --secondary: #eef2ff;
  --danger: #b91c1c;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: none;
  background: var(--primary);
  color: var(--primary-contrast);
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
}
button.secondary {
  background: var(--secondary);
  color: var(--text);
}
button.danger {
  background: var(--danger);
  color: #fff;
}
button:hover { opacity: 0.95; }

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
textarea { min-height: 90px; resize: vertical; }

#app-shell {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #111827;
  color: white;
  padding: 24px;
}
.brand h1 { margin: 0 0 4px 0; }
.brand p { margin: 0; color: #cbd5e1; }
.sidebar-section { margin-top: 24px; }
.sidebar label { display: block; margin-bottom: 8px; font-weight: 700; }
.nav { margin-top: 26px; display: grid; gap: 10px; }
.nav-btn,
.nav-group-toggle {
  text-align: left;
  background: rgba(255,255,255,0.08);
  width: 100%;
}
.nav-group-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-btn.active,
.nav-group-toggle.active {
  background: #fff;
  color: #111827;
}
.subnav {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding-left: 14px;
}
.subnav.collapsed { display: none; }
.subnav-btn {
  background: rgba(255,255,255,0.12);
  font-size: 0.98rem;
}
.chevron { transition: transform 0.18s ease; }
.chevron.open { transform: rotate(180deg); }
.small-text { font-size: 0.9rem; color: var(--muted); }
.sidebar .small-text { color: #cbd5e1; }

.content { padding: 28px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h2 { margin: 0 0 6px 0; }
.topbar p { margin: 0; color: var(--muted); }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.grid { display: grid; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gap-md { gap: 12px; }
.gap-lg { gap: 22px; }
.stack-md > * + * { margin-top: 12px; }
.booking-form .field { display: grid; gap: 6px; }
.field-label { font-size: 0.92rem; font-weight: 700; color: var(--text); }

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.checkbox-field input {
  width: auto;
  margin: 2px 0 0 0;
}
.checkbox-field span {
  font-size: 0.95rem;
  line-height: 1.35;
}
.form-grid { display: grid; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.top-gap { margin-top: 22px; }
.button-row { display: flex; gap: 8px; }
.button-row.wrap { flex-wrap: wrap; justify-content: flex-end; }
.align-right { text-align: right; }
.right-column { align-items: flex-end; flex-direction: column; }

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.list-item p, .list-item strong { margin: 0 0 6px 0; }
.list-item.compact { align-items: center; }
.invoice-list-main { flex: 1 1 auto; min-width: 0; }

.invoice-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}
.invoice-list-item .invoice-list-main {
  min-width: 0;
}

.compact-ledger-item {
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
}
.compact-ledger-item p,
.compact-ledger-item strong {
  margin: 0 0 2px 0;
  line-height: 1.2;
}
.compact-ledger-item .button-row {
  gap: 6px;
}
.compact-ledger-item .right-column {
  min-width: 140px;
}
.small-action-btn {
  padding: 8px 10px;
  border-radius: 10px;
}
.invoice-action-row {
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  margin-left: 0;
}
.invoice-action-row .small-action-btn {
  padding: 5px 9px;
  min-width: 0;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.1;
}
.invoice-paid-note {
  margin-right: 6px;
  white-space: nowrap;
  font-size: 0.92rem;
}
.invoice-preview-actions {
  justify-content: flex-end;
}
.invoice-preview-actions .small-action-btn {
  padding: 8px 12px;
  border-radius: 10px;
}
@media (max-width: 900px) {
  .invoice-action-row {
    justify-content: flex-start;
    min-width: 0;
    flex-wrap: wrap;
  }
}
.ledger-filter-row {
  margin-bottom: 10px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.stat-grid.four-columns { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-grid.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card {
  background: linear-gradient(135deg, #111827, #1e293b);
  color: white;
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat-card span { display: block; color: #cbd5e1; margin-bottom: 8px; }
.stat-card strong { font-size: 1.3rem; }

.tab-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.tab-btn {
  background: #e2e8f0;
  color: var(--text);
}
.tab-btn.active {
  background: var(--primary);
  color: #fff;
}

.top-gap-sm { margin-top: 8px; }

.invoice-number-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.invoice-lock-toggle {
  min-width: 52px;
  padding: 11px 12px;
  font-size: 1.05rem;
}

.readonly-like {
  background: #f8fafc;
}

.invoice-position-list {
  display: grid;
  gap: 10px;
}
.invoice-position-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
  padding: 12px;
}
.invoice-position-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.invoice-position-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(120px, 0.6fr) minmax(160px, 0.8fr);
  gap: 10px;
}
.position-description-field {
  min-width: 0;
}



button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.fieldset-reset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.lock-notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.year-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.year-head-actions {
  gap: 8px;
}

.icon-button {
  padding: 6px 10px;
  border-radius: 10px;
  min-width: 44px;
}

.toast {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

code {
  background: rgba(255,255,255,0.12);
  padding: 2px 6px;
  border-radius: 8px;
}

ul { padding-left: 20px; }

@media (max-width: 1200px) {
  .stat-grid,
  .stat-grid.four-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  #app-shell { grid-template-columns: 1fr; }
  .sidebar { padding-bottom: 12px; }
  .two-columns, .three-columns, .stat-grid, .stat-grid.four-columns, .form-grid-3 { grid-template-columns: 1fr; }
}


.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h3 {
  margin: 0;
}

.ledger-mode-switch {
  justify-content: flex-end;
}

.ledger-preview {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

.ledger-preview-title {
  background: #000;
  color: #fff;
  padding: 8px 12px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
}

.ledger-preview-scroll {
  overflow: auto;
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 740px;
  font-size: 0.9rem;
}

.ledger-table th,
.ledger-table td {
  border: 1px solid #cbd5e1;
  padding: 5px 7px;
  vertical-align: top;
  line-height: 1.2;
}

.ledger-table thead th {
  background: #f1f5f9;
  font-weight: 700;
}

.ledger-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.ledger-table .carryover-row {
  background: #fff7ed;
}

.income-cell {
  color: #15803d;
  white-space: nowrap;
}

.expense-cell {
  color: #b91c1c;
  white-space: nowrap;
}

.ledger-empty {
  text-align: center;
  color: var(--muted);
}


.panel-head-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head-stack h3 {
  margin: 0;
}

.ledger-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.ledger-mode-switch,
.ledger-export-switch {
  justify-content: flex-start;
}

.ledger-export-btn {
  background: #e2e8f0;
  color: var(--text);
}


.edit-notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}


.ledger-filter-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: end;
}

.ledger-inline-field {
  margin: 0;
  min-width: 220px;
}

.ledger-search-field {
  flex: 1 1 260px;
}

.ledger-inline-field .field-label {
  margin-bottom: 6px;
}


.ledger-period-row {
  margin-bottom: 12px;
}

.ledger-period-row .ledger-inline-field {
  min-width: 240px;
}

.modal-open {
  overflow: hidden;
}

.invoice-modal.hidden {
  display: none;
}

.invoice-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.62);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
  padding: 28px;
}

.invoice-modal-dialog {
  width: min(1180px, 100%);
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.25);
  padding: 20px;
}

.prompt-modal-dialog {
  width: min(560px, 100%);
}

.prompt-dialog-form {
  max-width: 420px;
}

.invoice-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.invoice-modal-header h3 {
  margin: 0 0 4px 0;
}

.invoice-preview-surface {
  background: #e5e7eb;
  border-radius: 18px;
  padding: 24px;
  overflow: auto;
}

.invoice-preview-root {
  display: flex;
  justify-content: center;
}

.invoice-document {
  width: 794px;
  min-height: 1123px;
  height: 1123px;
  margin: 0 auto;
  background: #fff;
  color: #111;
  padding: 56px 70px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
}

.invoice-topline {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
}

.invoice-head {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  min-height: 170px;
}

.invoice-recipient {
  font-size: 14px;
  line-height: 1.45;
}

.invoice-meta {
  min-width: 280px;
  text-align: right;
  font-size: 14px;
  line-height: 1.55;
}

.invoice-number-bar {
  margin: 20px 0 20px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  background: #000;
  color: #fff;
  padding: 8px 12px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.invoice-letter {
  font-size: 15px;
  line-height: 1.45;
}

.invoice-letter p {
  margin: 0 0 10px 0;
}

.invoice-after-table {
  margin-top: 18px;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 14px;
}

.invoice-table th {
  background: #000;
  color: #fff;
  padding: 8px 8px;
  border: 2px solid #000;
  text-align: left;
}

.invoice-table td {
  padding: 8px 8px;
  border: 2px solid #111;
  vertical-align: top;
}

.invoice-table .col-pos {
  width: 10%;
}

.invoice-table .col-qty {
  width: 12%;
}

.invoice-table .col-price,
.invoice-table .col-total {
  width: 15%;
}

.invoice-desc-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.invoice-total-row td {
  padding-top: 6px;
  padding-bottom: 6px;
}

.invoice-total-label {
  text-align: center;
}

.invoice-grand-total-row td {
  background: #000;
  color: #fff;
  font-weight: 700;
  border-color: #000;
  padding-top: 6px;
  padding-bottom: 6px;
}

.invoice-legal-block {
  margin-top: 18px;
  font-size: 12.5px;
  line-height: 1.45;
}

.invoice-legal-block div + div {
  margin-top: 4px;
}

.invoice-signature {
  margin-top: 28px;
  font-size: 15px;
}

.invoice-signature p {
  margin: 0 0 8px 0;
}

.invoice-signature-space {
  height: 66px;
}

.invoice-footer {
  margin-top: 40px;
}

.invoice-footer-line {
  height: 9px;
  background: #000;
  margin-bottom: 12px;
}

.invoice-footer-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.invoice-footer-col {
  text-align: center;
  font-size: 12px;
  line-height: 1.4;
}

.invoice-footer-icon-wrap {
  margin-bottom: 10px;
}

.invoice-footer-icon {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.invoice-footer-strong {
  font-weight: 700;
}

.invoice-footer-strong,
.invoice-footer-iban {
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .invoice-modal {
    padding: 16px;
  }

  .invoice-modal-dialog {
    padding: 16px;
  }
}


#invoice-preview-canvas {
  display: flex;
  justify-content: center;
}

.invoice-preview-frame {
  width: 842px;
  max-width: 100%;
  height: 1168px;
  border: 0;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
}


.member-sepa-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
  padding: 14px;
}
.member-sepa-box h4 {
  margin: 0 0 10px 0;
}
.member-list-item .right-column {
  min-width: 132px;
}


.member-detail-item {
  align-items: flex-start;
}
.member-detail-actions {
  min-width: 230px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.compact-action-field {
  margin: 0;
}
.compact-action-field .field-label {
  margin-bottom: 4px;
}
.compact-action-field input,
.compact-action-field select {
  padding: 8px 10px;
}
.member-paid-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: #dcfce7;
  color: #166534;
  font-weight: 700;
}
.disabled-field {
  opacity: 0.8;
}
@media (max-width: 1100px) {
  .member-detail-item {
    flex-direction: column;
  }
  .member-detail-actions {
    min-width: 0;
    width: 100%;
  }
}

.auth-sidebar-box {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,0.04);
}
.auth-sidebar-box .button-row {
  justify-content: flex-start;
}
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  border-radius: 12px;
  text-decoration: none;
  background: rgba(255,255,255,0.12);
  color: inherit;
}
.content .ghost-link,
.login-card .ghost-link {
  background: var(--secondary);
  color: var(--text);
}
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #e2e8f0, #f8fafc);
}
.login-shell {
  width: 100%;
  max-width: 520px;
}
.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.muted-copy {
  color: var(--muted);
}
.inline-message {
  min-height: 24px;
  color: var(--muted);
}
.inline-message.error {
  color: var(--danger);
  font-weight: 700;
}
.inline-message.success {
  color: #0c7a43;
  font-weight: 700;
}

@media (max-width: 980px) {
  #app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    padding-bottom: 16px;
  }
}

.session-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.session-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #edf2fb;
  color: #0f2347;
  font-weight: 700;
  font-size: 0.92rem;
}

.session-chip.muted {
  background: #f3f6fb;
  color: #54657e;
}

.empty-state-card {
  max-width: 980px;
}

.admin-guard {
  border: 1px solid #d9e2ef;
  border-radius: 18px;
  padding: 18px 20px;
  background: #fff7ed;
}

.admin-guard.good {
  background: #eefbf3;
}

.admin-guard.bad {
  background: #fff1f0;
}
