/* ============ RESET & BASE ============ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Remove number input spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

:root {
    --purple-50: #f0f5fa;
    --purple-100: #dfe9f2;
    --purple-200: #c4d6e6;
    --purple-300: #a3bdd6;
    --purple-400: #8daec8;
    --purple-500: #6d97b8;
    --purple-600: #5a84a8;
    --purple-700: #81A6C6;
    --purple-800: #3d6585;
    --purple-900: #2d4d68;
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #f0f1f4;
    --gray-200: #e0e2e8;
    --gray-300: #ccced6;
    --gray-400: #8e92a0;
    --gray-500: #6b7084;
    --gray-600: #565b6e;
    --gray-700: #4a4f60;
    --gray-800: #474E68;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --transition: 150ms ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Dark mode — softer palette */
[data-theme="dark"] {
    --white: #212123;
    --gray-50: #252830;
    --gray-100: #2f323b;
    --gray-200: #3a3d47;
    --gray-300: #4a4e5a;
    --gray-400: #7a7e8c;
    --gray-500: #a0a4b0;
    --gray-600: #c4c7d0;
    --gray-700: #dddfe5;
    --gray-800: #edeef2;
    --purple-50: #2a3040;
    --purple-100: #313a4d;
    --purple-200: #3d4a60;
    --shadow: 0 1px 3px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.15);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.2), 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.3), 0 4px 10px rgba(0,0,0,0.15);
    color-scheme: dark;
}

[data-theme="dark"] body {
    background: #121214;
    color: #dcdce2;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--gray-100);
    color: var(--gray-800);
    border-color: var(--gray-300);
}

[data-theme="dark"] .navbar {
    background: #18181b;
    border-color: var(--gray-200);
}

[data-theme="dark"] .login-card {
    background: rgba(33, 33, 35, 0.92);
}

[data-theme="dark"] .credits-banner.credits-ok {
    background: #14261a;
    color: #6ee7a0;
    border-color: #1a3d24;
}

[data-theme="dark"] #eur-rate-banner {
    background: #14261a;
    color: #6ee7a0;
    border-color: #1a3d24;
}

[data-theme="dark"] .alert-error {
    background: #2a1215;
    color: #fca5a5;
    border-color: #5c2020;
}

[data-theme="dark"] .btn-icon {
    color: var(--gray-500);
    border-color: var(--gray-300);
}

[data-theme="dark"] .btn-icon:hover {
    color: var(--gray-700);
}

[data-theme="dark"] .btn-icon.danger:hover {
    background: #2a1215;
    border-color: #5c2020;
}

[data-theme="dark"] .dot-menu {
    background: #222224;
    border-color: #3a3a3f;
}

[data-theme="dark"] .dot-menu-item:hover {
    background: #2a2238;
}

[data-theme="dark"] .dot-menu-item.dot-menu-danger:hover {
    background: #2a1215;
}

[data-theme="dark"] .row-work {
    background: #261c06;
}

[data-theme="dark"] .row-custom {
    background: #0a1f12;
}

[data-theme="dark"] .proforma-badge {
    background: #261c06;
    color: #fbbf58;
    border-color: #4a3520;
}

[data-theme="dark"] .payment-badge.paid {
    background: #0a1f12;
    color: #6ee7a0;
}

[data-theme="dark"] .payment-badge.paid:hover {
    background: #14261a;
}

[data-theme="dark"] .payment-badge.unpaid {
    background: #261c06;
    color: #fbbf58;
}

[data-theme="dark"] .payment-badge.unpaid:hover {
    background: #3a2a0e;
}

