:root {
    --bg: #0b0b0b;
    --panel: #121212;
    --panel-2: #1a1a1a;
    --text: #f3f3f3;
    --muted: #b7b7b7;
    --accent: #74df22;
    --ink: #020202
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    font-family: Inter, system-ui, Arial, sans-serif;
    background: var(--bg);
    color: var(--text)
}

header {
    position: sticky;
    top: 0;
    background: #0e0e0e;
    border-bottom: 1px solid #222
}

.wrap {
    max-width: 1100px;
    margin: auto;
    padding: 14px
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent)
}

.right {
    display: flex;
    gap: 8px;
    align-items: center
}

.sep {
    width: 1px;
    height: 28px;
    background: #232323
}

.btn {
    background: var(--accent);
    color: #08250b;
    border: none;
    padding: 9px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.1;
}

.btn.secondary {
    background: #1f1f1f;
    color: var(--text);
    border: 1px solid #2a2a2a
}

.btn.ghost {
    background: transparent;
    color: var(--text);
    border: 1px dashed #2a2a2a
}

.panel {
    background: linear-gradient(180deg, var(--panel), var(--panel-2));
    border: 1px solid #242424;
    border-radius: 12px;
    padding: 14px;
    margin: 14px 0
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px
}

@media (max-width:900px) {
    .row {
        grid-template-columns: 1fr
    }
}

label {
    font-size: 12px;
    color: var(--muted);
    display: block;
    margin-bottom: 6px
}

select,
input[type=number],
input[type=text],
textarea,
input[type=date] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #2a2a2a;
    background: #121212;
    color: var(--text)
}

textarea {
    resize: vertical
}

select:focus,
input:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent)
}

.sum {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    background: #111
}

.value {
    font-variant-numeric: tabular-nums;
    font-weight: 800
}

.mini {
    font-size: 13px;
    color: #a7a7a7
}

.checkline {
    display: flex;
    align-items: center;
    gap: 8px
}

.totals .grand {
    border-top: 1px dashed #2a2a2a;
    padding-top: 6px
}


/* Tabelle */

table {
    width: 100%;
    border-collapse: collapse
}

th,
td {
    padding: 10px 8px;
    border-bottom: 1px dashed #2a2a2a
}

th {
    font-size: 12px;
    color: #a9a9a9;
    text-align: left
}


/* Druckansicht */

.print-only {
    display: none
}

.invoice-head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 12px
}

.head-left {
    display: flex;
    gap: 14px;
    align-items: flex-start
}

.logo {
    width: 180px;
    height: auto;
    object-fit: contain
}

.addr {
    font-size: 12px;
    line-height: 1.5
}

.firm-name {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 4px
}

.head-right {
    text-align: right
}

.invoice-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 10px
}

.meta-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    align-items: start
}

.meta-grid .label {
    text-align: left
}

.meta-grid .value {
    text-align: right
}

.period-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-end
}

#pPeriodDash {
    white-space: pre
}

.to-block {
    margin: 10px 0 6px
}

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

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px
}

.invoice-table th,
.invoice-table td {
    border-bottom: 1px solid #333;
    padding: 8px
}

.t-right {
    text-align: right
}


/* Zusatz-Alignments */

.t-center {
    text-align: center
}


/* neue Spalten im Dashboard enger? optional
td:nth-child(5), th:nth-child(5),
td:nth-child(6), th:nth-child(6) { white-space: nowrap } */

.invoice-totals {
    margin-top: 12px;
    display: grid;
    gap: 6px;
    max-width: 420px;
    margin-left: auto
}

.invoice-totals>div {
    display: flex;
    justify-content: space-between
}

.invoice-totals .grand {
    font-weight: 800;
    border-top: 2px solid #333;
    padding-top: 6px
}

.payment-block {
    margin-top: 10px
}

.closing {
    margin-top: 12px;
    white-space: pre-wrap
}

.invoice-foot {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    font-size: 12px;
    color: #555;
    padding-top: 8px;
    border-top: 1px solid #333
}

.foot-spacer {
    height: 32mm
}

@media print {
    @page {
        margin: 12mm 12mm 28mm 12mm
    }
    body {
        background: #fff;
        color: #000
    }
    .no-print {
        display: none !important
    }
    .print-only {
        display: block !important;
        background: #fff;
        border: none
    }
    .panel {
        background: #fff;
        border: none;
        box-shadow: none
    }
    .wrap {
        max-width: 100%;
        padding: 0 10mm
    }
    .invoice-table th,
    .invoice-table td {
        border-color: #ccc
    }
    .invoice-foot {
        position: fixed;
        left: 10mm;
        right: 10mm;
        bottom: 6mm;
        background: #fff
    }
}

#estWorkRow {
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

#estWorkRow .pair {
    display: inline-flex;
    gap: 8px;
    align-items: baseline;
}

#hourlyRate {
    white-space: nowrap;
}


/* ===== EXTRA UI helpers ===== */

.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn.btn-xs {
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 8px;
}

.tab {
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid #2a2a2a;
    background: #ffffff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .2px;
}

.tab.active {
    background: var(--accent);
    color: #08250b;
    font-weight: 800
}

.badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid #2a2a2a;
    background: #121212
}

.badge.ok {
    background: #0e2a14;
    border-color: #1f4d2a;
    color: #a6f7a6
}

.badge.due {
    background: #2a1b0e;
    border-color: #4d2f1f;
    color: #ffd6a6
}

.badge.overdue {
    background: #2a0e0e;
    border-color: #4d1f1f;
    color: #ffb0b0
}


/* Liste */

.list {
    display: grid;
    gap: 8px
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    background: #121212
}

.muted {
    color: var(--muted);
    font-size: 12px
}

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

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px
}

@media (max-width:1100px) {
    .grid-3 {
        grid-template-columns: 1fr
    }
}

.hr {
    height: 1px;
    background: #232323;
    margin: 10px 0
}

.danger {
    color: #ff7a7a
}

.link {
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline dotted
}

.small-input {
    display: flex;
    gap: 8px;
    align-items: center
}

.small-input input {
    max-width: 280px
}

.sticky-sub {
    position: sticky;
    top: 64px;
    z-index: 5;
    background: #0e0e0e;
    border-bottom: 1px dashed #232323;
    padding: 6px 0
}


/* Sortierbare Tabellen-Header */

th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

th.sortable:hover {
    filter: brightness(1.1);
}

th.sortable.sort-asc::after,
th.sortable.sort-desc::after {
    content: "";
    border: 6px solid transparent;
    border-top-color: currentColor;
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    opacity: .7;
}

th.sortable.sort-desc::after {
    border-top-color: transparent;
    border-bottom-color: currentColor;
}


/* ganze Tabellenzeile für überfällige Rechnungen einfärben */

tr.row-overdue td {
    color: #ff6b6b;
}


/* Badge-Optik etwas „roter“ */

.badge.overdue {
    background: #5a1212;
    color: #ffb3b3;
    border-color: transparent;
}