:root {
    --primary: #0e7490;
    --primary-dark: #155e75;
    --accent: #f59e0b;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #172033;
    --muted: #64748b;
    --border: #dbe3ec;
    --danger: #dc2626;
    --success: #15803d;
    --shadow: 0 18px 45px rgba(15, 23, 42, .1);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Tahoma, Arial, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top right, #cffafe 0, transparent 32%), var(--bg);
}
button, input { font: inherit; }
.page-shell { min-height: 100vh; padding: 32px 16px; display: grid; place-items: center; }
.card { background: var(--card); border: 1px solid rgba(255,255,255,.8); border-radius: 24px; box-shadow: var(--shadow); }
.form-card { width: min(100%, 650px); padding: 34px; }
.brand-mark {
    position: relative;
    isolation: isolate;
    width: 158px;
    height: 66px;
    margin: 0 auto 18px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.38);
    border-radius: 22px 8px 22px 8px;
    background:
        radial-gradient(circle at 88% 14%, rgba(255,255,255,.32) 0 3px, transparent 4px),
        linear-gradient(135deg, #0891b2 0%, #0e7490 48%, #164e63 100%);
    box-shadow: 0 12px 28px rgba(14,116,144,.28), inset 0 1px 0 rgba(255,255,255,.28);
    color: #fff;
    direction: rtl;
    transform: rotate(-1deg);
}
.brand-mark::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: auto -22px -30px 18px;
    height: 64px;
    border: 12px solid rgba(255,255,255,.09);
    border-radius: 50%;
    transform: rotate(-8deg);
}
.brand-mark::after {
    content: '';
    position: absolute;
    right: 14px;
    bottom: 10px;
    width: 3px;
    height: 18px;
    border-radius: 3px;
    background: rgba(255,255,255,.33);
    box-shadow: 7px 5px 0 rgba(255,255,255,.2), 14px -3px 0 rgba(255,255,255,.26);
}
.brand-mark span { font-size: 23px; font-weight: 800; letter-spacing: -.8px; }
.brand-mark b {
    min-width: 37px;
    padding-right: 9px;
    border-right: 1px solid rgba(255,255,255,.42);
    font-size: 26px;
    font-weight: 900;
    line-height: 1;
    direction: ltr;
    text-align: left;
    font-variant-numeric: tabular-nums;
}
h1, h2 { margin-top: 0; }
h1 { margin-bottom: 8px; text-align: center; font-size: clamp(24px, 5vw, 32px); }
h2 { font-size: 20px; margin-bottom: 22px; }
.subtitle { color: var(--muted); line-height: 1.8; text-align: center; margin-top: 0; }
.steps { direction: rtl; display: flex; align-items: center; justify-content: center; margin: 30px 0 36px; }
.step-dot { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: #e2e8f0; font-weight: 700; transition: .2s; }
.step-dot.is-active, .step-dot.is-done { background: var(--primary); color: #fff; }
.step-line { width: 46px; height: 2px; background: #dbe3ec; }
.form-step { display: none; animation: enter .2s ease-out; }
.form-step.is-active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(7px); } }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.choice-button { min-height: 145px; padding: 22px 14px; display: flex; flex-direction: column; gap: 13px; align-items: center; justify-content: center; border: 2px solid var(--border); border-radius: 18px; color: var(--text); background: #fff; cursor: pointer; font-weight: 700; line-height: 1.7; transition: .2s; }
.choice-button:hover, .choice-button:focus-visible { border-color: var(--primary); background: #ecfeff; transform: translateY(-2px); outline: none; }
.choice-icon { font-size: 34px; }
.field { margin-bottom: 19px; }
.selection-banner {
    margin-bottom: 24px;
    padding: 13px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid #a5f3fc;
    border-radius: 14px;
    background: linear-gradient(135deg, #ecfeff, #f0fdfa);
}
.selection-banner span { color: var(--muted); font-size: 12px; }
.selection-banner strong { color: var(--primary-dark); font-size: 14px; }
.field label { display: block; margin-bottom: 8px; font-weight: 700; }
.field label b { color: var(--danger); }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 13px 14px; color: var(--text); background: #fff; outline: none; transition: .2s; }
.field textarea { resize: vertical; line-height: 1.8; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,116,144,.12); }
.field input.is-invalid { border-color: var(--danger); }
.numeric-input, .numeric-text, .number-cell { direction: ltr; text-align: left !important; unicode-bidi: plaintext; font-variant-numeric: tabular-nums; }
.field-hint, .field-error { display: block; margin-top: 6px; font-size: 12px; }
.field-hint { color: var(--muted); }
.field-error { color: var(--danger); min-height: 16px; }
.actions { display: flex; gap: 12px; justify-content: space-between; margin-top: 27px; }
.button { border: 0; border-radius: 12px; padding: 12px 20px; cursor: pointer; font-weight: 700; text-decoration: none; text-align: center; }
.button:disabled { opacity: .65; cursor: wait; }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { color: #334155; background: #e2e8f0; }
.button-danger { color: #fff; background: var(--danger); }
.button-danger:hover { background: #b91c1c; }
.confirmation-list { margin: 0; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.confirmation-list div { display: grid; grid-template-columns: 150px 1fr; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.confirmation-list div:last-child { border-bottom: 0; }
.confirmation-list dt { color: var(--muted); }
.confirmation-list dd { margin: 0; font-weight: 700; }
.upload-box { min-height: 230px; padding: 22px; border: 2px dashed #94a3b8; border-radius: 18px; display: flex; flex-direction: column; gap: 9px; align-items: center; justify-content: center; text-align: center; cursor: pointer; background: #f8fafc; }
.upload-box:hover { border-color: var(--primary); background: #ecfeff; }
.upload-box small { color: var(--muted); }
.upload-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: #cffafe; color: var(--primary-dark); font-size: 28px; }
#image-preview { display: none; max-width: 100%; max-height: 280px; border-radius: 12px; margin-top: 12px; }
#image-preview.is-visible { display: block; }
.multi-image-preview { display: none; width: 100%; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 9px; margin-top: 12px; }
.multi-image-preview.is-visible { display: grid; }
.multi-image-preview img { width: 100%; height: 100px; border-radius: 10px; object-fit: cover; background: #e2e8f0; }
.public-switch { width: max-content; max-width: 100%; margin: 22px auto 0; padding: 4px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; border: 1px solid var(--border); border-radius: 13px; background: #f8fafc; }
.public-switch a { padding: 8px 16px; border-radius: 9px; color: #475569; text-decoration: none; font-size: 13px; font-weight: 700; }
.public-switch a.is-active { color: #fff; background: var(--primary); box-shadow: 0 4px 12px rgba(14,116,144,.2); }
.step-one-switch { margin-top: 0; margin-bottom: 24px; }
.expense-steps { margin-bottom: 30px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.alert { padding: 13px 16px; margin: 20px 0; border-radius: 12px; line-height: 1.7; }
.alert-success { color: #166534; background: #dcfce7; border: 1px solid #bbf7d0; }
.alert-error { color: #991b1b; background: #fee2e2; border: 1px solid #fecaca; }

/* Admin */
.admin-body { background: #f8fafc; }
.admin-header { background: #0f172a; color: #fff; }
.admin-nav { width: min(1180px, calc(100% - 28px)); margin: auto; padding: 18px 0; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.admin-nav h1 { font-size: 19px; margin: 0; text-align: right; }
.admin-nav a { color: #cbd5e1; text-decoration: none; }
.admin-header-actions { display: flex; align-items: center; gap: 18px; }
.admin-tabs { padding: 4px; display: flex; gap: 3px; border-radius: 11px; background: rgba(255,255,255,.08); }
.admin-tabs a { padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 700; }
.admin-tabs a.is-active { color: #0f172a; background: #fff; }
.logout-link { font-size: 13px; }
.admin-main { width: min(1180px, calc(100% - 28px)); margin: 28px auto; }
.filter-card { margin-bottom: 22px; padding: 20px; border: 1px solid var(--border); border-radius: 18px; background: #fff; }
.filter-heading { margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.filter-heading h2 { margin: 0 0 5px; font-size: 18px; }
.filter-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.filter-active-badge { padding: 6px 11px; border-radius: 99px; color: #075985; background: #e0f2fe; font-size: 11px; font-weight: 800; white-space: nowrap; }
.filter-errors { margin: 0 0 18px; }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.filter-grid .field { margin-bottom: 15px; }
.filter-actions { display: flex; align-items: center; gap: 10px; }
.filter-actions .button { min-width: 135px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 18px; }
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 8px; font-size: 25px; direction: ltr; text-align: left; }
.table-card { background: #fff; border: 1px solid var(--border); border-radius: 18px; overflow: hidden; }
.table-title { padding: 18px 20px; margin: 0; }
.table-card-heading { padding-left: 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.table-card-heading .table-title { padding-left: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1040px; }
th, td { padding: 13px 12px; border-top: 1px solid var(--border); text-align: right; vertical-align: middle; font-size: 13px; }
th { color: #475569; background: #f8fafc; white-space: nowrap; }
.admin-body table th, .admin-body table td { direction: rtl; text-align: right; }
.admin-body table .number-cell, .admin-body table .numeric-text { direction: rtl; text-align: right !important; unicode-bidi: normal; }
.payment-row-construction > td { background: #f0fdf4; }
.payment-row-charge > td { background: #faf5ff; }
.payment-row-construction:hover > td { background: #dcfce7; }
.payment-row-charge:hover > td { background: #f3e8ff; }
.receipt-thumb { width: 64px; height: 64px; border-radius: 9px; object-fit: cover; display: block; }
.badge { display: inline-flex; align-items: center; border-radius: 99px; padding: 5px 9px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-match { background: #dcfce7; color: #166534; }
.badge-mismatch { background: #fee2e2; color: #b91c1c; }
.badge-error { background: #f1f5f9; color: #475569; }
.badge-manual { background: #dbeafe; color: #1d4ed8; }
.badge-duplicate { background: #fce7f3; color: #be185d; }
.duplicate-badge { display: flex; width: max-content; margin-top: 7px; text-decoration: none; }
.mismatch-amount { color: var(--danger); font-weight: 800; }
.inline-form { margin: 0; }
.row-actions { display: flex; flex-direction: column; align-items: stretch; gap: 7px; }
.row-actions .button { width: 100%; display: block; }
.button-small { padding: 8px 11px; font-size: 12px; white-space: nowrap; }
.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); }
.login-card { width: min(100%, 430px); padding: 30px; }
.ocr-details { max-width: 230px; line-height: 1.75; }
.expense-table { min-width: 760px; }
.expense-reason-cell { min-width: 260px; max-width: 560px; line-height: 1.9; white-space: normal; }
.expense-thumbnails { min-width: 150px; display: flex; flex-wrap: wrap; gap: 7px; }
.expense-edit-card { max-width: 820px; margin: auto; }
.expense-edit-images { display: flex; flex-wrap: wrap; gap: 10px; }
.expense-edit-images img { width: 110px; height: 110px; border-radius: 12px; object-fit: cover; background: #e2e8f0; }
.expense-edit-image-item { width: 130px; padding: 9px; display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--border); border-radius: 14px; background: #f8fafc; }
.expense-edit-image-item a, .expense-edit-image-item img { display: block; width: 100%; }
.expense-edit-image-item .button { width: 100%; }
.report-shell { width: min(1180px, calc(100% - 28px)); min-height: 100vh; margin: auto; padding: 32px 0; }
.report-card { padding: 24px; }
.report-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.report-heading h1, .report-heading .subtitle { text-align: right; }
.report-count { min-width: 110px; padding: 13px 16px; border: 1px solid #a5f3fc; border-radius: 14px; background: #ecfeff; }
.report-count span { display: block; color: var(--muted); font-size: 12px; }
.report-count strong { display: block; margin-top: 5px; font-size: 24px; direction: ltr; text-align: left; }
.report-color-legend { margin: 24px 2px 9px; display: flex; align-items: center; flex-wrap: wrap; gap: 9px 18px; color: var(--muted); font-size: 11px; font-weight: 500; }
.report-color-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 11px; height: 11px; display: inline-block; border: 1px solid rgba(15,23,42,.08); border-radius: 4px; }
.legend-construction { background: #dcfce7; }
.legend-charge { background: #f3e8ff; }
.report-table-wrap { margin-top: 0; border: 1px solid var(--border); border-radius: 15px; }
.report-table { min-width: 860px; }
.report-table .number-cell { text-align: right !important; }
.report-reason-cell { min-width: 220px; max-width: 420px; line-height: 1.8; white-space: normal; }
.pagination { margin-top: 22px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 7px; }
.pagination a, .pagination span { min-width: 38px; min-height: 38px; padding: 8px 11px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 10px; color: #475569; background: #fff; text-decoration: none; font-size: 13px; }
.pagination a:hover { border-color: var(--primary); color: var(--primary-dark); }
.pagination a.is-active { border-color: var(--primary); color: #fff; background: var(--primary); }
.edit-page { max-width: 1180px; }
.edit-layout { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 20px; align-items: start; }
.receipt-preview-card { position: sticky; top: 20px; padding: 14px; }
.receipt-preview-card img { display: block; width: 100%; max-height: 620px; object-fit: contain; border-radius: 12px; background: #f1f5f9; }
.replace-image-button { display: block; margin-top: 12px; padding: 11px 13px; border: 1px solid var(--primary); border-radius: 11px; color: var(--primary-dark); background: #ecfeff; text-align: center; font-weight: 700; cursor: pointer; }
.replace-image-button:hover { background: #cffafe; }
.replace-image-hint { display: block; margin-top: 8px; color: var(--muted); text-align: center; line-height: 1.6; }
.replace-image-hint.is-error { color: var(--danger); }
.receipt-summary { display: flex; flex-direction: column; gap: 8px; padding: 16px 4px 4px; line-height: 1.6; }
.edit-form-card { overflow: visible; }
.edit-form { padding: 0 20px 22px; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.field-full { grid-column: 1 / -1; }

@media (max-width: 760px) {
    .page-shell { padding: 16px 10px; align-items: start; }
    .form-card { padding: 24px 18px; border-radius: 18px; }
    .choice-grid { grid-template-columns: 1fr; }
    .choice-button { min-height: 115px; }
    .confirmation-list div { grid-template-columns: 1fr; gap: 5px; }
    .selection-banner { align-items: flex-start; flex-direction: column; gap: 5px; }
    .steps { margin: 24px 0 30px; }
    .step-line { width: 28px; }
    .actions .button { flex: 1; padding-inline: 10px; }
    .stats { grid-template-columns: 1fr 1fr; }
    .edit-layout { grid-template-columns: 1fr; }
    .receipt-preview-card { position: static; }
    .edit-grid { grid-template-columns: 1fr; }
    .field-full { grid-column: auto; }
    .admin-nav { align-items: flex-start; }
    .admin-header-actions { align-items: flex-end; flex-direction: column-reverse; gap: 10px; }
    .admin-main { margin-top: 18px; }
    .table-card-heading { padding-left: 14px; }
    .filter-card { padding: 17px 14px; }
    .filter-grid { grid-template-columns: 1fr; }
    .filter-actions .button { flex: 1; min-width: 0; padding-inline: 9px; }
    .report-shell { width: min(100% - 18px, 1180px); padding: 12px 0; }
    .report-card { padding: 18px 12px; border-radius: 16px; }
    .report-heading { align-items: flex-start; }
    .report-count { min-width: 90px; }
}