[data-theme="dark"] .freq-daily   { background: #172554; color: #93bbfc; }
[data-theme="dark"] .freq-weekly  { background: #1e1b4b; color: #a5b4fc; }
[data-theme="dark"] .freq-monthly { background: #2e1065; color: #e9a5ff; }
[data-theme="dark"] .freq-push    { background: #0a1f12; color: #6ee7a0; }

[data-theme="dark"] .qty-warning {
    background: #3a2a0e !important;
    border-color: #d97706 !important;
    color: #fbbf58 !important;
}

[data-theme="dark"] .proforma-badge.paid {
    background: #0a1f12;
    color: #6ee7a0;
    border-color: #1a3d24;
}

[data-theme="dark"] .stat-value.paid { color: #6ee7a0; }
[data-theme="dark"] .stat-value.unpaid { color: #fbbf58; }

[data-theme="dark"] .pdf-archive-status.fresh { color: #34d399; }
[data-theme="dark"] .pdf-archive-status.stale { color: #fbbf58; }

body {
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 0.9375rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============ LOGIN ============ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0;
    padding: 16px 0;
    position: relative;
    background: #1a1a1a url('assets/default.webp') center no-repeat;
    background-size: cover;
}

.login-body::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.1);
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 44px 36px 36px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.login-logo img {
    height: 56px;
    margin-bottom: 8px;
}

.login-logo {
    margin-bottom: 28px;
}

.login-form .form-group {
    text-align: left;
    margin-bottom: 16px;
}

.login-form .btn-primary {
    padding: 12px 24px;
    font-size: 0.9375rem;
    margin-top: 4px;
}

@media (max-width: 768px) {
    .login-body {
        padding: 16px;
    }

    .login-container {
        padding: 0;
    }

    .login-card {
        padding: 32px 20px 24px;
        border-radius: 16px;
    }

    .login-logo img {
        height: 44px;
    }

    .login-logo {
        margin-bottom: 20px;
    }

    .login-form .form-group {
        margin-bottom: 12px;
    }

    .login-form input {
        font-size: max(1rem, 16px);
        padding: 10px 12px;
    }

    .login-form .btn-primary {
        padding: 12px 24px;
        min-height: 44px;
    }
}

/* ============ ALERTS ============ */
.alert {
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.8125rem;
    font-weight: 500;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

/* ============ FORMS ============ */
label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 4px;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

label small {
    text-transform: none;
    font-weight: 400;
    letter-spacing: 0;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--purple-400);
    box-shadow: 0 0 0 3px rgba(90, 132, 168, 0.12);
}

.input-lg {
    font-size: 1.0625rem;
    padding: 12px 16px;
    font-weight: 500;
}

textarea {
    resize: vertical;
}

/* Focus styles for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--purple-400);
    outline-offset: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none; /* handled by border-color + box-shadow above */
}

.toggle input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(90, 132, 168, 0.25);
}

.form-group {
    margin-bottom: 12px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.2;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn i {
    font-size: 0.8em;
}

.btn-primary {
    background: var(--purple-600);
    color: var(--white);
    border: 1.5px solid var(--purple-600);
    box-shadow: 0 1px 2px rgba(90, 132, 168, 0.3);
}

.btn-primary:hover {
    background: var(--purple-700);
    box-shadow: 0 4px 12px rgba(90, 132, 168, 0.3);
}

.btn-outline {
    background: var(--white);
    color: var(--purple-600);
    border: 1.5px solid var(--purple-200);
}

.btn-outline:hover {
    background: var(--purple-50);
    border-color: var(--purple-400);
    color: var(--purple-700);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
    border: 1.5px solid var(--danger);
    box-shadow: 0 1px 2px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: var(--danger-hover);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 11px 28px;
    font-size: 0.9375rem;
}

.btn-full {
    width: 100%;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--radius);
    font-size: 0.875rem;
    border: 1px solid var(--gray-200);
    background: var(--white);
    color: var(--gray-400);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-icon.danger:hover {
    background: #fef2f2;
    color: var(--danger);
    border-color: #fecaca;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ============ NAVBAR ============ */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--purple-700);
    font-size: 1.125rem;
}

.nav-logo {
    height: 28px;
}

.nav-tabs {
    display: flex;
    gap: 2px;
}

.nav-tab {
    padding: 7px 16px;
    border: none;
    background: none;
    color: var(--gray-500);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nav-tab i {
    font-size: 0.75rem;
    opacity: 0.7;
}

.nav-tab:hover {
    background: var(--purple-50);
    color: var(--purple-600);
}

.nav-tab.active {
    background: var(--purple-100);
    color: var(--purple-700);
    font-weight: 600;
}

.nav-tab.active i {
    opacity: 1;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8125rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* ============ CONTAINER & PAGES ============ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 24px 48px;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 200ms ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--gray-800);
    letter-spacing: -0.01em;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--gray-400);
    font-size: 0.875rem;
}

/* ============ FORM SECTIONS ============ */
.form-section {
    margin-bottom: 28px;
}

.form-section h3 {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--purple-700);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--purple-100);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ============ ADDRESS COLUMNS ============ */
.address-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 28px;
}

.address-col {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
}

.address-col h3 {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--purple-700);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--purple-100);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ============ ITEMS TABLE (Create page) ============ */
.items-table-wrapper {
    overflow: visible;
    margin-bottom: 12px;
}

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

.items-table th {
    background: var(--purple-50);
    color: var(--purple-700);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 8px;
    text-align: left;
    border-bottom: 2px solid var(--purple-200);
}

.items-table td {
    padding: 6px 4px;
    vertical-align: middle;
}

.items-table input,
.items-table select {
    padding: 7px 6px;
    font-size: 0.8125rem;
}

.items-table .col-drag { width: 30px; text-align: center; }
.items-table .col-name { width: 38%; }
.items-table .col-price { width: 16%; }
.items-table .col-qty { width: 12%; }
.items-table .col-unit { width: 10%; }
.items-table .col-total { width: 14%; }
.items-table .col-action { width: 5%; text-align: center; }

.items-table .calculated {
    background: var(--purple-50);
    font-weight: 600;
    color: var(--purple-700);
}

.items-table input:disabled {
    background: var(--gray-100);
    color: var(--gray-400);
    cursor: not-allowed;
    border-color: var(--gray-200);
}

.row-work {
    background: #fffbeb;
}

.row-custom {
    background: #f0fdf4;
}

/* Drag handle */
.drag-handle {
    cursor: grab;
    color: var(--gray-300);
    font-size: 0.875rem;
    user-select: none;
    text-align: center;
    padding: 6px 2px !important;
    width: 30px;
}

.drag-handle:hover {
    color: var(--purple-500);
}

.drag-handle:active {
    cursor: grabbing;
}

tr.dragging {
    opacity: 0.4;
    background: var(--purple-50);
}

tr.drag-over {
    border-top: 2px solid var(--purple-500);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--purple-100);
    color: var(--purple-700);
}


.pi-size-badge {
    background: var(--gray-100);
    color: var(--gray-600);
    text-transform: none;
    font-weight: 500;
    min-width: 20px;
}

.pi-size-badge:empty {
    display: none;
}

.qty-warning {
    background: #fef9c3 !important;
    border-color: #f59e0b !important;
    color: #92400e !important;
}

.item-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============ TOTALS BAR ============ */
.totals-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 14px 20px;
    background: var(--purple-50);
    border-radius: var(--radius);
    border: 1px solid var(--purple-200);
    font-size: 1rem;
    font-weight: 500;
}

.totals-bar strong {
    color: var(--purple-700);
    font-size: 1.25rem;
    font-weight: 700;
    margin-left: 6px;
}

/* ============ FORM ACTIONS ============ */
.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

/* ============ DATABASE PAGE ============ */
.db-creator {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    margin-bottom: 24px;
}

.db-creator h3 {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--purple-700);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.db-form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.db-form-row .form-group {
    flex: 1;
}

.db-form-row .btn {
    margin-bottom: 12px;
    white-space: nowrap;
}

.db-table-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
    min-height: 34px;
}

/* ============ DATA TABLE ============ */
.table-wrapper {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

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

.data-table th {
    background: var(--purple-50);
    color: var(--purple-700);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--purple-200);
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
}

.data-table tr:hover td {
    background: var(--purple-50);
}

.data-table .col-check {
    width: 40px;
    text-align: center;
}

.data-table .actions {
    display: flex;
    gap: 6px;
}

.data-table .inline-edit input {
    padding: 6px 8px;
    font-size: 0.8125rem;
    width: 100%;
}

.data-table .edit-actions {
    display: flex;
    gap: 4px;
}

/* ============ OVERVIEW / PROJECTS GRID ============ */
.projects-grid {
    display: grid;
    gap: 12px;
}

