:root {
    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-text: #1c1e21;
    --color-muted: #6b7280;
    --color-border: #e2e4e9;
    --color-primary: #1f6f50;
    --color-primary-dark: #16543c;
    --color-error-bg: #fdecea;
    --color-error-text: #9c2b1f;
    --color-success-bg: #e8f5ec;
    --color-success-text: #1f6f50;
    --color-info-bg: #eaf1fb;
    --color-info-text: #234f8a;
    /* Kategoriale Farbreihe (fest, nie rotierend zugewiesen) fuer Produktgruppen-Badges. */
    --cat-0: #2a78d6;
    --cat-1: #eb6834;
    --cat-2: #1baf7a;
    --cat-3: #eda100;
    --cat-4: #e87ba4;
    --cat-5: #008300;
    --cat-6: #4a3aa7;
    --cat-7: #e34948;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--color-primary-dark);
    text-decoration: none;
}

.site-header nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.site-header nav a.nav-link {
    color: var(--color-text);
    text-decoration: none;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.site-header nav a.nav-link:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: var(--color-surface);
}

.user-info {
    color: var(--color-muted);
    font-size: 0.9rem;
}

.container {
    /* Selbstanpassend: 92% der Fensterbreite mit angemessenem Randabstand, nach oben durch
       max-width gedeckelt, damit Zeilen auf sehr breiten Bildschirmen nicht ausufern. */
    width: 92%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 0;
}

h1 {
    margin-top: 0;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.card label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.card input[type="text"],
.card input[type="email"],
.card input[type="password"],
.card input[type="number"],
.card select,
.card textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

.card .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400;
}

.card button,
.inline-form button {
    margin-top: 1rem;
    padding: 0.55rem 1.1rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    align-self: flex-start;
}

.card button:hover,
.inline-form button:hover {
    background: var(--color-primary-dark);
}

.card button:disabled {
    background: var(--color-border);
    color: var(--color-muted);
    cursor: not-allowed;
}

.amount-row {
    display: flex;
    gap: 0.5rem;
}

.radio-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.amount-row input {
    flex: 1;
}

.amount-row select {
    flex: 1;
}

.amount-row .remove-price-leg {
    flex: 0 0 auto;
}

