/* ==========================================================================
   Belegfluss – Bestellungen & Rechnungen
   ========================================================================== */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --surface-hover: #f3f4f7;
    --border: #e5e7ec;
    --border-strong: #d3d7df;
    --text: #151a23;
    --text-2: #4b5363;
    --text-3: #8a91a0;

    --accent: #4257e8;
    --accent-hover: #3446cf;
    --accent-soft: #eceffd;
    --accent-text: #2f40c2;

    --green: #12804a;
    --green-soft: #e5f5ec;
    --amber: #a35a00;
    --amber-soft: #fff3e0;
    --red: #c42b2b;
    --red-soft: #fdecec;
    --blue: #1f6fbf;
    --blue-soft: #e7f1fb;
    --gray-soft: #eef0f3;

    --sidebar: #11151c;
    --sidebar-text: #aeb5c2;
    --sidebar-active: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, .06);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
    --shadow-lg: 0 24px 64px rgba(16, 24, 40, .18);

    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1016;
        --surface: #151922;
        --surface-2: #11151c;
        --surface-hover: #1b202b;
        --border: #242a36;
        --border-strong: #303746;
        --text: #e9ecf2;
        --text-2: #aab1bf;
        --text-3: #707888;

        --accent: #6378ff;
        --accent-hover: #7a8cff;
        --accent-soft: rgba(99, 120, 255, .14);
        --accent-text: #a5b1ff;

        --green: #4cc38a;
        --green-soft: rgba(76, 195, 138, .13);
        --amber: #f0b45a;
        --amber-soft: rgba(240, 180, 90, .13);
        --red: #f07171;
        --red-soft: rgba(240, 113, 113, .13);
        --blue: #6aaef0;
        --blue-soft: rgba(106, 174, 240, .13);
        --gray-soft: #222833;

        --sidebar: #0a0d12;
        --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
        --shadow-lg: 0 24px 64px rgba(0, 0, 0, .5);

        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

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

[hidden] { display: none !important; }

.num, .money { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -.01em; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }

svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.i--lg { width: 20px !important; height: 20px !important; }

/* ---------- Layout -------------------------------------------------------- */