.project-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition);
}

.project-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--purple-200);
}

.project-card-imported {
    border-left: 3px solid var(--purple-500);
}

.imported-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: var(--purple-100, rgba(90, 132, 168, 0.12));
    color: var(--purple-600);
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 10px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.project-info {
    flex: 1;
    min-width: 0;
}

.project-info h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 3px;
}

.project-meta {
    font-size: 0.75rem;
    color: var(--gray-400);
    display: flex;
    gap: 12px;
    align-items: center;
}

.project-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.project-total {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--purple-700);
    margin-right: 20px;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.project-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* 3-dot dropdown menu */
.dot-menu-wrapper {
    position: relative;
}

.dot-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    z-index: 120;
    margin-top: 4px;
    padding: 4px 0;
}

.dot-menu.visible {
    display: block;
}

.dot-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.8125rem;
    color: var(--gray-700);
    cursor: pointer;
    transition: background 100ms ease;
    white-space: nowrap;
}

.dot-menu-item:hover {
    background: var(--purple-50);
    color: var(--purple-700);
}

.dot-menu-item i {
    width: 16px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray-400);
}

.dot-menu-item:hover i {
    color: var(--purple-500);
}

.dot-menu-item.dot-menu-danger {
    color: var(--danger);
}

.dot-menu-item.dot-menu-danger:hover {
    background: #fef2f2;
    color: var(--danger-hover);
}

.dot-menu-item.dot-menu-danger i {
    color: var(--danger);
}

.dot-menu-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 4px 0;
}

/* Proforma badge */
.proforma-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
    cursor: pointer;
    font-family: var(--font);
    transition: opacity 150ms;
}

.proforma-badge:hover {
    opacity: 0.8;
}

.proforma-badge.paid {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 16px;
}

/* ============ ARES ============ */
.ares-hint {
    background: var(--purple-50);
    border: 1px dashed var(--purple-300);
    border-radius: var(--radius);
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 0.75rem;
    color: var(--purple-600);
    text-align: center;
}

.btn-ares {
    margin-bottom: 12px;
    align-self: flex-end;
    white-space: nowrap;
}

/* ============ AUTOCOMPLETE ============ */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 9000;
    display: none;
    box-shadow: var(--shadow-lg);
}

.autocomplete-dropdown.visible {
    display: block;
}

.autocomplete-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.8125rem;
    transition: background var(--transition);
}

.autocomplete-option:hover,
.autocomplete-option.highlighted {
    background: var(--purple-50);
    color: var(--purple-700);
}

/* ============ TOAST NOTIFICATIONS ============ */
#toast-container {
    position: fixed;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 8px;
}

.toast {
    background: var(--white);
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.8125rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 400px;
    animation: toastIn 300ms ease;
    border-left: 4px solid var(--purple-500);
}

.toast i {
    font-size: 1rem;
    flex-shrink: 0;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.success i {
    color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.error i {
    color: var(--danger);
}

.toast.removing {
    animation: toastOut 300ms ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ============ CONFIRM DIALOG ============ */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(2px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px 0;
    animation: overlayIn 200ms ease;
}

.overlay.closing {
    animation: overlayOut 200ms ease forwards;
}

.overlay.closing > * {
    animation: modalOut 200ms ease forwards;
}

@keyframes overlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes overlayOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes modalOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

.confirm-dialog {
    background: var(--white);
    border-radius: 16px;
    padding: 28px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: modalIn 200ms ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.confirm-dialog h3 {
    margin-bottom: 8px;
    color: var(--gray-800);
    font-size: 1.0625rem;
}

.confirm-dialog p {
    color: var(--gray-500);
    margin-bottom: 20px;
    font-size: 0.875rem;
    line-height: 1.5;
}

.confirm-dialog .dialog-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ============ CREDITS BANNER ============ */
.credits-banner {
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid;
}

.credits-ok {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

/* Smooth reveal for the EUR/CZK rate banner on the Database page. The banner
   is statically rendered with display:none and toggled to display:block once
   the rate API resolves — without an animation that toggle jolts the items
   table below by the banner's height. Slide-and-fade in over the height
   transition makes the layout shift feel intentional. */
#eur-rate-banner.eur-rate-banner-in {
    animation: eurBannerIn 380ms ease-out both;
    transform-origin: top center;
}

@keyframes eurBannerIn {
    from {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin-bottom: 0;
        border-top-width: 0;
        border-bottom-width: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        max-height: 80px;
        padding-top: 10px;
        padding-bottom: 10px;
        margin-bottom: 16px;
        border-top-width: 1px;
        border-bottom-width: 1px;
        transform: translateY(0);
    }
}


/* ============ TUTORIAL ============ */
.tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    animation: overlayIn 260ms ease;
}

.tutorial-overlay.tutorial-fadeout {
    animation: overlayOut 220ms ease forwards;
}

/* Spotlight and backdrop are both always present in the overlay; the JS
   toggles between them by flipping their opacity. The transition here is
   what turns a hard mode switch into a smooth crossfade. */
.tutorial-spotlight {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 220ms ease;
}

.tutorial-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    opacity: 0;
    transition: opacity 220ms ease;
    pointer-events: none;
}

.tutorial-card-host {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.tutorial-card-host > * {
    pointer-events: auto;
}

.tutorial-card {
    position: absolute;
    background: var(--white);
    border-radius: 16px;
    padding: 20px 24px;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
    z-index: 10001;
    /* Opacity-only fade so the centering transform on .tutorial-card-center
       is never disturbed. (A scale animation would override the
       `translate(-50%, -50%)` for the duration of the animation, and the
       card would visibly jump to true center once it finished.) */
    animation: tutorialCardIn 220ms ease;
}

.tutorial-card.tutorial-card-out {
    animation: tutorialCardOut 160ms ease forwards;
}

@keyframes tutorialCardIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes tutorialCardOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.tutorial-card-center {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.tutorial-card-step {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.tutorial-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 6px;
}

.tutorial-card-text {
    font-size: 0.8125rem;
    color: var(--gray-600);
    line-height: 1.5;
    margin-bottom: 16px;
}

.tutorial-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Migration-prompt step gets a slightly wider card and a stacked action
   column, because the Czech labels "Ne, začínám od nuly" and "Ano, importovat"
   don't fit side-by-side in the default 320px width. */
.tutorial-card-migration {
    max-width: 380px;
}

.tutorial-card-actions-stacked {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.tutorial-card-actions-stacked .btn {
    width: 100%;
    justify-content: center;
}

@media (max-width: 640px) {
    .tutorial-card {
        max-width: 280px;
    }
    .tutorial-card-migration {
        max-width: 300px;
    }
}

/* ============ TOOLTIPS ============ */
.tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    font-size: 0.6rem;
    color: var(--gray-400);
    cursor: help;
    position: relative;
    vertical-align: baseline;
    margin-left: 4px;
    flex-shrink: 0;
    top: -1px;
}

.tip:hover { color: var(--purple-600); }

.tip-content {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: #f0f1f4;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    padding: 8px 12px;
    border-radius: 8px;
    width: max-content;
    max-width: 260px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 100;
    text-transform: none;
    letter-spacing: 0;
    pointer-events: none;
    white-space: normal;
}

.tip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--gray-800);
}

.tip:hover .tip-content,
.tip.active .tip-content {
    display: block;
}

/* Flip tooltip down if near top */
.tip-bottom .tip-content {
    bottom: auto;
    top: calc(100% + 6px);
}

.tip-bottom .tip-content::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: var(--gray-800);
}

[data-theme="dark"] .tip-content {
    background: var(--gray-700);
    color: var(--gray-100);
}

[data-theme="dark"] .tip-content::after {
    border-top-color: var(--gray-700);
}

[data-theme="dark"] .tip-bottom .tip-content::after {
    border-top-color: transparent;
    border-bottom-color: var(--gray-700);
}

@media (max-width: 768px) {
    .tip-content { max-width: 200px; }
}

/* ============ STATISTICS ============ */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stats-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
}