.text-muted {
    color: var(--color-muted);
    font-size: 0.85rem;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.category-dot {
    display: inline-block;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    margin-right: 0.4rem;
    flex: 0 0 auto;
}

.category-dot.cat-0 { background: var(--cat-0); }
.category-dot.cat-1 { background: var(--cat-1); }
.category-dot.cat-2 { background: var(--cat-2); }
.category-dot.cat-3 { background: var(--cat-3); }
.category-dot.cat-4 { background: var(--cat-4); }
.category-dot.cat-5 { background: var(--cat-5); }
.category-dot.cat-6 { background: var(--cat-6); }
.category-dot.cat-7 { background: var(--cat-7); }

/* Waehrungsspalten im Markt: gleiche kategoriale Farbreihe wie die Produktkategorie-Punkte,
   aber viertel-transparent als Spaltenhintergrund - macht die Spalten klar unterscheidbar,
   ohne den Text zu uebertoenen. Spezifischer als ".table th" (das sonst dessen eigenen
   Hintergrund gewinnen wuerde), damit die Faerbung in Kopf- UND Datenzeilen greift. */
.table th.currency-col-0, .table td.currency-col-0 { background: color-mix(in srgb, var(--cat-0) 25%, transparent); }
.table th.currency-col-1, .table td.currency-col-1 { background: color-mix(in srgb, var(--cat-1) 25%, transparent); }
.table th.currency-col-2, .table td.currency-col-2 { background: color-mix(in srgb, var(--cat-2) 25%, transparent); }
.table th.currency-col-3, .table td.currency-col-3 { background: color-mix(in srgb, var(--cat-3) 25%, transparent); }
.table th.currency-col-4, .table td.currency-col-4 { background: color-mix(in srgb, var(--cat-4) 25%, transparent); }
.table th.currency-col-5, .table td.currency-col-5 { background: color-mix(in srgb, var(--cat-5) 25%, transparent); }
.table th.currency-col-6, .table td.currency-col-6 { background: color-mix(in srgb, var(--cat-6) 25%, transparent); }
.table th.currency-col-7, .table td.currency-col-7 { background: color-mix(in srgb, var(--cat-7) 25%, transparent); }

.link-button {
    background: none;
    border: none;
    color: var(--color-primary);
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-size: 0.9rem;
    margin: 0.25rem 0 1rem;
    display: inline-block;
}

.link-button:hover {
    color: var(--color-primary-dark);
}

.multiselect {
    position: relative;
    margin-bottom: 0.75rem;
}

.multiselect-summary {
    font-size: 0.95rem;
    padding: 0.3rem 0;
}

.multiselect-summary.is-empty {
    color: var(--color-muted);
    font-style: italic;
}

.multiselect-toggle {
    width: 100%;
    text-align: left;
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
}

.multiselect-toggle:hover {
    border-color: var(--color-primary);
}

.multiselect-panel {
    position: absolute;
    z-index: 10;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.multiselect-panel .checkbox-label {
    padding: 0.3rem 0;
}

.remove-price-leg {
    background: none;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.4rem;
}

.remove-price-leg:hover {
    color: var(--color-error-text);
}

.inline-form {
    display: inline;
}

.inline-form button {
    margin-top: 0;
    padding: 0.35rem 0.75rem;
    font-size: 0.9rem;
}

.quantity-input {
    width: 4rem;
    padding: 0.35rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.9rem;
    margin-right: 0.35rem;
}

.table-scroll {
    /* Faellt die Tabelle trotz breitem Container schmaler aus als ihr Inhalt (viele
       Waehrungsspalten, lange Texte), scrollt nur die Tabelle selbst horizontal - nie die
       ganze Seite. */
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}

.table-scroll .table {
    margin-bottom: 0;
}

.table th,
.table td {
    text-align: left;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
}

/* Fuer Tabellen mit vielen kurzen Werten (z.B. der Markt mit einer Spalte je Waehrung):
   Spalten werden lieber breiter, als dass Inhalt umbricht, damit alles in moeglichst wenigen
   Zeilen Platz findet. Bewusst gesetzte <br>-Umbrueche (Name + Detailzeile) bleiben davon
   unberuehrt. Nicht global auf .table, da z.B. lange Beschreibungstexte anderswo sinnvoll
   umbrechen sollen. */
.table-compact th,
.table-compact td {
    white-space: nowrap;
}

.table th {
    background: var(--color-bg);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--color-muted);
}

.table tr:last-child td {
    border-bottom: none;
}

.tabs {
    display: flex;
    gap: 1.5rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1.25rem;
}

.tabs a {
    padding: 0.5rem 0;
    color: var(--color-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.tabs a.active {
    color: var(--color-primary-dark);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

.flash {
    padding: 0.65rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.flash-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.flash-error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

.flash-info {
    background: var(--color-info-bg);
    color: var(--color-info-text);
}

.stat-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.4rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 220px;
    position: relative;
    z-index: 0;
    overflow: hidden;
}

/* Dezentes Hintergrund-Icon je Kachel (assets/icons/*.svg) - passend zum Menuepunkt, rein
   dekorativ (aria-hidden). z-index:-1 zusammen mit dem z-index:0 auf .stat-box sorgt dafuer,
   dass das Icon ÜBER dem weissen Kachel-Hintergrund, aber HINTER Zahl/Beschriftung liegt (die
   als normal fliessender Inhalt sonst IMMER ueber absolut positionierten Geschwistern mit
   z-index:auto laegen wuerden). */
.stat-box-icon {
    position: absolute;
    z-index: -1;
    inset: 0;
    background-repeat: no-repeat;
    background-position: right -10px bottom -10px;
    background-size: 92px 92px;
    opacity: 0.12;
    pointer-events: none;
}

/* Die Zahl ist der eigentliche Blickfang der Kachel - deutlich groesser als die Beschriftung,
   damit trotz der jetzt ebenfalls groesseren Beschriftung eine klare Rangfolge erkennbar bleibt. */
.stat-box strong {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--color-primary-dark);
}

/* Kacheln ohne Zahl (reine Aktions-Kacheln wie "Neues Angebot erstellen") haben nur dieses eine
   <strong> als einziges Kind - dafuer eine massvollere, fuer ganze Phrasen passende Groesse. */
.stat-box strong:only-child {
    font-size: 1.25rem;
    font-weight: 600;
}

.stat-box span {
    font-size: 1.575rem;
    font-weight: 500;
    color: var(--color-text);
    text-align: center;
    margin-top: 0.35rem;
}

.stat-box small {
    font-size: 0.8rem;
    color: var(--color-muted);
    opacity: 0.85;
    margin-top: 0.35rem;
    text-align: center;
}

a.stat-box {
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

a.stat-box:hover {
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

a.stat-box.active {
    border-color: var(--color-primary);
    background: var(--color-info-bg);
}

.site-footer {
    text-align: center;
    color: var(--color-muted);
    font-size: 0.85rem;
    padding: 1.5rem;
}
