/* ------------------------------------------------------------------
   SmartPOS Design-System
   Eine Akzentfarbe (Hauptaktion), neutrale Werkzeug-Buttons, ruhige
   Flächen. Alle Abstände/Ecken über Tokens — keine Inline-Styles.
   ------------------------------------------------------------------ */

:root {
    --sp-font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Sans Arabic", sans-serif;

    --sp-bg: #f4f6f9;
    --sp-surface: #ffffff;
    --sp-surface-2: #f9fafc;
    --sp-border: #e4e8ef;
    --sp-border-strong: #cdd5e0;

    --sp-text: #18212f;
    --sp-text-2: #5b6b82;
    --sp-text-3: #8d99ac;

    --sp-primary: #2457e6;
    --sp-primary-hover: #1b47c4;
    --sp-primary-soft: #e9effd;

    --sp-success: #1f8f4e;
    --sp-success-soft: #e5f5ec;
    --sp-warning: #b96b00;
    --sp-warning-soft: #fff3df;
    --sp-danger: #cf3535;
    --sp-danger-soft: #fdeaea;
    --sp-info: #0f7590;
    --sp-info-soft: #e2f3f8;

    --sp-sidebar: #0f1b2d;
    --sp-sidebar-2: #16243a;
    --sp-sidebar-text: #a9b6c8;
    --sp-sidebar-muted: #66768d;

    --sp-radius: 10px;
    --sp-radius-sm: 7px;
    --sp-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --sp-shadow-lg: 0 20px 50px rgba(6, 12, 28, .35);

    /* Bootstrap-Anbindung */
    --bs-body-font-family: var(--sp-font);
    --bs-body-bg: var(--sp-bg);
    --bs-body-color: var(--sp-text);
    --bs-border-color: var(--sp-border);
    --bs-link-color: var(--sp-primary);
    --bs-link-hover-color: var(--sp-primary-hover);
    --bs-link-color-rgb: 36, 87, 230;
    --bs-link-hover-color-rgb: 27, 71, 196;
    --bs-secondary-color: var(--sp-text-2);
}

html { font-size: 15px; }

html, body {
    font-family: var(--sp-font);
    background: var(--sp-bg);
    color: var(--sp-text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-weight: 650; letter-spacing: -.01em; color: var(--sp-text); }
h1:focus { outline: none; }

a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Seitenkopf ---------- */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.4rem;
}
.page-header h1 { font-size: 1.45rem; margin: 0; }
.page-subtitle { margin: .3rem 0 0; color: var(--sp-text-2); font-size: .92rem; max-width: 70ch; }
.page-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.section-title {
    font-size: .76rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--sp-text-2);
    margin: 1.6rem 0 .6rem;
}

/* ---------- Karten ---------- */
.card {
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    box-shadow: var(--sp-shadow);
    background: var(--sp-surface);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--sp-border);
    padding: .8rem 1.1rem;
    font-weight: 600;
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.card-header .hint { font-weight: 400; color: var(--sp-text-3); font-size: .82rem; }
.card-body { padding: 1.1rem; }
.card-footer { background: var(--sp-surface-2); border-top: 1px solid var(--sp-border); padding: .65rem 1.1rem; font-size: .88rem; }
.card-table > .card-body { padding: 0; }
.card-table .table { margin-bottom: 0; }
.card-table .table > :not(caption) > * > * { padding-inline: 1.1rem; }