.app {
    display: grid;
    grid-template-columns: 236px 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 18px 12px;
    background: var(--sidebar);
    color: var(--sidebar-text);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand__mark {
    display: grid; place-items: center;
    width: 32px; height: 32px; border-radius: 9px;
    background: linear-gradient(135deg, #5b6cff 0%, #3a4bdc 100%);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 4px 12px rgba(66, 87, 232, .35);
}
.brand__mark svg { width: 18px; height: 18px; }
.brand__name { font-weight: 650; font-size: 16px; color: #fff; letter-spacing: -.01em; }
.brand--lg { justify-content: center; padding-bottom: 8px; }
.brand--lg .brand__name { color: var(--text); font-size: 18px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav__item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav__item.is-active { background: rgba(255, 255, 255, .09); color: var(--sidebar-active); }
.nav__item.is-active .nav__icon { color: #8f9dff; }
.nav__icon { display: inline-flex; }
.nav__label { flex: 1; }
.nav__badge {
    min-width: 22px; padding: 1px 7px; border-radius: 99px;
    background: #4257e8; color: #fff; font-size: 11.5px; font-weight: 650; text-align: center;
}
.nav__dot { width: 8px; height: 8px; border-radius: 50%; background: #f0b45a; }

.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 8px; font-size: 12.5px; }
.sync-info { display: flex; align-items: center; gap: 8px; }
.sync-info__dot { width: 7px; height: 7px; border-radius: 50%; background: #5d6574; flex: none; }
.sync-info.is-fresh .sync-info__dot { background: #4cc38a; box-shadow: 0 0 0 3px rgba(76, 195, 138, .18); }
.sync-info.is-busy .sync-info__dot { background: #6378ff; animation: pulse 1s ease-in-out infinite; }
.sidebar__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.link-muted { color: var(--sidebar-text); display: inline-flex; align-items: center; gap: 6px; }
.link-muted:hover { color: #fff; text-decoration: none; }
.sidebar .pill--soft { background: rgba(255, 255, 255, .08); color: #d3d8e2; }

.main { min-width: 0; padding: 28px 32px 120px; outline: none; }
.boot { display: grid; place-items: center; min-height: 60vh; }

/* ---------- Page header --------------------------------------------------- */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 24px; font-weight: 680; letter-spacing: -.02em; }
.page-sub { margin: 4px 0 0; color: var(--text-2); }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Buttons ------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-weight: 550;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .input:focus-visible, .select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(66, 87, 232, .3), inset 0 1px 0 rgba(255, 255, 255, .15); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--danger { color: var(--red); }
.btn--danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn--danger-solid:hover { background: var(--red); filter: brightness(.92); }
.input--sm { height: 32px; font-size: 13.5px; }

.drawer.drawer--wide { width: 720px; }
.ed-lines { display: flex; flex-direction: column; gap: 10px; }
.ed-line { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.ed-line__head { display: flex; gap: 8px; align-items: center; }
.ed-line__pos { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; background: var(--gray-soft); color: var(--text-2); font-size: 12px; font-weight: 650; }
.ed-line__nums { display: grid; grid-template-columns: 90px 90px 1fr 96px 1fr; gap: 8px; align-items: end; }
.ed-line__nums label, .ed-line__total { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ed-line__nums span, .ed-line__total span { font-size: 12px; color: var(--text-3); font-weight: 550; }
.ed-line__total { align-items: flex-end; padding-bottom: 6px; }
.ed-line__total strong { font-variant-numeric: tabular-nums; }
.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn--ghost:hover { background: var(--surface-hover); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn--icon { padding: 0; width: 36px; }
.btn--sm.btn--icon { width: 30px; }
.btn--block { width: 100%; }
.btn .spinner { width: 14px; height: 14px; border-width: 2px; }

.split { display: inline-flex; }
.split .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split .select {
    height: 36px; border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px;
    padding: 0 28px 0 10px; background-color: var(--surface); width: auto; font-weight: 550;
}

/* ---------- Inputs -------------------------------------------------------- */

.input, .select, .textarea {
    width: 100%;
    height: 36px;
    padding: 0 11px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a91a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 30px;
    cursor: pointer;
}

.search { position: relative; width: 300px; max-width: 100%; }
.search .i { position: absolute; left: 11px; top: 10px; color: var(--text-3); }
.search .input { padding-left: 34px; }
.search kbd {
    position: absolute; right: 8px; top: 8px;
    font: 11px/18px var(--mono); padding: 0 6px; border-radius: 5px;
    border: 1px solid var(--border); color: var(--text-3); background: var(--surface-2);
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field__label .req { color: var(--red); }
.field__hint { font-size: 12.5px; color: var(--text-3); }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px 16px; }
.col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-6 { grid-column: span 6; }

.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
    position: relative; flex: none; width: 36px; height: 20px; margin-top: 1px;
    border-radius: 99px; background: var(--border-strong); transition: background .2s;
}
.switch__track::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s;
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch__text strong { display: block; font-weight: 550; }
.switch__text span { color: var(--text-3); font-size: 13px; }

.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice__opt { position: relative; cursor: pointer; }
.choice__opt input { position: absolute; opacity: 0; }
.choice__card {
    display: flex; gap: 12px; height: 100%; padding: 14px;
    border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface);
    transition: border-color .15s, background .15s;
}
.choice__card strong { display: block; font-weight: 600; margin-bottom: 2px; }
.choice__card span { color: var(--text-2); font-size: 13px; }
.choice__icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 9px; background: var(--gray-soft); color: var(--text-2); }
.choice__opt input:checked + .choice__card { border-color: var(--accent); background: var(--accent-soft); }
.choice__opt input:checked + .choice__card .choice__icon { background: var(--accent); color: #fff; }
.choice__opt input:focus-visible + .choice__card { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Cards / KPIs -------------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card__title { margin: 0; font-size: 15px; font-weight: 640; }
.card__desc { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }
.card__body { padding: 18px 20px 20px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi__label { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 13px; font-weight: 550; }
.kpi__icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--gray-soft); color: var(--text-2); }
.kpi__icon .i { width: 15px; height: 15px; }
.kpi__value { margin-top: 10px; font-size: 26px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi__foot { margin-top: 2px; color: var(--text-3); font-size: 12.5px; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.kpi--accent .kpi__icon { background: var(--accent-soft); color: var(--accent-text); }
.kpi--amber .kpi__icon { background: var(--amber-soft); color: var(--amber); }
.kpi--green .kpi__icon { background: var(--green-soft); color: var(--green); }
.kpi__cta { font-weight: 600; font-size: 12.5px; background: none; border: 0; padding: 0; color: var(--accent-text); cursor: pointer; }
.kpi__cta:hover { text-decoration: underline; }

/* ---------- Toolbar / tabs ------------------------------------------------ */

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--gray-soft); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    display: inline-flex; align-items: center; gap: 7px;
    height: 30px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent;
    color: var(--text-2); font-weight: 550; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab__count { min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--border); color: var(--text-2); font-size: 11.5px; font-weight: 650; line-height: 18px; text-align: center; }
.tab.is-active .tab__count { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Table --------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
    position: sticky; top: 0; z-index: 1;
    padding: 10px 14px; text-align: left; white-space: nowrap;
    font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em;
    background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .sort { opacity: 0; margin-left: 2px; }
.table th.is-sorted { color: var(--text); }
.table th.is-sorted .sort { opacity: 1; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background .1s; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr.is-selected { background: var(--accent-soft); }
.table tbody tr.is-cancelled td:not(:first-child) { opacity: .55; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .right { text-align: right; }
.table .w-check { width: 44px; padding-right: 0; }
.table .w-chev { width: 36px; padding-left: 0; color: var(--text-3); }

.cell-stack { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cell-strong { font-weight: 560; }
.cell-sub { color: var(--text-3); font-size: 12.5px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.max-260 { max-width: 260px; }
.max-320 { max-width: 320px; }

.buyer { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
    display: grid; place-items: center; flex: none;
    width: 32px; height: 32px; border-radius: 50%;
    font-size: 12px; font-weight: 650; color: #fff;
    background: var(--avatar, #6b7280);
}

.check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; margin: 0; vertical-align: middle; }
.check[disabled] { cursor: not-allowed; opacity: .35; }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    height: 22px; padding: 0 8px; border-radius: 99px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
    background: var(--gray-soft); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge--plain::before { display: none; }
.badge--green { background: var(--green-soft); color: var(--green); }
.badge--amber { background: var(--amber-soft); color: var(--amber); }
.badge--red { background: var(--red-soft); color: var(--red); }
.badge--blue { background: var(--blue-soft); color: var(--blue); }
.badge--accent { background: var(--accent-soft); color: var(--accent-text); }

.inv-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-family: var(--mono); font-size: 12.5px; }
.inv-missing { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; }
.inv-missing .btn { opacity: 0; transition: opacity .12s; }
.table tbody tr:hover .inv-missing .btn, .inv-missing .btn:focus-visible { opacity: 1; }

.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 13px; }
.pager { display: flex; gap: 6px; align-items: center; }

/* ---------- Empty states -------------------------------------------------- */

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px; }
.empty__icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 14px; }
.empty__icon .i { width: 24px; height: 24px; }
.empty h3 { margin: 0 0 4px; font-size: 16px; }
.empty p { margin: 0 0 18px; color: var(--text-2); max-width: 420px; }

/* ---------- Drawer -------------------------------------------------------- */

.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(10, 14, 22, .32); backdrop-filter: blur(2px); animation: fade .18s ease; }
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
    width: 520px; max-width: 100vw;
    display: flex; flex-direction: column;
    background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
    transform: translateX(105%); transition: transform .24s cubic-bezier(.2, .8, .2, 1);
}
.drawer.is-open { transform: none; }
.drawer__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.drawer__head .row-gap { flex-wrap: nowrap; flex: none; gap: 2px; }
.drawer__title { margin: 0; font-size: 17px; font-weight: 660; letter-spacing: -.01em; }
.drawer__sub { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.drawer__body { flex: 1; overflow-y: auto; padding: 18px 22px 24px; display: flex; flex-direction: column; gap: 18px; }
.drawer__foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }

.section-label { margin: 0 0 8px; font-size: 12px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.info-box { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); min-width: 0; }
.info-box p { margin: 0; }
.info-line { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; margin-top: 6px; min-width: 0; }
.info-line .i { color: var(--text-3); }
.address { white-space: pre-line; line-height: 1.55; }
.copy-btn { float: right; margin: -6px -6px 0 0; }

.items { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.item__thumb { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 9px; background: var(--gray-soft); color: var(--text-3); }
.item__main { flex: 1; min-width: 0; }
.item__title { font-weight: 550; line-height: 1.35; }
.item__meta { margin-top: 3px; color: var(--text-3); font-size: 12.5px; }
.item__price { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item__price small { display: block; color: var(--text-3); font-size: 12px; }

.sum { display: grid; gap: 6px; padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.sum__row { display: flex; justify-content: space-between; gap: 12px; color: var(--text-2); }
.sum__row--total { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--border); color: var(--text); font-weight: 680; font-size: 16px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: flex; gap: 12px; padding-bottom: 14px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline__dot { position: relative; z-index: 1; display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--gray-soft); color: var(--text-3); }
.timeline__dot .i { width: 13px; height: 13px; }
.timeline li.is-done .timeline__dot { background: var(--green-soft); color: var(--green); }
.timeline li.is-todo .timeline__title { color: var(--text-3); }
.timeline__title { font-weight: 550; }
.timeline__time { color: var(--text-3); font-size: 12.5px; }

.note { padding: 12px 14px; border-radius: var(--radius); background: var(--amber-soft); color: var(--amber); font-size: 13px; display: flex; gap: 10px; }
.note--info { background: var(--blue-soft); color: var(--blue); }
.note .i { margin-top: 2px; }
.quote { margin: 0; padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; color: var(--text-2); }

/* ---------- Bulk bar ------------------------------------------------------ */

.bulkbar {
    position: fixed; left: calc(50% + 118px); bottom: 24px; z-index: 30;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 8px 8px 16px;
    border-radius: 12px;
    background: #151a23; color: #fff;
    box-shadow: var(--shadow-lg);
    transform: translateX(-50%);
    animation: rise .2s ease;
}
.bulkbar__count { font-weight: 600; margin-right: 6px; }
.bulkbar .btn--ghost { color: #c4cad6; }
.bulkbar .btn--ghost:hover { background: rgba(255, 255, 255, .1); color: #fff; }

/* ---------- Modal --------------------------------------------------------- */

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(10, 14, 22, .4); backdrop-filter: blur(3px); animation: fade .15s ease; }
.modal__box { width: 480px; max-width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: pop .18s cubic-bezier(.2, .8, .2, 1); }
.modal__box--wide { width: 600px; }
.modal__head { padding: 20px 22px 0; display: flex; gap: 14px; align-items: flex-start; }
.modal__icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft); color: var(--accent-text); }
.modal__icon--amber { background: var(--amber-soft); color: var(--amber); }
.modal__title { margin: 0; font-size: 17px; font-weight: 660; }
.modal__text { margin: 4px 0 0; color: var(--text-2); }
.modal__body { padding: 16px 22px; overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 14px 22px 18px; }
.modal__error { margin-right: auto; color: var(--red); font-size: 13px; }

.logo-row { display: flex; gap: 16px; align-items: center; }
.logo-preview {
    display: grid; place-items: center; flex: none;
    width: 180px; height: 84px; padding: 10px;
    border: 1px dashed var(--border-strong); border-radius: var(--radius);
    background: #fff;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview .muted { font-size: 13px; color: #8a91a0; }
.logo-row__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.logo-row__body strong { font-weight: 600; }
.btn input[type="file"] { display: none; }

.progress { height: 8px; border-radius: 99px; background: var(--gray-soft); overflow: hidden; }
.progress__bar { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #7b8bff); transition: width .3s ease; }
.progress-label { display: flex; justify-content: space-between; margin-top: 8px; color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }

.result-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); max-height: 320px; overflow-y: auto; }
.result-list li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.result-list li:last-child { border-bottom: 0; }
.result-list .i { margin-top: 2px; }
.result-ok .i { color: var(--green); }
.result-warn .i { color: var(--amber); }
.result-err .i { color: var(--red); }
.result-list small { display: block; color: var(--text-3); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; font-weight: 550; }

/* ---------- Toasts -------------------------------------------------------- */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 70; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.toast {
    display: flex; align-items: flex-start; gap: 10px; max-width: 380px;
    padding: 12px 14px; border-radius: 11px;
    background: #151a23; color: #f1f3f7; box-shadow: var(--shadow-lg);
    font-size: 13.5px; animation: rise .2s ease;
}
.toast .i { margin-top: 2px; }
.toast--ok .i { color: #4cc38a; }
.toast--err .i { color: #f07171; }
.toast--warn .i { color: #f0b45a; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all .2s; }

/* ---------- Settings ------------------------------------------------------ */

.settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 28px; align-items: start; }
.settings__nav { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; }
.settings__nav a { padding: 7px 10px; border-radius: 7px; color: var(--text-2); font-weight: 550; }
.settings__nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.settings__stack { display: flex; flex-direction: column; gap: 18px; max-width: 860px; }
.preview-number { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--border-strong); font-family: var(--mono); font-size: 13px; }

.savebar {
    position: fixed; left: 236px; right: 0; bottom: 0; z-index: 25;
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
    padding: 12px 32px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    animation: rise .18s ease;
}
.savebar__text { margin-right: auto; color: var(--text-2); }

/* ---------- Auth ---------------------------------------------------------- */

.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; background:
    radial-gradient(1200px 600px at 10% -10%, rgba(66, 87, 232, .12), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(66, 87, 232, .08), transparent 60%),
    var(--bg); }
.auth-card { width: 380px; max-width: 100%; padding: 32px 30px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.auth-title { margin: 14px 0 6px; font-size: 20px; text-align: center; letter-spacing: -.01em; }
.auth-sub { margin: 0 0 22px; text-align: center; color: var(--text-2); }
.alert { padding: 10px 12px; border-radius: 9px; margin-bottom: 14px; font-size: 13.5px; }
.alert--error { background: var(--red-soft); color: var(--red); }

/* ---------- Misc ---------------------------------------------------------- */

.spinner { display: inline-block; width: 22px; height: 22px; border: 2.5px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.btn--primary .spinner { border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill--soft { background: var(--gray-soft); color: var(--text-2); }
.pill--warn { background: var(--amber-soft); color: var(--amber); }
.flag { font-size: 14px; line-height: 1; }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--gray-soft), var(--surface-hover), var(--gray-soft)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } }
@keyframes rise { from { opacity: 0; transform: translate(var(--tx, 0), 8px); } }
@keyframes shimmer { to { background-position: -200% 0; } }
.bulkbar { --tx: -50%; }

/* ---------- Responsive ---------------------------------------------------- */

@media (max-width: 1180px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .col-hide-lg { display: none; }
}

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px; }
    .brand { padding: 0 6px 0 0; }
    .brand__name { display: none; }
    .nav { flex-direction: row; flex: 1; overflow-x: auto; }
    .nav__item { padding: 8px 10px; }
    .sidebar__foot { margin: 0; padding: 0; flex-direction: row; }
    .sync-info, .sidebar__meta .pill { display: none; }
    .main { padding: 20px 16px 120px; }
    .settings { grid-template-columns: 1fr; }
    .settings__nav { display: none; }
    .savebar { left: 0; padding: 12px 16px; }
    .bulkbar { left: 50%; }
    .col-hide-md { display: none; }
    .search { width: 100%; }
}

@media (max-width: 600px) {
    .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi { padding: 12px 14px; }
    .kpi__value { font-size: 21px; }
    .nav__label { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid > * { grid-column: auto !important; }
    .choice, .info-grid { grid-template-columns: 1fr; }
    .logo-row { flex-direction: column; align-items: flex-start; }
    .ed-line__nums { grid-template-columns: 1fr 1fr; }
    .page-actions { width: 100%; }
    .page-actions > * { flex: 1; }
    .col-hide-sm { display: none; }
    .drawer { width: 100vw; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
