/* =============================================================================
   Veloratio – Web-Portal
   Baut auf ../style.css auf (Farben, Buttons, Formularfelder, Hinweise).
   ============================================================================= */

body.portal { background: var(--bg); }
/* Die Website gibt jedem <section> großen Abstand; im Portal nicht. */
.portal .view section:not(.card) { padding: 0; }
.portal [hidden] { display: none !important; }
.portal-noscript { padding: var(--space-4); text-align: center; }

/* ── Anmeldung ─────────────────────────────────────────────────────────── */
.login {
    min-height: 100vh; display: grid; place-content: center; gap: var(--space-3);
    padding: var(--space-4) 16px; position: relative; isolation: isolate;
}
.login::before {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(600px 400px at 85% 15%, rgba(77,182,172,.18), transparent 70%),
        radial-gradient(520px 360px at 10% 90%, rgba(26,35,126,.08), transparent 70%);
}
.login-card {
    width: min(420px, 100%); background: var(--surface); border: 1px solid var(--divider);
    border-radius: var(--radius-xl); box-shadow: var(--shadow-lift); padding: var(--space-4);
}
.login-card h1 { font-size: 1.75rem; margin: var(--space-3) 0 6px; }
.login-lead { color: var(--text-muted); font-size: 0.9375rem; margin-bottom: var(--space-3); }
.login-foot { margin-top: var(--space-3); font-size: 0.8125rem; color: var(--text-muted); line-height: 1.5; }
.login-legal { text-align: center; font-size: 0.8125rem; color: var(--text-muted); }
.login-legal a:hover { color: var(--navy); }

/* ── Grundgerüst ───────────────────────────────────────────────────────── */
/* minmax(0, 1fr): breite Tabellen scrollen in ihrem Rahmen, statt die Seite zu verbreitern. */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
    background: var(--navy); color: #fff; padding: 22px 14px;
}
.brand-light { color: #fff; padding: 0 10px; margin-bottom: var(--space-4); }
.side-nav { display: grid; gap: 4px; }
.side-nav a {
    display: flex; align-items: center; min-height: 44px; padding: 0 14px;
    border-radius: var(--radius-sm); color: var(--text-on-dark-muted); font-weight: 600; font-size: 0.9375rem;
}
.side-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-nav a.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 var(--teal-light); }
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.14); display: grid; gap: 8px; }
.side-user { font-size: 0.8125rem; color: var(--text-on-dark-muted); overflow-wrap: anywhere; }
.side-logout {
    justify-self: start; background: none; border: 1px solid rgba(255,255,255,.35); color: #fff;
    border-radius: var(--radius-sm); min-height: 40px; padding: 0 14px; cursor: pointer; font-weight: 600; font-size: 0.875rem;
}
.side-logout:hover { background: rgba(255,255,255,.1); }

.view { min-width: 0; padding: var(--space-4) clamp(16px, 4vw, 48px) var(--space-8); max-width: 1180px; width: 100%; outline: none; }
.loading { color: var(--text-muted); padding: var(--space-4) 0; }

@media (max-width: 860px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: sticky; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 16px; }
    .brand-light { margin: 0; padding: 0; }
    .side-nav { order: 3; width: 100%; display: flex; overflow-x: auto; gap: 4px; scrollbar-width: none; }
    .side-nav a { flex: none; min-height: 40px; padding: 0 12px; }
    .side-nav a.active { box-shadow: inset 0 -3px 0 var(--teal-light); }
    .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; }
    .side-user { display: none; }
}