/* ---------- Tabellen ---------- */
.table { --bs-table-hover-bg: #f6f8fb; --bs-table-striped-bg: var(--sp-surface-2); color: var(--sp-text); }
.table thead th {
    font-size: .72rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--sp-text-2);
    background: var(--sp-surface-2);
    border-bottom: 1px solid var(--sp-border);
    padding: .6rem .85rem;
    white-space: nowrap;
}
.table > :not(caption) > * > * { padding: .62rem .85rem; border-bottom-color: var(--sp-border); vertical-align: middle; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table .text-end, .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .row-muted { color: var(--sp-text-3); }
.table .row-muted td { text-decoration: line-through; }
.table .row-click { cursor: pointer; }
.table-sm > :not(caption) > * > * { padding: .4rem .65rem; }
.table-nested { background: var(--sp-surface-2); }
.table-nested .table { margin-bottom: 0; background: transparent; }
.table-nested .table thead th { background: transparent; }

/* ---------- Formulare ---------- */
.form-label { font-size: .8rem; font-weight: 600; color: var(--sp-text-2); margin-bottom: .3rem; }
.form-hint { font-size: .78rem; color: var(--sp-text-3); margin-top: .3rem; }
.form-control, .form-select {
    background-color: var(--sp-surface);
    border-color: var(--sp-border-strong);
    border-radius: var(--sp-radius-sm);
    font-size: .92rem;
    padding: .45rem .7rem;
    color: var(--sp-text);
}
.form-control::placeholder { color: var(--sp-text-3); }
.form-control:disabled, .form-select:disabled { background-color: #eef1f5; color: var(--sp-text-2); }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--sp-primary);
    box-shadow: 0 0 0 3px var(--sp-primary-soft);
}
.form-check-input:checked { background-color: var(--sp-primary); border-color: var(--sp-primary); }
.form-control-sm, .form-select-sm { font-size: .85rem; padding: .3rem .55rem; }

.input-icon { position: relative; }
.input-icon > .icon {
    position: absolute;
    inset-inline-start: .7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sp-text-3);
    pointer-events: none;
}
.input-icon > .form-control { padding-inline-start: 2.25rem; }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--sp-success); }
.invalid { outline: 1px solid var(--sp-danger); }
.validation-message { color: var(--sp-danger); font-size: .85rem; }
.validation-errors { color: var(--sp-danger); font-size: .88rem; padding-inline-start: 1.1rem; }

/* ---------- Buttons ---------- */
.btn {
    border-radius: var(--sp-radius-sm);
    font-weight: 500;
    font-size: .9rem;
    padding: .45rem .9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    white-space: nowrap;
}
.btn-sm { font-size: .82rem; padding: .3rem .65rem; }
.btn-lg { font-size: 1.02rem; padding: .65rem 1.3rem; }
.btn-icon { padding: .3rem; width: 2rem; height: 2rem; }
.btn-icon.btn-sm { width: 1.75rem; height: 1.75rem; padding: .2rem; }

.btn-primary {
    --bs-btn-bg: var(--sp-primary);
    --bs-btn-border-color: var(--sp-primary);
    --bs-btn-hover-bg: var(--sp-primary-hover);
    --bs-btn-hover-border-color: var(--sp-primary-hover);
    --bs-btn-active-bg: var(--sp-primary-hover);
    --bs-btn-active-border-color: var(--sp-primary-hover);
    --bs-btn-disabled-bg: #9db0e6;
    --bs-btn-disabled-border-color: #9db0e6;
}
.btn-outline-secondary {
    --bs-btn-color: var(--sp-text);
    --bs-btn-bg: var(--sp-surface);
    --bs-btn-border-color: var(--sp-border-strong);
    --bs-btn-hover-color: var(--sp-text);
    --bs-btn-hover-bg: #f1f4f8;
    --bs-btn-hover-border-color: var(--sp-border-strong);
    --bs-btn-active-color: var(--sp-text);
    --bs-btn-active-bg: #e9edf3;
    --bs-btn-active-border-color: var(--sp-border-strong);
}
.btn-outline-danger {
    --bs-btn-color: var(--sp-danger);
    --bs-btn-bg: var(--sp-surface);
    --bs-btn-border-color: var(--sp-border-strong);
    --bs-btn-hover-color: var(--sp-danger);
    --bs-btn-hover-bg: var(--sp-danger-soft);
    --bs-btn-hover-border-color: #e9b4b4;
    --bs-btn-active-color: var(--sp-danger);
    --bs-btn-active-bg: var(--sp-danger-soft);
    --bs-btn-active-border-color: #e9b4b4;
}
.btn-link { --bs-btn-color: var(--sp-text-2); --bs-btn-hover-color: var(--sp-primary); text-decoration: none; }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--sp-primary-soft); }
.btn-close:focus { box-shadow: none; }