.stats-card-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stats-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
}

.stats-charts {
    display: flex;
    gap: 16px;
    align-items: stretch;
}

.stats-chart-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.stats-chart-card canvas {
    max-height: 280px;
}

/* Bar card grows to match the doughnut card's height on desktop and the
   canvas wrap fills the remaining vertical space, so the bars grow tall
   instead of being capped at the original 260px. */
.stats-chart-card-bars {
    min-height: 360px;
}

.stats-bar-canvas-wrap {
    flex: 1;
    min-height: 280px;
    position: relative;
}

.stats-bar-canvas-wrap canvas {
    max-height: none !important;
    width: 100% !important;
    height: 100% !important;
}

.stats-chart-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 12px;
}

.stats-threshold {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 14px 20px;
    margin-bottom: 10px;
    /* Slide+fade in when the threshold cards are injected, so the page
       below doesn't jolt when the API call resolves and the warnings
       suddenly take up space. The bar fill inside has its own width
       transition (see .stats-threshold-fill) which kicks in afterward. */
    animation: statsThresholdIn 380ms ease-out both;
    transform-origin: top center;
}

.stats-threshold:nth-child(2) { animation-delay: 80ms; }
.stats-threshold:nth-child(3) { animation-delay: 160ms; }

@keyframes statsThresholdIn {
    from {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        margin-bottom: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        max-height: 200px;
        padding-top: 14px;
        padding-bottom: 14px;
        margin-bottom: 10px;
        transform: translateY(0);
    }
}

.stats-threshold-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
}

.stats-threshold-bar {
    height: 8px;
    background: var(--gray-100);
    border-radius: 4px;
    overflow: hidden;
}

.stats-threshold-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 500ms ease;
}

.stats-vat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.stats-vat-table th {
    text-align: left;
    padding: 6px 12px;
    color: var(--gray-500);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    border-bottom: 2px solid var(--gray-200);
}

.stats-vat-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--gray-100);
}

.stats-vat-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
    .stats-charts {
        flex-direction: column;
    }
}

/* ============ EXPORT FORMAT CARDS ============ */
.export-format-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 12px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 150ms;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-600);
    text-align: center;
}

.export-format-card:hover {
    border-color: var(--gray-400);
}

.export-format-card.active {
    border-color: var(--purple-600);
    background: var(--purple-50);
    color: var(--purple-700);
}

/* ============ PROJECT SETTINGS DROPDOWN ============ */
.project-settings-wrapper {
    position: relative;
}

.project-settings-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 14px 16px;
    min-width: 260px;
    z-index: 50;
}

/* ============ SEGMENTED CONTROL ============ */
.seg-control {
    display: inline-flex;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
}

.seg-control button {
    padding: 8px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    background: var(--white);
    color: var(--gray-500);
    cursor: pointer;
    transition: all 150ms;
    line-height: 1.2;
}

.seg-control button:not(:last-child) {
    border-right: 1px solid var(--gray-200);
}

.seg-control button.active {
    background: var(--purple-600);
    color: var(--white);
}

.seg-control button:hover:not(.active) {
    background: var(--gray-50);
    color: var(--gray-700);
}

/* ============ COLOR PICKER ============ */
.color-swatch {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    border: 2px solid var(--gray-200);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 150ms;
}

.color-swatch:hover {
    border-color: var(--gray-400);
}

.color-picker-dropdown {
    margin-top: 8px;
    padding: 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
}

/* ============ PDF VIEWER MODAL ============ */
.pdf-viewer-overlay {
    z-index: 1000;
}

.pdf-viewer-modal {
    background: var(--white);
    border-radius: 16px;
    animation: modalIn 200ms ease;
    width: 90vw;
    max-width: 900px;
    height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0,0,0,0.2);
}

.pdf-viewer-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    margin: 12px 12px 0;
    background: var(--gray-100);
}

.pdf-viewer-pages {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.pdf-page-canvas {
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.pdf-viewer-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--gray-500);
    font-size: 0.875rem;
}

.pdf-viewer-spinner .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--purple-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.pdf-viewer-error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
    padding: 24px;
}

.pdf-viewer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
}

