:root {
    --primary: #315f91;
    --primary-dark: #24496f;
    --bg: #f3f6fa;
    --panel: #ffffff;
    --text: #172033;
    --muted: #657086;
    --line: #dce3ec;
    --danger: #c73535;
    --success: #18794e;
    --radius: 14px;
    --shadow: 0 8px 28px rgba(25, 45, 74, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Arial, "Segoe UI", sans-serif; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.container { width: min(1120px, calc(100% - 28px)); margin-inline: auto; }
.container.narrow { width: min(620px, calc(100% - 28px)); }
.page-space { padding-block: 26px 44px; }
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.header-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { width: 52px; height: 52px; object-fit: contain; }
.brand span { display: grid; }
.brand strong { font-size: 1.08rem; }
.brand small { color: var(--muted); }
.nav-actions, .form-actions, .section-head, .page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 16px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; line-height: 1.1; transition: .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: #fff; border-color: var(--line); color: var(--text); }
.btn.danger { background: #fff; border-color: #f0bbbb; color: var(--danger); }
.btn.small { min-height: 34px; padding: 7px 10px; font-size: .82rem; }
.btn.large { min-height: 48px; padding-inline: 24px; }
.btn.wide { width: 100%; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.panel h1, .panel h2, .page-title h1, .section-head h1 { margin: 0; }
.panel h2 { font-size: 1.06rem; }
.page-title { margin-bottom: 18px; }
.page-title h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
.page-title p, .section-head p { margin: 4px 0 0; color: var(--muted); }
.alert { margin-bottom: 18px; padding: 13px 16px; border-radius: 10px; border: 1px solid; }
.alert.success { color: #0d6942; background: #eaf8f1; border-color: #a8dfc5; }
.alert.error { color: #9e2424; background: #fff0f0; border-color: #efb7b7; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.stat-card span { display: block; color: var(--muted); font-size: .88rem; }
.stat-card strong { display: block; margin-top: 6px; font-size: 1.35rem; color: var(--primary-dark); }
.section-head { margin-bottom: 18px; }
.section-head h1 { font-size: 1.35rem; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: #eef3f8; color: #334155; font-size: .82rem; text-align: left; }
.data-table th, .data-table td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.actions-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.actions-cell form { display: inline; margin: 0; }
.empty-state { padding: 42px 16px; text-align: center; }
.empty-state h2 { margin: 0 0 6px; }
.empty-state p { color: var(--muted); margin: 0 0 18px; }
.invoice-form { display: grid; gap: 16px; }
.form-section h2 { margin-bottom: 17px; color: var(--primary-dark); }
.form-grid { display: grid; gap: 15px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid label { display: grid; gap: 7px; }
.form-grid label > span { color: #3d495c; font-size: .86rem; font-weight: 700; }
.form-grid .span-two { grid-column: 1 / -1; }
input, textarea { width: 100%; border: 1px solid #cfd8e4; border-radius: 9px; background: #fff; color: var(--text); padding: 11px 12px; outline: none; }
input { min-height: 45px; }
textarea { resize: vertical; }
input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(49,95,145,.12); }
.issuer-note { display: grid; gap: 2px; margin-top: 16px; padding: 13px 15px; border-radius: 10px; background: #f3f7fb; color: #334155; }
.issuer-note span, .issuer-note small { color: var(--muted); }
.calculation-note { margin: 15px 0 0; color: var(--muted); font-size: .84rem; }
.calculation-boxes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.calculation-boxes > div { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; }
.calculation-boxes span { display: block; color: var(--muted); font-size: .78rem; }
.calculation-boxes strong { display: block; margin-top: 5px; font-size: 1.05rem; }
.calculation-boxes .grand { background: var(--primary); border-color: var(--primary); color: #fff; }
.calculation-boxes .grand span { color: rgba(255,255,255,.78); }
.form-actions { padding: 4px 0 18px; justify-content: flex-end; }
.install-box { margin-top: 8vh; text-align: center; }
.install-logo { width: 110px; height: 110px; object-fit: contain; }
.install-box h1 { margin: 8px 0 20px; }
.install-box p { color: var(--muted); text-align: left; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(145deg, #eaf1f9, #f8fafc); }
.login-wrap { width: min(430px, 100%); }
.login-card { margin: 0; padding: 34px; text-align: center; }
.login-logo { display: block; width: 92px; height: 92px; margin: 0 auto 18px; object-fit: contain; }
.login-card h1 { margin: 0 0 7px; color: var(--primary-dark); }
.login-card > p { margin: 0 0 20px; color: var(--muted); }
.login-card form { display: grid; gap: 16px; text-align: left; }
.login-card label { display: grid; gap: 7px; color: #3d495c; font-size: .86rem; font-weight: 700; }
.login-card .btn { width: 100%; margin-top: 4px; }
.login-credentials { margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; line-height: 1.7; }
.logout-link { color: var(--danger) !important; }
.danger-zone { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-color: #efb7b7; }
.danger-zone h2, .clean-result h2 { margin: 0; }
.danger-zone p, .clean-result p { margin: 5px 0 0; color: var(--muted); }
.clean-panel form { display: grid; gap: 18px; }
.clean-warning { display: grid; gap: 5px; margin-bottom: 20px; padding: 15px 16px; border: 1px solid #efb7b7; border-radius: 10px; background: #fff0f0; color: #9e2424; }
.clean-warning span { color: #7c3030; }
.field-label { display: grid; gap: 7px; color: #3d495c; font-size: .86rem; font-weight: 700; }
.confirm-check { display: flex; align-items: flex-start; gap: 10px; color: #3d495c; }
.confirm-check input { flex: 0 0 auto; width: 19px; min-height: 19px; margin: 2px 0 0; }
.clean-actions { display: flex; justify-content: flex-end; gap: 10px; }
.clean-result { text-align: center; }
.clean-result .btn { margin-top: 18px; }
code { padding: 2px 5px; border-radius: 5px; background: #eef2f7; }

/* A4 fatura ön izlemesi */
.print-page { background: #dbe2ea; }
.print-toolbar { width: min(210mm, calc(100% - 24px)); margin: 18px auto 10px; display: flex; justify-content: flex-end; gap: 10px; }
.invoice-sheet { width: 210mm; min-height: 297mm; margin: 0 auto 24px; padding: 10mm; background: #fff; color: #000; box-shadow: 0 10px 35px rgba(0,0,0,.2); font-family: Arial, sans-serif; }
.invoice-title { min-height: 20mm; display: flex; align-items: center; justify-content: center; border-bottom: 2px solid #111; }
.invoice-title h1 { margin: 0; font-size: 15pt; text-align: center; }
.invoice-top-grid { display: grid; grid-template-columns: 62% 38%; border: 1px solid #111; border-top: 0; }
.invoice-info-block { border-right: 1px solid #111; }
.invoice-info-block h2 { margin: 0; padding: 2mm; background: var(--primary); color: #fff; font-size: 10pt; text-align: center; border-bottom: 1px solid #111; }
.invoice-info-block dl { display: grid; grid-template-columns: 44% 56%; margin: 0; }
.invoice-info-block dt, .invoice-info-block dd { min-height: 7mm; margin: 0; padding: 1.5mm; border-bottom: 1px solid #111; font-size: 8.5pt; overflow-wrap: anywhere; }
.invoice-info-block dt { font-weight: 700; border-right: 1px solid #111; }
.invoice-info-block dl:last-of-type dt:last-of-type, .invoice-info-block dl:last-of-type dd:last-of-type { border-bottom: 0; }
.invoice-meta-block { min-width: 0; }
.invoice-meta-block > div { display: grid; grid-template-columns: 62% 38%; border-bottom: 1px solid #111; }
.invoice-meta-block span, .invoice-meta-block strong { padding: 2mm; font-size: 9pt; }
.invoice-meta-block span { text-align: center; font-weight: 700; border-right: 1px solid #111; }
.invoice-meta-block strong { text-align: center; }
.invoice-meta-block img { display: block; width: 35mm; height: 35mm; margin: 10mm auto; object-fit: contain; opacity: .92; }
.invoice-lines { width: 100%; border-collapse: collapse; margin-top: 4mm; table-layout: fixed; }
.invoice-lines th, .invoice-lines td { border: 1px solid #111; text-align: center; padding: 1.5mm; font-size: 8.5pt; }
.invoice-lines th { background: var(--primary); color: #fff; font-weight: 700; }
.invoice-lines th:nth-child(1) { width: 34%; }
.invoice-lines th:nth-child(2) { width: 11%; }
.invoice-lines th:nth-child(3) { width: 11%; }
.invoice-lines th:nth-child(4) { width: 8%; }
.invoice-lines th:nth-child(5) { width: 17%; }
.invoice-lines th:nth-child(6) { width: 19%; }
.invoice-lines .main-line td { height: 18mm; }
.invoice-lines .blank-line td { height: 8mm; }
.invoice-totals-wrap { display: flex; justify-content: flex-end; }
.invoice-totals { width: 36%; border-collapse: collapse; }
.invoice-totals th, .invoice-totals td { border: 1px solid #111; padding: 1.4mm; font-size: 9pt; }
.invoice-totals th { width: 55%; background: var(--primary); color: #fff; text-align: left; }
.invoice-totals td { font-weight: 700; text-align: right; }
.amount-words { min-height: 15mm; margin-top: 4mm; padding: 2mm; border: 1px solid #111; font-size: 9pt; }
.amount-words strong, .amount-words span { display: block; }
.amount-words span { margin-top: 2mm; font-weight: 700; }
.bank-info { margin-top: 4mm; border: 1px solid #111; }
.bank-info h2 { margin: 0; padding: 1.5mm; text-align: center; font-size: 10pt; border-bottom: 1px solid #111; }
.bank-info > div { display: grid; grid-template-columns: 34% 66%; }
.bank-info > div + div { border-top: 1px solid #111; }
.bank-info strong, .bank-info span { min-height: 7mm; padding: 1.5mm; font-size: 9pt; }
.bank-info strong { border-right: 1px solid #111; }
.bank-info span { text-align: center; }

@media (max-width: 760px) {
    .header-inner { min-height: 70px; align-items: center; }
    .brand img { width: 46px; height: 46px; }
    .brand strong { font-size: .98rem; }
    .brand small { font-size: .76rem; }
    .nav-actions .btn.secondary { display: none; }
    .nav-actions .logout-link { display: inline-flex !important; }
    .stats { grid-template-columns: 1fr; gap: 10px; }
    .stat-card { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; }
    .stat-card strong { margin: 0; font-size: 1.15rem; }
    .panel { padding: 16px; border-radius: 12px; }
    .section-head { align-items: stretch; flex-direction: column; }
    .mobile-wide { width: 100%; }
    .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
    .form-grid .span-two { grid-column: auto; }
    .calculation-boxes { grid-template-columns: repeat(2, 1fr); }
    .form-actions { display: grid; grid-template-columns: 1fr 1.5fr; }
    .form-actions .btn { width: 100%; }

    .data-table.responsive, .data-table.responsive tbody, .data-table.responsive tr, .data-table.responsive td { display: block; width: 100%; }
    .data-table.responsive thead { display: none; }
    .data-table.responsive tr { margin-bottom: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
    .data-table.responsive td { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--line); text-align: right; }
    .data-table.responsive td::before { content: attr(data-label); color: var(--muted); font-weight: 700; text-align: left; }
    .data-table.responsive td:last-child { border-bottom: 0; }
    .data-table.responsive .actions-cell { justify-content: flex-end; }
    .data-table.responsive .actions-cell::before { margin-right: auto; }
    .invoice-sheet { width: 100%; min-height: auto; margin: 0; padding: 10px; box-shadow: none; overflow-x: auto; }
    .print-toolbar { width: calc(100% - 20px); }
    .login-card { padding: 26px 20px; }
    .login-logo { width: 78px; height: 78px; }
    .danger-zone { align-items: stretch; flex-direction: column; }
    .danger-zone .btn { width: 100%; }
    .clean-actions { display: grid; grid-template-columns: 1fr; }
    .clean-actions .btn { width: 100%; }
}

@media print {
    @page { size: A4 portrait; margin: 0; }
    body.print-page { margin: 0; background: #fff; }
    .no-print { display: none !important; }
    .invoice-sheet { width: 210mm; min-height: 297mm; margin: 0; padding: 10mm; box-shadow: none; }
    .invoice-info-block h2, .invoice-lines th, .invoice-totals th { background: #315f91 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