/* ---------- Tags ---------- */
.tag {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .14rem .55rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    line-height: 1.45;
    white-space: nowrap;
}
.tag-neutral { background: #eceff4; color: var(--sp-text-2); }
.tag-primary { background: var(--sp-primary-soft); color: var(--sp-primary); }
.tag-success { background: var(--sp-success-soft); color: var(--sp-success); }
.tag-warning { background: var(--sp-warning-soft); color: var(--sp-warning); }
.tag-danger { background: var(--sp-danger-soft); color: var(--sp-danger); }
.tag-info { background: var(--sp-info-soft); color: var(--sp-info); }

/* ---------- Kennzahlen ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr)); gap: 1rem; }
.kpi {
    background: var(--sp-surface);
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    box-shadow: var(--sp-shadow);
    padding: 1rem 1.15rem;
}
.kpi-label { font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--sp-text-2); }
.kpi-value { font-size: 1.55rem; font-weight: 650; letter-spacing: -.02em; margin-top: .3rem; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .8rem; color: var(--sp-text-3); margin-top: .15rem; }

/* ---------- Auswahl-Listen (Kasse) ---------- */
.pick-list { max-height: 24rem; overflow-y: auto; border: 1px solid var(--sp-border); border-radius: var(--sp-radius-sm); background: var(--sp-surface); }
.pick-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: .6rem .85rem;
    border: 0;
    border-bottom: 1px solid var(--sp-border);
    background: transparent;
    text-align: start;
    color: var(--sp-text);
    font-size: .92rem;
}
.pick-item:last-child { border-bottom: 0; }
.pick-item:hover { background: var(--sp-primary-soft); }
.pick-item .amount { color: var(--sp-text-2); }

.totals { display: flex; flex-direction: column; align-items: flex-end; gap: .1rem; }
.totals .line { display: flex; gap: 1.25rem; font-size: .9rem; color: var(--sp-text-2); }
.totals .line span:first-child { min-width: 5rem; text-align: end; }
.totals .grand { display: flex; gap: 1.25rem; align-items: baseline; font-size: 1.55rem; font-weight: 700; margin-top: .3rem; }
.totals .grand span:first-child { font-size: .9rem; font-weight: 600; color: var(--sp-text-2); }

/* ---------- Meta-Zeilen, Leerzustände, Hinweise ---------- */
.meta { display: flex; flex-wrap: wrap; gap: .45rem .9rem; align-items: center; color: var(--sp-text-2); font-size: .9rem; }
.meta .icon { color: var(--sp-text-3); }

.empty-state { text-align: center; padding: 2.75rem 1rem; color: var(--sp-text-2); }
.empty-state .icon { width: 2.4rem; height: 2.4rem; color: var(--sp-text-3); margin-bottom: .7rem; }
.empty-state p { margin: 0; }