@media (max-width: 640px) {
    .pdf-viewer-modal {
        width: 98vw;
        height: 94vh;
        border-radius: 12px;
    }
    .pdf-viewer-body {
        margin: 8px 8px 0;
    }
    .pdf-viewer-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* ============ SETTINGS DRAWER ============ */
/* ============ SETTINGS PAGE ============ */
.settings-layout {
    display: flex;
    gap: 24px;
    min-height: 500px;
}

.settings-sidebar {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 8px;
    align-self: flex-start;
    position: sticky;
    top: 80px;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-600);
    background: none;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 150ms ease;
    text-align: left;
    font-family: var(--font);
    width: 100%;
}

.settings-nav-item:hover {
    background: var(--gray-50);
    color: var(--gray-800);
}

.settings-nav-item.active {
    background: var(--purple-50);
    color: var(--purple-700);
    font-weight: 600;
}

.settings-nav-item i {
    width: 16px;
    text-align: center;
    font-size: 0.75rem;
}

.settings-nav-group-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--gray-400);
    padding: 12px 14px 4px;
}

.settings-nav-group-label:first-child {
    padding-top: 4px;
}

.settings-nav-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 6px 8px;
}

.settings-content {
    flex: 1;
    min-width: 0;
}

.settings-panel {
    display: none;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.settings-panel.active {
    display: block;
}

.settings-panel h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-100);
}

/* Logo preview */
.logo-preview-box {
    width: 180px;
    height: 80px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--gray-50);
}

.logo-preview-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Background gallery */
.bg-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.bg-gallery-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--gray-200);
    aspect-ratio: 16/9;
}

.bg-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bg-gallery-item .bg-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 150ms ease;
}

.bg-gallery-item:hover .bg-delete {
    opacity: 1;
}

.bg-gallery-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3px 6px;
    background: rgba(0,0,0,0.5);
    color: white;
    font-size: 0.6rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* User management */
.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 6px;
}

.user-card-info {
    flex: 1;
}

.user-card-info strong {
    font-size: 0.875rem;
}

.user-card-info .user-meta {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.role-badge {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.role-badge.admin { background: var(--purple-100); color: var(--purple-700); }
.role-badge.user { background: var(--gray-100); color: var(--gray-500); }

.user-card .role-select {
    padding: 4px 8px;
    font-size: 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: var(--font);
    background: var(--white);
    cursor: pointer;
    flex-shrink: 0;
}

.user-card .btn-icon {
    flex-shrink: 0;
}

/* Image upload dropzones */
.img-dropzone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 200ms ease;
    background: var(--gray-50);
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.img-dropzone:hover,
.img-dropzone.drag-over {
    border-color: var(--purple-400);
    background: var(--purple-50);
}

.img-dropzone i {
    font-size: 1.5rem;
    color: var(--purple-400);
    margin-bottom: 4px;
}

.img-dropzone span {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-600);
}

.img-dropzone small {
    font-size: 0.6875rem;
    color: var(--gray-400);
}

/* Mobile dropdown for settings nav */
.settings-mobile-select {
    display: none;
    width: 100%;
    margin-bottom: 16px;
}

/* Color picker row */
.color-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.color-input-row input[type="color"] {
    width: 44px;
    height: 38px;
    padding: 2px;
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
    border: 1px solid var(--gray-200);
}

.color-input-row input[type="text"] {
    flex: 1;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8125rem;
}

/* Toggle switch */
.toggle-group {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    line-height: 1;
}

.toggle-group > label {
    margin-bottom: 0;
}

.toggle-group > label:first-child {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 24px;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 24px;
    cursor: pointer;
    transition: background 200ms ease;
    width: 44px;
    height: 24px;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 200ms ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider {
    background: var(--purple-600);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ============ DASHBOARD ============ */
.page-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.dashboard-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.dashboard-header h3 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--gray-700);
}

.period-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.period-btn {
    padding: 5px 14px;
    border: none;
    background: var(--white);
    color: var(--gray-500);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border-right: 1px solid var(--gray-200);
}

.period-btn:last-child {
    border-right: none;
}

.period-btn:hover {
    background: var(--gray-50);
}

.period-btn.active {
    background: var(--purple-600);
    color: var(--white);
}

.dashboard-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.stat-value.paid { color: #166534; }
.stat-value.unpaid { color: #f59e0b; }
.stat-value.total { color: var(--purple-700); }

.chart-container {
    position: relative;
    width: 100%;
}

/* ============ PAYMENT STATUS ============ */
.payment-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 12px;
    font-family: var(--font);
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    line-height: 1.4;
    letter-spacing: 0.01em;
}

.payment-badge i {
    font-size: 0.625rem;
}

.payment-badge.paid {
    background: #dcfce7;
    color: #166534;
}

.payment-badge.paid:hover {
    background: #bbf7d0;
}

.payment-badge.unpaid {
    background: #fef3c7;
    color: #92400e;
}

.payment-badge.unpaid:hover {
    background: #fde68a;
}

/* ============ VAT ROW ============ */
.vat-settings-strip {
    background: var(--purple-50);
    border: 1px solid var(--purple-200);
    border-radius: var(--radius-lg);
    padding: 14px 20px;
}

.vat-settings-strip h3 {
    color: var(--purple-700);
}

.vat-row {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 12px;
}

.vat-row > .toggle-group {
    flex: 0 0 auto;
    gap: 12px;
    justify-content: flex-start;
}

.vat-row > .toggle-group > label:first-child {
    flex: 0 0 auto;
}

#vat-rate-group {
    flex-shrink: 0;
    min-width: 140px;
}

.totals-detail {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
    width: 100%;
}

.totals-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.totals-row span {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.totals-row strong {
    font-size: 1rem;
    color: var(--purple-700);
}

.totals-grand span {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
}

.totals-grand strong {
    font-size: 1.25rem;
    font-weight: 700;
}

/* ============ CURRENCY INPUT GROUP ============ */
.currency-input-group {
    display: flex;
    gap: 0;
    align-items: stretch;
}

.currency-input-group input {
    flex: 1;
    min-width: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.currency-input-group .currency-toggle {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: 0;
    width: 44px;
    flex-shrink: 0;
    padding: 0;
    font-size: 0.8125rem;
    height: auto;
    min-height: 0;
    margin-bottom: 0 !important;
    display: flex;
}


.currency-toggle {
    min-width: 42px;
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
    overflow: hidden;
}

@keyframes swoosh-out {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-100%); opacity: 0; }
}

@keyframes swoosh-in {
    0% { transform: translateY(100%); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.currency-toggle .cur-text {
    display: inline-block;
}

.currency-toggle .cur-text.out {
    animation: swoosh-out 150ms ease-in forwards;
}

.currency-toggle .cur-text.in {
    animation: swoosh-in 150ms ease-out forwards;
}

.price-hint {
    font-size: 0.6875rem;
    color: var(--gray-400);
    font-weight: 400;
    margin-left: 4px;
}

.eur-hidden { display: none !important; }

/* ============ SENDER CARDS (Settings) ============ */
.senders-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sender-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 10px 12px;
}

.sender-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
}

.sender-card-header strong {
    flex: 1;
}

.sender-card-actions {
    display: flex;
    gap: 4px;
}

.sender-card-actions .btn-icon {
    width: 26px;
    height: 26px;
    font-size: 0.7rem;
}

.sender-card-detail {
    font-size: 0.6875rem;
    color: var(--gray-400);
    margin-top: 4px;
}

.sender-editor {
    border: 2px solid var(--purple-200);
    background: var(--purple-50);
}

/* ============ UPLOAD ZONE ============ */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 200ms ease;
    background: var(--gray-50);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--purple-400);
    background: var(--purple-50);
}

