:root {
    --bg: #f3f1ec;
    --panel: #ffffff;
    --ink: #171614;
    --muted: #6f6a63;
    --line: #e4dfd6;
    --soft: #f7f5f1;
    --accent: #1c3d38;
    --accent-dark: #132b27;
    --accent-soft: #e8efed;
    --gold: #b0894d;
    --danger: #9f2d20;
    --ok: #1f6b4a;
    --ok-bg: #e8f5ee;
    --warn: #8a5a12;
    --warn-bg: #f8efd8;
    --shadow: 0 1px 0 rgba(23, 22, 20, 0.04), 0 18px 40px rgba(23, 22, 20, 0.06);
    --radius: 18px;
    font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    min-height: 100%;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.app {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px 28px;
    background: rgba(243, 241, 236, 0.9);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #f7f4ee;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.brand-copy {
    display: grid;
    line-height: 1.15;
}

.brand-copy strong {
    font-size: 0.98rem;
    font-weight: 650;
}

.brand-copy small {
    color: var(--muted);
    font-size: 0.75rem;
}

.topbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

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

.page {
    width: min(1280px, calc(100% - 48px));
    margin: 0 auto;
    padding: 28px 0 64px;
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.68rem;
    color: var(--muted);
    font-weight: 650;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 22px 8px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.panel-highlight {
    border-color: #d5e2de;
    background: linear-gradient(180deg, #fbfffe 0%, #f6faf8 100%);
}

.panel-header h2,
.detail-card h3,
.image-panel h3,
.import-card h3 {
    margin: 6px 0 0;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    font-weight: 650;
}

.split {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.actions,
.bottom {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.actions-end { justify-content: flex-end; margin: 18px 0 6px; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--accent);
    color: #f7f4ee;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 650;
    font-size: 0.92rem;
    white-space: nowrap;
}

.button:hover { background: var(--accent-dark); }

.button.secondary {
    background: var(--accent-soft);
    color: var(--accent);
}

.button.ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}

.button.ghost:hover {
    background: #fff;
    border-color: #d2cdc4;
}

.tabs {
    display: flex;
    gap: 6px;
    padding: 5px;
    margin: 0 0 22px;
    background: #ebe7e0;
    border-radius: 16px;
    overflow-x: auto;
}

.tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 650;
    font-size: 0.92rem;
    padding: 10px 14px;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.tab:hover { color: var(--ink); }

.tab.is-active {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(23, 22, 20, 0.06);
}

.tab-count {
    min-width: 20px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #ded9d1;
    color: var(--ink);
    font-size: 0.74rem;
}

.tab.is-active .tab-count { background: var(--accent-soft); color: var(--accent); }

.tab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gold);
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.cards.compact {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    margin-top: 18px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px 18px 16px;
    box-shadow: var(--shadow);
}

.card span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
}

.card strong {
    display: block;
    margin-top: 10px;
    font-size: 1.7rem;
    letter-spacing: -0.03em;
    font-weight: 650;
}

.shortcut-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.shortcut {
    text-align: left;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow);
    cursor: pointer;
    font: inherit;
    color: inherit;
    display: grid;
    gap: 6px;
}

.shortcut:hover { border-color: #cfc8bc; }

.shortcut-kicker {
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
    font-weight: 700;
}

.shortcut strong {
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.shortcut p {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.4;
}

.import-stack { display: grid; gap: 16px; }

.import-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.import-card {
    display: grid;
    gap: 12px;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.import-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.import-card--baselinker { grid-column: 1 / -1; }

.baselinker-fields {
    grid-template-columns: 1fr 200px auto !important;
    align-items: end;
}

.label-hint {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.85em;
}

.filter-grid,
.form-grid {
    display: grid;
    gap: 16px;
}

.filter-grid {
    grid-template-columns: repeat(3, minmax(0, 220px));
    align-items: end;
}

.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-width { grid-column: 1 / -1; }

label {
    display: grid;
    gap: 8px;
    font-weight: 650;
    color: var(--ink);
    font-size: 0.92rem;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 13px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(28, 61, 56, 0.18);
    border-color: #9bb3ad;
}

textarea { resize: vertical; min-height: 84px; }

.dropzone {
    position: relative;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    min-height: 132px;
    padding: 18px;
    border: 1px dashed #c9d5d1;
    border-radius: 16px;
    background: var(--soft);
    overflow: hidden;
}

.dropzone:hover,
.dropzone.is-dragover {
    border-color: var(--accent);
    background: #f3f7f6;
}

.dropzone-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--accent-soft);
    position: relative;
}

.dropzone-icon::before,
.dropzone-icon::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    background: var(--accent);
    border-radius: 999px;
    transform: translate(-50%, -50%);
}

.dropzone-icon::before { width: 22px; height: 2px; }
.dropzone-icon::after { width: 2px; height: 22px; }

.dropzone-copy {
    display: grid;
    gap: 4px;
    color: var(--muted);
    pointer-events: none;
}