.alert { border-radius: var(--sp-radius-sm); font-size: .9rem; border: 1px solid transparent; }
.alert-info { background: var(--sp-info-soft); color: #0b5a6f; border-color: #bfe0ea; }
.alert-warning { background: var(--sp-warning-soft); color: #7a4600; border-color: #f2ddb3; }
.alert-danger { background: var(--sp-danger-soft); color: #8f2323; border-color: #f0c2c2; }
.alert-success { background: var(--sp-success-soft); color: #145f34; border-color: #bfe3cd; }

.progress { height: .6rem; border-radius: 999px; background: #e6eaf0; }
.progress-bar { background: var(--sp-primary); }
.progress-bar.bg-danger { background: var(--sp-danger) !important; }

.icon { width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -.2em; }

.text-muted { color: var(--sp-text-2) !important; }
.text-negative { color: var(--sp-danger); }
.text-positive { color: var(--sp-success); }

.link-quiet { color: inherit; }
.link-quiet:hover { color: var(--sp-primary); text-decoration: none; }

/* ---------- Auth-Seiten ---------- */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(60rem 30rem at 15% -10%, rgba(36, 87, 230, .35), transparent 60%),
        radial-gradient(40rem 25rem at 100% 110%, rgba(14, 117, 144, .35), transparent 60%),
        var(--sp-sidebar);
}
.auth-card {
    width: 100%;
    max-width: 27rem;
    background: var(--sp-surface);
    border-radius: 16px;
    padding: 2rem 2rem 1.6rem;
    box-shadow: var(--sp-shadow-lg);
}
.auth-card.wide { max-width: 34rem; }
.auth-brand { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.5rem; }
.auth-brand .brand-mark { width: 2.4rem; height: 2.4rem; font-size: 1.1rem; }
.auth-brand .brand-name { font-weight: 750; font-size: 1.2rem; letter-spacing: -.01em; }
.auth-card h1 { font-size: 1.3rem; margin-bottom: .25rem; }
.auth-card .lead { color: var(--sp-text-2); font-size: .92rem; margin-bottom: 1.4rem; }
.auth-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 1.25rem; font-size: .88rem; }
.auth-lang { position: fixed; top: 1rem; inset-inline-end: 1.25rem; }
.auth-lang a { color: rgba(255,255,255,.7); padding: .2rem .5rem; font-size: .85rem; }
.auth-lang a.active { color: #fff; font-weight: 600; }

/* ---------- Portfolio-Demo (SmartPos:Portfolio:Demo) ---------- */
.demo-hinweis {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .35rem .75rem;
    padding: .45rem 1rem; font-size: .85rem; line-height: 1.35; text-align: center;
    background: #fff4e5; color: #7a3e00; border-bottom: 1px solid #f3d3a6;
}
.demo-hinweis .demo-kennzeichen { font-weight: 700; white-space: nowrap; }
.demo-hinweis.schwebend { position: fixed; top: 0; inset-inline: 0; z-index: 10; padding-inline-end: 7rem; }
.auth-page:has(.demo-hinweis.schwebend) .auth-lang { top: .45rem; z-index: 11; }
.auth-page:has(.demo-hinweis.schwebend) .auth-lang a { color: #7a3e00; }

.brand-mark {
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    background: linear-gradient(135deg, #4f8bff, #2457e6);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: .95rem;
    letter-spacing: -.02em;
}

/* ---------- Rechnungseditor ---------- */
.editor-heading { font-size: 1.05rem; font-weight: 650; margin-bottom: .9rem; }

.btn-inline {
    background: none;
    border: 0;
    padding: 0;
    color: var(--sp-primary);
    font-size: .82rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    text-decoration: none;
}
.btn-inline:hover { color: var(--sp-primary-hover); text-decoration: underline; }

.suggest-wrap { position: relative; }
.suggest-list {
    position: absolute;
    z-index: 30;
    inset-inline: 0;
    top: calc(100% + 4px);
    max-height: 18rem;
    overflow-y: auto;
    background: var(--sp-surface);
    border: 1px solid var(--sp-border-strong);
    border-radius: var(--sp-radius-sm);
    box-shadow: 0 10px 30px rgba(16, 24, 40, .12);
}
.suggest-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: .5rem .75rem;
    border: 0;
    background: transparent;
    text-align: start;
    color: var(--sp-text);
    font-size: .9rem;
}
.suggest-item:hover { background: var(--sp-primary-soft); }

.input-action { position: relative; }
.input-action > .form-control { padding-inline-end: 2.5rem; }
.input-action-btn {
    position: absolute;
    inset-inline-end: .35rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    border: 1.5px solid var(--sp-primary);
    background: var(--sp-surface);
    color: var(--sp-primary);
    display: grid;
    place-items: center;
    padding: 0;
}
.input-action-btn:hover { background: var(--sp-primary-soft); }
.input-action-btn .icon { width: 1rem; height: 1rem; }

.input-suffix { position: relative; flex: 1; }
.input-suffix > .form-control { padding-inline-end: 2.4rem; }
.input-suffix > span {
    position: absolute;
    inset-inline-end: .7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--sp-text-3);
    font-size: .85rem;
    pointer-events: none;
}

.segmented { display: inline-flex; background: #eef1f5; border-radius: 8px; padding: 3px; }
.segmented button {
    border: 0;
    background: transparent;
    padding: .28rem .9rem;
    border-radius: 6px;
    font-size: .85rem;
    font-weight: 500;
    color: var(--sp-text-2);
}
.segmented button.active { background: var(--sp-surface); color: var(--sp-text); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); font-weight: 600; }

.positions-table { min-width: 70rem; }
.positions-table .col-produkt { min-width: 20rem; }
.positions-table thead th { background: transparent; border-bottom: 0; padding-bottom: .3rem; }
.positions-table > tbody > tr > td { border-bottom: 1px solid var(--sp-border); padding-top: .75rem; padding-bottom: .75rem; }
.positions-table .typ-select { width: auto; font-size: .78rem; color: var(--sp-text-2); }

.editor-totals { border-top: 1px solid var(--sp-border); padding-top: .6rem; }
.editor-totals .line, .editor-totals .grand { display: flex; justify-content: space-between; padding: .3rem 0; }
.editor-totals .line { color: var(--sp-text-2); font-size: .9rem; }
.editor-totals .grand { font-weight: 700; font-size: 1.15rem; border-top: 1px solid var(--sp-border); margin-top: .3rem; padding-top: .6rem; }

.card-toggle {
    width: 100%;
    border: 0;
    border-bottom: 0;
    background: transparent;
    text-align: start;
    font-size: 1.05rem;
    font-weight: 650;
    padding: 1rem 1.1rem;
}
.card-toggle:hover { background: var(--sp-surface-2); }

.info-box {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    background: var(--sp-surface-2);
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius-sm);
    padding: .8rem 1rem;
}
.info-box > .icon { color: var(--sp-primary); margin-top: .15rem; }

.sp-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(15, 27, 45, .45);
    display: grid;
    place-items: center;
    padding: 1rem;
}
.sp-modal {
    width: 100%;
    max-width: 34rem;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    background: var(--sp-surface);
    border-radius: 14px;
    box-shadow: var(--sp-shadow-lg);
    overflow: hidden;
}
.sp-modal-wide { max-width: 62rem; height: calc(100vh - 2rem); }
.sp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--sp-border);
    font-weight: 650;
}
.sp-modal-body { padding: 1.1rem; overflow-y: auto; }
.sp-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: .75rem 1.1rem;
    border-top: 1px solid var(--sp-border);
    background: var(--sp-surface-2);
}
.pdf-frame { flex: 1; width: 100%; border: 0; background: #525659; }

.logo-preview {
    display: grid;
    place-items: center;
    min-height: 7rem;
    border: 1px dashed var(--sp-border-strong);
    border-radius: var(--sp-radius-sm);
    background: var(--sp-surface-2);
    padding: .75rem;
}
.logo-preview img { max-height: 6rem; max-width: 100%; }

.settings-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--sp-border); margin-bottom: 1.4rem; }
.settings-tabs a {
    padding: .55rem .9rem;
    color: var(--sp-text-2);
    font-weight: 500;
    font-size: .9rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    text-decoration: none;
}
.settings-tabs a.active { color: var(--sp-primary); border-bottom-color: var(--sp-primary); }
.settings-tabs a:hover { color: var(--sp-text); text-decoration: none; }

/* ---------- Blazor-Systemmeldungen ---------- */
.blazor-error-boundary {
    background: var(--sp-danger-soft);
    color: #8f2323;
    border: 1px solid #f0c2c2;
    border-radius: var(--sp-radius-sm);
    padding: 1rem;
}
.blazor-error-boundary::after { content: "Ein Fehler ist aufgetreten."; }

@media (max-width: 640.98px) {
    html { font-size: 14px; }
    .page-header { margin-bottom: 1rem; }
}