.upload-zone.has-file {
    border-color: var(--purple-500);
    border-style: solid;
    background: var(--purple-50);
}

.upload-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

.upload-zone-content i {
    font-size: 2.25rem;
    color: var(--purple-400);
    margin-bottom: 8px;
}

.upload-zone.has-file .upload-zone-content i {
    color: var(--purple-600);
}

.upload-zone-content p {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gray-600);
    margin: 0;
}

.upload-zone.has-file .upload-zone-content p {
    color: var(--purple-700);
}

.upload-zone-formats {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.upload-zone-filename {
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ============ IMPORT CHOICE CARDS ============ */
.import-choice-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.import-choice-card {
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 200ms ease;
    background: var(--white);
}

.import-choice-card:hover {
    border-color: var(--purple-400);
    background: var(--purple-50);
    box-shadow: var(--shadow-md);
}

.import-choice-card i {
    font-size: 1.75rem;
    color: var(--purple-500);
    margin-bottom: 12px;
    display: block;
}

.import-choice-card h4 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.import-choice-card p {
    font-size: 0.8125rem;
    color: var(--gray-500);
    line-height: 1.4;
    margin: 0;
}

.import-choice-card.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.prestep-template-area {
    margin-top: 12px;
    padding-top: 12px;
}

.prestep-template-area select {
    width: 100%;
    font-size: 0.8125rem;
    padding: 8px 10px;
}


.quote-bg-preview {
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.quote-bg-preview img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

/* ============ SKELETON LOADER ============ */

@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.3; }
}

.skeleton {
    background: var(--gray-400);
    border-radius: 4px;
    animation: skeleton-pulse 1.2s ease-in-out infinite;
}

.skeleton-card {
    pointer-events: none;
}

.skeleton-title {
    width: 55%;
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text {
    width: 40%;
    height: 12px;
    display: inline-block;
}

.skeleton-text-sm {
    width: 22%;
    height: 12px;
    display: inline-block;
    margin-left: 8px;
}

.skeleton-price {
    width: 80px;
    height: 20px;
}

.skeleton-btn {
    width: 72px;
    height: 30px;
    border-radius: 6px;
    display: inline-block;
}

/* ============ APP FOOTER ============ */

.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    font-size: 0.75rem;
    color: var(--gray-400);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    z-index: 10;
}

.app-footer a {
    color: var(--gray-500);
    text-decoration: none;
}

.app-footer a:hover {
    color: var(--purple-600);
    text-decoration: underline;
}

/* ============ PDF ARCHIVE ============ */
.pdf-archive-dialog {
    max-width: 600px;
    width: 94%;
}

.pdf-archive-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.pdf-archive-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.pdf-archive-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pdf-archive-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
}

.pdf-archive-info {
    flex: 1;
    min-width: 0;
}

.pdf-archive-info strong {
    display: block;
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-archive-type {
    font-size: 0.6875rem;
    color: var(--gray-500);
}

.pdf-archive-meta {
    display: flex;
    gap: 10px;
    font-size: 0.6875rem;
    color: var(--gray-400);
    flex-shrink: 0;
}

.pdf-archive-status {
    font-weight: 600;
}

.pdf-archive-status.fresh {
    color: #059669;
}

.pdf-archive-status.stale {
    color: #d97706;
}

/* ============ IMPORT SOURCE CARDS ============ */
.import-source-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.import-source-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    color: var(--white);
}