.dropzone-copy strong { color: var(--ink); font-size: 1rem; }

.dropzone-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.dropzone-pill {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 700;
}

.dropzone-file {
    font-weight: 650;
    color: var(--accent);
    margin-top: 4px;
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.current-upload {
    display: grid;
    gap: 4px;
    margin-bottom: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--soft);
}

.current-upload-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.stack { display: grid; gap: 18px; }

.table-wrap { overflow-x: auto; margin: 8px -8px 0; }

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

th, td {
    padding: 13px 10px;
    text-align: left;
    border-bottom: 1px solid #efeae2;
    vertical-align: top;
    font-size: 0.92rem;
}

th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 700;
}

tbody tr:hover { background: #faf8f4; }

.row-actions {
    display: flex;
    gap: 10px;
    white-space: nowrap;
}

.row-actions a {
    color: var(--accent);
    font-weight: 650;
    font-size: 0.88rem;
}

.link-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 650;
    color: var(--accent);
}

.link-btn.danger { color: var(--danger); }

.empty {
    text-align: center;
    color: var(--muted);
    padding: 36px 16px;
}

.cell-muted {
    color: var(--muted);
    font-size: 0.8rem;
}

.badge,
.pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    background: var(--soft);
    color: var(--ink);
}

.badge.warn,
.pill-warn {
    background: var(--warn-bg);
    color: var(--warn);
}

.pill-ok {
    background: var(--ok-bg);
    color: var(--ok);
}

.pill-fv {
    background: #f4ead6;
    color: #7a5420;
}

.kind {
    display: inline-flex;
    align-items: center;
    margin-top: 5px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.kind-receipt {
    background: #e8efed;
    color: #1c3d38;
}

.kind-invoice {
    background: #f4ead6;
    color: #7a5420;
}

.kind-pack {
    background: #ece8f6;
    color: #4b3f78;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 16px 0;
}

.detail-card {
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
}

dl {
    margin: 14px 0 0;
    display: grid;
    gap: 10px;
}

dl div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid #ece7de;
    padding-bottom: 8px;
}

dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-weight: 650; }

.image-panel {
    margin-top: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    background: var(--soft);
}

.messages { margin-bottom: 16px; }

.helper-text {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 500;
}

.helper-inline { display: block; margin-top: 8px; }

.message,
.form-errors {
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--ok-bg);
    border: 1px solid #cfe5d8;
}

.form-errors {
    margin-bottom: 16px;
    background: #fdecea;
    border-color: #f0c7c1;
}

.error { color: var(--danger); font-size: 0.85rem; font-weight: 500; }

.delete-column input[type="checkbox"],
.check-col input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.check-col {
    width: 36px;
    text-align: center;
    vertical-align: middle;
}

.import-modal {
    border: none;
    border-radius: 20px;
    padding: 0;
    width: min(760px, 96vw);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--panel);
    box-shadow: 0 30px 80px rgba(23, 22, 20, 0.22);
}

.import-modal::backdrop {
    background: rgba(23, 22, 20, 0.42);
    backdrop-filter: blur(4px);
}

.import-modal-inner {
    display: grid;
    gap: 18px;
    padding: 24px;
}

.import-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.import-modal-header h2 { margin: 4px 0 0; }

.modal-close {
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    font-size: 14px;
    cursor: pointer;
    color: var(--muted);
}

.month-picker-form { position: relative; }

.month-picker-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    font: inherit;
    font-weight: 650;
    color: var(--ink);
    cursor: pointer;
}

.month-caret {
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
}

.month-picker-popup {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    margin-top: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 14px;
    width: 248px;
}

.mp-year-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.mp-year-label { font-weight: 700; }

.mp-arrow {
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
}

.mp-months {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.mp-month-btn {
    padding: 8px 4px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}

.mp-month-btn:hover { background: var(--soft); }

.mp-month-btn.mp-active {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.input-with-action {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.input-with-action input { flex: 1; }

.receipt-combo {
    display: flex;
    align-items: stretch;
    flex: 1;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}

.receipt-combo input {
    border: 0;
    border-radius: 0;
    min-width: 0;
}

.receipt-combo input:focus {
    outline: none;
}

.receipt-suffix {
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    background: var(--soft);
    color: var(--muted);
    font-weight: 700;
    font-size: 0.92rem;
    white-space: nowrap;
    border-left: 1px solid var(--line);
}

.dashboard-topbar,
.shell,
.sidebar,
.content,
.nav,
.muted { }

@media (max-width: 980px) {
    .topbar {
        flex-wrap: wrap;
        padding: 12px 16px;
    }

    .topbar-center,
    .brand { min-width: 0; }

    .page { width: calc(100% - 28px); padding-top: 18px; }

    .cards,
    .shortcut-grid,
    .import-grid,
    .detail-grid,
    .filter-grid,
    .form-grid,
    .baselinker-fields {
        grid-template-columns: 1fr !important;
    }

    .split { flex-direction: column; }
    .dropzone { grid-template-columns: 1fr; }
}