/* ── Seitenkopf, Karten, Tabellen ──────────────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--space-3); }
.page-head h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
.page-actions, .button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button-row { margin-top: var(--space-3); }
.back { display: inline-flex; min-height: 40px; align-items: center; color: var(--navy); font-weight: 600; font-size: 0.9375rem; }
.muted { color: var(--text-muted); }
.small { font-size: 0.8125rem; }
.center { text-align: center; }
.portal .notice { margin-bottom: var(--space-3); }
.portal .notice ul { margin: 6px 0 0 18px; }

.card {
    background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card); padding: var(--space-3); margin-bottom: var(--space-3);
}
.card h2 { font-size: 1.0625rem; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.link { background: none; border: 0; padding: 6px 4px; color: var(--navy); font-weight: 600; cursor: pointer; font-size: 0.875rem; }
.link:hover { text-decoration: underline; }
.link.danger { color: #C62828; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); margin-bottom: var(--space-3); }
.kpi { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-lg); padding: 18px 20px; display: grid; gap: 4px; box-shadow: var(--shadow-card); }
.kpi-label { font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.5rem; color: var(--navy); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi-hint { font-size: 0.8125rem; color: var(--text-muted); }
@media (max-width: 980px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .kpis { grid-template-columns: 1fr; } }

.bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; align-items: end; height: 200px; }
.bar { display: grid; grid-template-rows: auto 1fr auto; align-items: end; justify-items: center; height: 100%; gap: 6px; }
.bar-fill { width: min(48px, 70%); min-height: 3px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--teal-light), var(--teal)); align-self: end; }
.bar-value { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-label { font-size: 0.8125rem; color: var(--text-muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar input, .toolbar select, .portal .field input, .portal .field textarea, .portal .field select, .edit-table input, .edit-table select {
    font: inherit; font-size: 0.9375rem; background: var(--surface); border: 1px solid var(--divider);
    border-radius: var(--radius-sm); padding: 10px 12px; min-height: 44px; color: var(--text);
}
.toolbar input { flex: 1 1 260px; }
.portal .field textarea { width: 100%; resize: vertical; min-height: 0; }
.portal .field input, .portal .field select { width: 100%; }
.toolbar input:focus, .toolbar select:focus, .portal .field textarea:focus, .edit-table input:focus, .edit-table select:focus {
    outline: none; border-color: var(--navy); box-shadow: var(--shadow-focus);
}

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-lg); }
.card .table-wrap { border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--divider); background: var(--surface-alt); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td, tr.clickable:focus td { background: rgba(26,35,126,.04); }
tr.clickable:focus { outline: 2px solid var(--navy); outline-offset: -2px; }
.row-actions { text-align: right; white-space: nowrap; }
.sum { text-align: right; padding: 12px 14px; font-weight: 700; border-top: 1px solid var(--divider); font-variant-numeric: tabular-nums; }
.empty { padding: var(--space-6) 0; text-align: center; display: grid; gap: 12px; justify-items: center; }

.chip { display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: .03em; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
/* Schriftfarben wie in der App (app_theme.dart statusTextColor) — kontrastgeprüft. */
.chip-paid { background: rgba(76,175,80,.14); color: #1B5E20; }
.chip-overdue { background: rgba(229,57,53,.12); color: #B71C1C; }
.chip-pending { background: rgba(26,35,126,.08); color: var(--navy); }

/* ── Rechnungsdetail ───────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.detail-grid .card { margin-bottom: 0; }
.detail-grid + .card { margin-top: var(--space-3); }
@media (max-width: 760px) { .detail-grid { grid-template-columns: minmax(0, 1fr); } }
.address { white-space: pre-line; font-weight: 600; margin-bottom: 10px; }
.info { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--divider); font-size: 0.9375rem; }
.info-label { color: var(--text-muted); }
.info-value { text-align: right; overflow-wrap: break-word; min-width: 0; }
.info select { font: inherit; border: 1px solid var(--divider); border-radius: var(--radius-sm); padding: 6px 10px; min-height: 40px; background: var(--surface); }

.totals { margin: var(--space-2) 0 0 auto; max-width: 340px; display: grid; gap: 6px; }
.total-row { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.total-row.strong { font-weight: 700; color: var(--navy); font-size: 1.0625rem; padding-top: 8px; border-top: 2px solid var(--navy); }

/* ── Formulare ─────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-3); }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.edit-table td { padding: 6px; border-bottom: 0; }
.edit-table .w-full { width: 100%; min-width: 200px; }
.edit-table .w-num { width: 110px; text-align: right; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--divider); background: var(--surface); cursor: pointer; font-size: 1.25rem; line-height: 1; color: var(--text-muted); }
.icon-btn:hover { color: #C62828; border-color: #C62828; }
.card > .btn { margin-top: 12px; }

.dialog {
    /* margin: auto zentriert — der Reset in style.css setzt margin sonst auf 0. */
    margin: auto; max-height: calc(100vh - 32px); overflow-y: auto;
    border: 0; border-radius: var(--radius-xl); padding: var(--space-4); width: min(640px, calc(100vw - 32px));
    box-shadow: 0 24px 64px rgba(13,27,42,.28); color: var(--text);
}
.dialog::backdrop { background: rgba(13,27,42,.45); }
.dialog h2 { margin-bottom: var(--space-3); font-size: 1.25rem; }

.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
    background: var(--navy-dark); color: #fff; padding: 12px 18px; border-radius: var(--radius);
    box-shadow: var(--shadow-lift); font-size: 0.9375rem; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
    max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #B71C1C; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ── Team und Entwürfe ─────────────────────────────────────────────────── */
.side-role { font-size: 0.75rem; color: var(--teal-light); font-weight: 700; letter-spacing: .03em; }
.badge {
    margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
    background: var(--teal-light); color: var(--navy-dark); font-size: 0.75rem; font-weight: 800;
    display: inline-grid; place-items: center;
}
.draft-list { display: grid; gap: var(--space-2); }
.draft-list .card { margin-bottom: 0; }
.card-new { box-shadow: inset 4px 0 0 var(--teal), var(--shadow-card); }
.chip-draft-new { background: rgba(0,137,123,.12); color: #00695C; }
.chip-draft-done { background: rgba(76,175,80,.14); color: #1B5E20; }
.chip-draft-rejected { background: rgba(107,114,128,.14); color: #374151; }
.plain-list { list-style: none; display: grid; gap: 4px; margin-top: 8px; }
.invite-code {
    font-size: clamp(1.75rem, 6vw, 2.5rem); font-weight: 800; letter-spacing: .12em; color: var(--navy);
    font-variant-numeric: tabular-nums; text-align: center; padding: 18px; margin: 8px 0 12px;
    background: var(--bg); border: 2px dashed rgba(26,35,126,.25); border-radius: var(--radius);
    user-select: all;
}
.steps-list { margin: 12px 0 0 20px; display: grid; gap: 6px; font-size: 0.9375rem; }
@media (max-width: 860px) { .side-role { display: none; } .badge { margin-left: 6px; } }