.icon-xlsx { background: #217346; }
.icon-csv  { background: #3b82f6; }
.icon-api  { background: #8b5cf6; }
.icon-xml  { background: #f59e0b; color: #78350f; }
.icon-file { background: #6b7280; }

.import-source-icon-img {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    object-fit: contain;
}

.import-source-body {
    flex: 1;
    min-width: 0;
}

.import-source-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.import-source-header strong {
    font-size: 0.875rem;
}

.import-source-meta {
    font-size: 0.75rem;
    color: var(--gray-500);
    line-height: 1.5;
    word-break: break-all;
}

.import-source-meta span {
    display: inline-block;
    margin-right: 12px;
}

.import-source-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.freq-badge {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.freq-manual  { background: var(--gray-100); color: var(--gray-500); }
.freq-daily   { background: #dbeafe; color: #1e40af; }
.freq-weekly  { background: #e0e7ff; color: #4338ca; }
.freq-monthly { background: #fae8ff; color: #86198f; }
.freq-push    { background: #d1fae5; color: #065f46; }

/* Import help panel */
.import-help-panel {
    display: none;
    margin-bottom: 16px;
}

.import-help-panel.visible {
    display: block;
}

.import-help-content {
    padding: 16px 20px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.import-help-content h4 {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 12px;
}

.import-help-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.import-help-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.import-help-item strong {
    font-size: 0.8125rem;
    display: block;
    margin-bottom: 2px;
}

.import-help-item p {
    font-size: 0.75rem;
    color: var(--gray-500);
    line-height: 1.4;
    margin: 0;
}

/* ============ CALENDAR ============ */
.calendar-wrapper {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    padding: 20px;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.calendar-nav h3 {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--gray-800);
    min-width: 160px;
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.cal-header {
    background: var(--gray-50);
    padding: 8px 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    text-align: center;
}

.cal-header.cal-weekend {
    color: var(--gray-400);
}

.cal-day {
    background: var(--white);
    min-height: 90px;
    padding: 4px;
    cursor: pointer;
    transition: background 100ms ease;
    position: relative;
}

.cal-day:hover {
    background: var(--purple-50);
}

.cal-day.other-month {
    background: var(--gray-50);
    opacity: 0.5;
}

.cal-day.today {
    background: var(--purple-50);
    box-shadow: inset 0 0 0 2px var(--purple-400);
}

.cal-day-num {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-700);
    padding: 2px 4px;
}

.cal-day.today .cal-day-num {
    color: var(--purple-700);
}

.cal-day.cal-weekend .cal-day-num {
    color: var(--gray-400);
}

.cal-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 2px;
}

.cal-event {
    font-size: 0.6875rem;
    padding: 2px 5px;
    border-radius: 4px;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    line-height: 1.3;
    font-weight: 500;
}

.cal-event:hover {
    filter: brightness(0.85);
    transform: scale(1.02);
}

.cal-event.color-green  { background: #22c55e; }
.cal-event.color-blue   { background: #3b82f6; }
.cal-event.color-orange { background: #f59e0b; color: #78350f; }
.cal-event.color-purple { background: #8b5cf6; }
.cal-event.color-red    { background: #ef4444; }

.cal-event-more {
    font-size: 0.625rem;
    color: var(--gray-500);
    padding: 0 4px;
    font-weight: 600;
}

/* All overlays are now scrollable via the base .overlay rule */

.event-dialog {
    max-width: 440px;
    width: 90%;
    margin: auto;
}

.event-dialog .color-options {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    padding: 4px;
}

.color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 150ms ease;
}

.color-option:hover {
    transform: scale(1.15);
}

.color-option.active {
    border-color: var(--gray-800);
    box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--gray-400);
}

.color-option.c-green  { background: #22c55e; }
.color-option.c-blue   { background: #3b82f6; }
.color-option.c-orange { background: #f59e0b; }
.color-option.c-purple { background: #8b5cf6; }
.color-option.c-red    { background: #ef4444; }

/* Searchable dropdown */
.searchable-select {
    position: relative;
}

.searchable-select input {
    width: 100%;
}

.searchable-select .ss-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 180px;
    overflow-y: auto;
    z-index: 50;
    margin-top: 2px;
}

.searchable-select .ss-dropdown.visible {
    display: block;
}

.searchable-select .ss-option {
    padding: 8px 12px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background 100ms ease;
}

.searchable-select .ss-option:hover {
    background: var(--purple-50);
}

.searchable-select .ss-empty {
    padding: 8px 12px;
    font-size: 0.8125rem;
    color: var(--gray-400);
    font-style: italic;
}

/* Today panel on overview */
.today-panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--purple-200);
    padding: 16px 20px;
    margin-bottom: 16px;
}

.today-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.today-panel-header h4 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--purple-700);
    display: flex;
    align-items: center;
    gap: 6px;
}

.today-panel-header h4 i {
    font-size: 0.8em;
}

.today-event-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.today-event-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
}

.today-event-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.today-event-dot.color-green  { background: #22c55e; }
.today-event-dot.color-blue   { background: #3b82f6; }
.today-event-dot.color-orange { background: #f59e0b; }
.today-event-dot.color-purple { background: #8b5cf6; }
.today-event-dot.color-red    { background: #ef4444; }

.today-event-time {
    color: var(--gray-400);
    font-size: 0.75rem;
    min-width: 40px;
}

.today-event-title {
    color: var(--gray-700);
    font-weight: 500;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {

    /* --- Base --- */
    html, body { overflow-x: hidden; }
    body { font-size: 0.875rem; }
    .app-footer { display: none; }
    .container { padding: 16px 12px 100px; }

    /* --- Navbar --- */
    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 12px;
        gap: 6px;
    }

    .nav-brand { flex: 1; }
    .nav-logo { height: 24px; }

    .nav-user {
        gap: 6px;
        font-size: 0;
    }
    .nav-user span { display: none; }
    .nav-user .btn { font-size: 0.6875rem; padding: 6px 10px; }

    /* Bottom tab bar */
    .nav-tabs {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: var(--white);
        border-top: 1px solid var(--gray-200);
        box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
        display: flex;
        justify-content: stretch;
        gap: 0;
        padding: 0;
    }

    .nav-tab {
        flex: 1;
        flex-direction: column;
        gap: 2px;
        padding: 8px 4px 10px;
        border-radius: 0;
        font-size: 0.625rem;
        justify-content: center;
        min-height: 52px;
    }

    .nav-tab i {
        font-size: 1rem;
        opacity: 0.8;
    }

    .nav-tab.active {
        background: var(--purple-50);
    }

    /* --- Page headers --- */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 16px;
    }

    .page-header h2 { font-size: 1.125rem; }

    .page-header-actions {
        width: 100%;
        flex-direction: row;
        gap: 8px;
    }

    .page-header-actions > .btn {
        flex: 1;
        justify-content: center;
    }

    .page-header-actions > .dot-menu-wrapper {
        flex-shrink: 0;
    }

    /* --- Overview page --- */
    .credits-banner { font-size: 0.75rem; padding: 8px 12px; }

    .dashboard-card { padding: 14px 12px; margin-bottom: 16px; }
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 12px;
    }

    .period-toggle { align-self: stretch; }
    .period-btn { flex: 1; text-align: center; padding: 6px 8px; }

    .dashboard-stats {
        gap: 12px;
        flex-wrap: wrap;
        margin-bottom: 12px;
    }

    .stat-box { min-width: 0; flex: 1 1 45%; }
    .stat-value { font-size: 1rem; }

    .chart-container canvas { max-height: 180px; }

    /* Project cards */
    .project-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 14px;
    }

    .project-info { width: 100%; }
    .project-info h3 { font-size: 0.9375rem; }

    .project-meta {
        flex-wrap: wrap;
        gap: 6px 10px;
    }

    .project-total {
        margin-right: 0;
        font-size: 1rem;
    }

    .project-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 6px;
    }

    .project-actions .btn-icon,
    .project-actions .payment-badge {
        min-height: 36px;
        min-width: 36px;
    }

    /* --- Create page --- */
    .address-columns {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .address-col {
        padding: 14px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-group {
        min-width: 0;
        width: 100%;
        overflow: hidden;
    }

    input[type="date"],
    input[type="time"] {
        max-width: 100%;
        min-width: 0;
        min-height: 44px;
        width: 100% !important;
        -webkit-appearance: none;
        appearance: none;
    }

    .form-section h3 { font-size: 0.75rem; }

    /* Items table → card layout */
    .items-table-wrapper { overflow: visible; }

    .items-table thead { display: none; }

    .items-table tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 4px 6px;
        padding: 12px 12px 10px;
        margin-bottom: 8px;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius);
        position: relative;
    }

    .items-table tbody tr.row-work {
        border-color: #fde68a;
    }
    [data-theme="dark"] .items-table tbody tr.row-work {
        border-color: #4a3520;
    }

    .items-table tbody tr.row-custom {
        border-color: #bbf7d0;
    }
    [data-theme="dark"] .items-table tbody tr.row-custom {
        border-color: #1a3d24;
    }

    .items-table td { padding: 0; }

    /* Drag handle — hide on mobile */
    .items-table .td-drag { display: none; }

    /* Name — full width, leave room for delete btn */
    .items-table .td-name { grid-column: 1 / -1; padding-right: 36px; margin-bottom: 4px; }

    /* Size badge cell — hide visual, hidden inputs stay in DOM */
    .items-table .td-size { display: none; }

    /* VAT column — hide on mobile (visible in totals instead) */
    .items-table .td-vat { display: none !important; }

    /* Delete button — top-right corner */
    .items-table .td-delete {
        position: absolute;
        top: 10px;
        right: 8px;
    }

    /* Labels */
    .items-table .td-base::before,
    .items-table .td-markup::before,
    .items-table .td-price::before,
    .items-table .td-qty::before,
    .items-table .td-unit::before,
    .items-table .td-total::before {
        display: block;
        font-size: 0.5625rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--gray-400);
        margin-bottom: 2px;
    }

    .items-table .td-base::before { content: 'Zákl. cena'; }
    .items-table .td-markup::before { content: 'Přirážka %'; }
    .items-table .td-price::before { content: 'Cena'; }
    .items-table .td-qty::before { content: 'Množství'; }
    .items-table .td-unit::before { content: 'Jed.'; }
    .items-table .td-total::before { content: 'Celkem'; }

    /* Make inputs fill their grid cell */
    .items-table input,
    .items-table select {
        width: 100%;
        font-size: 0.8125rem;
    }

    .item-buttons {
        gap: 6px;
    }

    .item-buttons .btn {
        flex: 1;
        font-size: 0.75rem;
        padding: 8px 6px;
    }

    /* VAT row */
    .vat-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .totals-bar {
        padding: 12px 14px;
    }

    .totals-row strong { font-size: 0.9375rem; }
    .totals-grand strong { font-size: 1.125rem; }

    /* Form actions */
    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* ARES row */
    .btn-ares {
        width: 100%;
        justify-content: center;
        margin-bottom: 12px;
    }

    /* --- Database page --- */
    .db-creator { padding: 14px; }

    .db-form-row {
        flex-direction: column;
        gap: 0;
        align-items: stretch;
    }

    .db-form-row .form-group { flex: unset; }

    .db-form-row > .btn {
        width: 100%;
        justify-content: center;
        margin-bottom: 12px;
    }

    .currency-input-group .currency-toggle {
        width: 44px;
    }

    .db-table-controls {
        flex-direction: column;
        gap: 8px;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 580px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size: 0.8125rem;
    }

    /* --- Calendar --- */
    .calendar-wrapper { padding: 12px; }
    .calendar-nav h3 { font-size: 0.875rem; min-width: 120px; }
    .cal-day { min-height: 60px; padding: 2px; }
    .cal-day-num { font-size: 0.6875rem; }
    .cal-event { font-size: 0.5625rem; padding: 1px 3px; }
    .event-dialog { width: 96%; padding: 20px; }

    /* --- Import page --- */
    .upload-zone { padding: 28px 16px; }

    .import-choice-cards {
        grid-template-columns: 1fr;
    }

    #import-preview .db-form-row {
        flex-direction: column;
        gap: 0;
    }

    /* --- Settings page --- */
    .settings-layout {
        flex-direction: column;
        gap: 0;
    }

    .settings-sidebar {
        display: none;
    }

    .settings-mobile-select {
        display: block;
    }

    .settings-panel { padding: 16px; }

    /* --- Toasts --- */
    #toast-container {
        bottom: 68px;
        left: 12px;
        right: 12px;
        transform: none;
    }

    .toast {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }

    /* --- Confirm dialog --- */
    .confirm-dialog {
        width: 94%;
        padding: 20px;
    }

    /* --- Touch targets --- */
    .btn { min-height: 44px; }
    .btn-sm { min-height: 38px; }
    .btn-icon { min-height: 44px; min-width: 44px; }

    .dot-menu { max-width: calc(100vw - 24px); }
    .dot-menu-item { min-height: 44px; display: flex; align-items: center; }

    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="email"],
    input[type="date"],
    input[type="time"],
    select,
    textarea {
        font-size: 1rem;
        padding: 10px 12px;
    }

    /* Prevent iOS zoom on focus */
    select, input, textarea {
        font-size: max(1rem, 16px);
    }

    /* Skeleton tweaks */
    .skeleton-card .project-actions { display: none; }
}
