/* =============================================================================
   Proforma Fatura Oluşturucu — KEREGE YAZILIM
   Direction A · "Fintech Noir"
   Deep ink app shell · single restrained indigo accent · bright corporate A4.
   Drop-in style.css (HTML + JS frozen). CSS only.
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500..700&family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@500;600&display=swap');

/* -----------------------------------------------------------------------------
   Design tokens
   -------------------------------------------------------------------------- */
:root {
    /* App shell — ink / charcoal blue-greys */
    --bg-main:        #070b14;
    --bg-panel:       #0a0f1c;
    --bg-card:        rgba(20, 27, 45, 0.55);
    --bg-card-solid:  #111726;
    --bg-input:       rgba(9, 14, 26, 0.85);
    --bg-elev:        rgba(30, 41, 59, 0.45);

    /* Hairline borders */
    --border-color:   rgba(148, 163, 184, 0.12);
    --border-strong:  rgba(148, 163, 184, 0.20);
    --border-hover:   rgba(99, 102, 241, 0.45);

    /* Text */
    --text-primary:   #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted:     #64748b;

    /* The ONE accent — refined indigo, used sparingly */
    --accent:         #6366f1;
    --accent-strong:  #818cf8;
    --accent-soft:    rgba(99, 102, 241, 0.14);
    --accent-ring:    rgba(99, 102, 241, 0.32);

    /* Functional */
    --success:        #10b981;
    --success-soft:   rgba(16, 185, 129, 0.12);
    --danger:         #f87171;
    --danger-soft:    rgba(248, 113, 113, 0.12);

    /* Depth — soft, restrained */
    --shadow-sm:      0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-md:      0 8px 24px -12px rgba(0, 0, 0, 0.55);
    --shadow-lg:      0 24px 60px -28px rgba(0, 0, 0, 0.70);

    --font-sans:      'Inter', system-ui, -apple-system, sans-serif;
    --font-mono:      'JetBrains Mono', ui-monospace, monospace;
    --font-display:   'Fraunces', 'Georgia', serif;

    /* Invoice "paper" — bright corporate counterpoint */
    --invoice-bg:         #ffffff;
    --invoice-ink:        #0f172a;
    --invoice-text:       #1e293b;
    --invoice-text-light: #64748b;
    --invoice-border:     #e6eaf0;
    --invoice-border-soft:#eef1f6;
    --invoice-tint:       #f7f8fb;
    --invoice-accent:     #4f46e5;
    --invoice-accent-deep:#3730a3;
    --invoice-accent-soft:#eef0fe;
    --invoice-success:    #059669;
}

/* -----------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    background-image:
        radial-gradient(900px 500px at 100% -10%, rgba(99, 102, 241, 0.08), transparent 60%),
        radial-gradient(700px 420px at 0% 0%, rgba(56, 189, 248, 0.04), transparent 55%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.006em;
}

/* -----------------------------------------------------------------------------
   Scrollbars
   -------------------------------------------------------------------------- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.22);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.45);
    background-clip: padding-box;
}

/* -----------------------------------------------------------------------------
   Header / shell
   -------------------------------------------------------------------------- */
header {
    background: linear-gradient(180deg, rgba(12, 17, 30, 0.92), rgba(7, 11, 20, 0.88));
    border-bottom: 1px solid var(--border-color);
    padding: 0.95rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.logo-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    background: linear-gradient(140deg, var(--accent-strong), var(--accent));
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    color: #fff;
    box-shadow:
        0 4px 14px -2px rgba(99, 102, 241, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.logo-text {
    min-width: 0;
}

.logo-text h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logo-text p {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 0.12rem;
    font-weight: 400;
}

.header-actions {
    display: flex;
    gap: 0.65rem;
    flex-shrink: 0;
}

/* -----------------------------------------------------------------------------
   App layout
   -------------------------------------------------------------------------- */
.app-container {
    display: flex;
    flex: 1;
    height: calc(100vh - 71px);
    overflow: hidden;
}

.editor-panel {
    width: 460px;
    min-width: 460px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.preview-panel {
    flex: 1;
    background-color: #060911;
    background-image: radial-gradient(rgba(99, 102, 241, 0.10) 1px, transparent 1px);
    background-size: 22px 22px;
    overflow-y: auto;
    padding: 3rem 2rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* -----------------------------------------------------------------------------
   Editor — cards & section titles
   -------------------------------------------------------------------------- */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.form-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: var(--accent-strong);
    margin-bottom: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--accent-strong);
    stroke: currentColor;
}

/* -----------------------------------------------------------------------------
   Editor — form controls
   -------------------------------------------------------------------------- */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1.1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    letter-spacing: 0.005em;
}

input,
textarea,
select {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 9px;
    padding: 0.6rem 0.75rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    line-height: 1.4;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
    appearance: none;
    -webkit-appearance: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

select {
    cursor: pointer;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
        linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% - 2px),
        calc(100% - 13px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 2rem;
}

select option {
    background-color: var(--bg-card-solid);
    color: var(--text-primary);
}

input:hover,
textarea:hover,
select:hover {
    border-color: var(--border-strong);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    background-color: rgba(13, 19, 34, 0.95);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.55;
}

/* Number inputs — keep clean */
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;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-secondary);
    user-select: none;
}

.checkbox-group input {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* -----------------------------------------------------------------------------
   Editor — dynamic item rows
   -------------------------------------------------------------------------- */
.items-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.item-editor-row {
    background: var(--bg-elev);
    border: 1px solid var(--border-color);
    border-radius: 11px;
    padding: 1rem;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.item-editor-row:hover {
    border-color: var(--border-strong);
    background: rgba(30, 41, 59, 0.60);
}

.item-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-index-badge {
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    text-transform: uppercase;
}

.btn-remove-item {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.28rem 0.5rem;
    border-radius: 7px;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.btn-remove-item svg {
    width: 14px;
    height: 14px;
    color: currentColor;
}

.btn-remove-item:hover {
    background-color: var(--danger-soft);
    color: #fca5a5;
}

.item-desc-input,
.item-duration-input,
.item-price-input {
    font-size: 0.83rem;
}

.item-desc-input {
    line-height: 1.5;
}

.item-price-input {
    font-variant-numeric: tabular-nums;
}

/* -----------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1.1rem;
    border-radius: 9px;
    font-family: var(--font-sans);
    font-size: 0.83rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.18s ease,
                background-color 0.18s ease, border-color 0.18s ease;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    color: inherit;
}

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: currentColor;
    stroke: currentColor;
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(140deg, var(--accent-strong), var(--accent));
    color: #fff;
    box-shadow: 0 4px 14px -3px rgba(99, 102, 241, 0.55),
                inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px -6px rgba(99, 102, 241, 0.65),
                inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-secondary {
    background-color: var(--bg-elev);
    border-color: var(--border-strong);
    color: var(--text-primary);
}
.btn-secondary:hover {
    transform: translateY(-2px);
    background-color: rgba(51, 65, 85, 0.55);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.btn-success {
    background: linear-gradient(140deg, #34d399, var(--success));
    color: #04231a;
    box-shadow: 0 4px 14px -3px rgba(16, 185, 129, 0.50),
                inset 0 1px 0 rgba(255, 255, 255, 0.30);
}
.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px -6px rgba(16, 185, 129, 0.60),
                inset 0 1px 0 rgba(255, 255, 255, 0.30);
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* =============================================================================
   THE INVOICE "PAPER" — bright corporate A4 (the most important surface)
   ============================================================================= */
.invoice-paper {
    background-color: var(--invoice-bg);
    color: var(--invoice-text);
    width: 794px;
    min-height: 1123px;
    padding: 3.25rem 3.25rem 2.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 13px;
    line-height: 1.55;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    letter-spacing: 0;
}

/* -----------------------------------------------------------------------------
   Invoice header — accent band treatment + brand/title
   -------------------------------------------------------------------------- */
.invoice-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2.25rem;
    padding-top: 0.75rem;
    position: relative;
}

/* Full-bleed accent band — anchored to the PAPER edges so it survives any
   padding change (screen 3.25rem <-> print 15mm) without misaligning. */
.invoice-paper::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 7px;
    background: linear-gradient(90deg, var(--invoice-accent), var(--invoice-accent-deep));
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.company-brand {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--invoice-ink);
    letter-spacing: -0.025em;
    line-height: 1.2;
    margin-bottom: 0.35rem;
    max-width: 22rem;
}

.company-subtitle {
    font-size: 0.78rem;
    color: var(--invoice-text-light);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.invoice-title-block {
    text-align: right;
    flex-shrink: 0;
}

.invoice-title-block h2 {
    font-family: var(--font-display);
    font-optical-sizing: auto;
    font-size: 1.95rem;
    font-weight: 600;
    letter-spacing: 0.045em;
    color: var(--invoice-accent);
    line-height: 1.0;
    margin-bottom: 0.85rem;
    text-transform: uppercase;
}

.invoice-meta-grid {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: end;
    gap: 0.3rem 0.9rem;
    text-align: right;
    font-size: 0.8rem;
}

.invoice-meta-label {
    font-weight: 600;
    color: var(--invoice-text-light);
    white-space: nowrap;
}

.invoice-meta-val {
    color: var(--invoice-ink);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* -----------------------------------------------------------------------------
   Parties — seller / buyer
   -------------------------------------------------------------------------- */
.invoice-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    margin-bottom: 2.25rem;
    padding: 1.5rem 0;
    border-top: 1px solid var(--invoice-border);
    border-bottom: 1px solid var(--invoice-border);
}

.party-box {
    position: relative;
    padding-left: 0.9rem;
}

.party-box::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.15rem;
    bottom: 0.15rem;
    width: 3px;
    border-radius: 3px;
    background: var(--invoice-accent);
}

.party-box h3 {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--invoice-accent);
    margin-bottom: 0.6rem;
    font-weight: 700;
}

.party-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--invoice-ink);
    letter-spacing: -0.01em;
    margin-bottom: 0.65rem;
    line-height: 1.3;
}

.party-details {
    font-size: 0.8rem;
    color: var(--invoice-text);
    display: flex;
    flex-direction: column;
    gap: 0.32rem;
}

.detail-row {
    display: flex;
    gap: 0.5rem;
    line-height: 1.45;
}

.detail-lbl {
    font-weight: 600;
    width: 90px;
    flex-shrink: 0;
    color: var(--invoice-text-light);
}

.detail-val {
    flex: 1;
    color: var(--invoice-text);
}

/* -----------------------------------------------------------------------------
   Items table — crisp solid header, no zebra
   -------------------------------------------------------------------------- */
.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
    font-size: 0.82rem;
}

.invoice-items-table th {
    background-color: var(--invoice-ink);
    color: #ffffff;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.07em;
    padding: 0.7rem 1rem;
    text-align: left;
    white-space: nowrap;
}

.invoice-items-table thead th:first-child {
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}
.invoice-items-table thead th:last-child {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
}

.invoice-items-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--invoice-border-soft);
    vertical-align: top;
    color: var(--invoice-text);
}

.invoice-items-table tbody tr:last-child td {
    border-bottom: 1px solid var(--invoice-border);
}

.invoice-items-table th.idx-col,
.invoice-items-table td.idx-col {
    text-align: center;
    width: 40px;
    color: var(--invoice-text-light);
    font-variant-numeric: tabular-nums;
}

.invoice-items-table th.center-col,
.invoice-items-table td.center-col {
    text-align: center;
    width: 80px;
}

.invoice-items-table th.num-col,
.invoice-items-table td.num-col {
    text-align: right;
    width: 120px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--invoice-ink);
}

.item-desc {
    font-weight: 700;
    color: var(--invoice-ink);
    margin-bottom: 0.2rem;
    white-space: pre-line;
    letter-spacing: -0.005em;
    line-height: 1.4;
}

.item-sub-desc {
    font-size: 0.72rem;
    color: var(--invoice-text-light);
    line-height: 1.5;
    font-weight: 400;
}

/* -----------------------------------------------------------------------------
   Bottom layout — notes / bank (left) + totals (right)
   -------------------------------------------------------------------------- */
.invoice-bottom-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 2.5rem;
    margin-top: 0.5rem;
    align-items: start;
}

.invoice-notes-block {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Bank card */
.bank-info-card {
    background-color: var(--invoice-tint);
    border: 1px solid var(--invoice-border);
    border-left: 3px solid var(--invoice-accent);
    padding: 1rem 1.1rem;
    border-radius: 0 8px 8px 0;
}

.bank-info-card h4 {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--invoice-accent);
    margin-bottom: 0.6rem;
    font-weight: 700;
}

.bank-row {
    font-size: 0.78rem;
    margin-bottom: 0.3rem;
    color: var(--invoice-text);
    line-height: 1.45;
}

.bank-row strong {
    color: var(--invoice-text-light);
    font-weight: 600;
    display: inline-block;
    width: 68px;
}

.bank-iban {
    background-color: var(--invoice-accent-soft);
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    word-break: break-all;
    margin-top: 0.35rem;
    display: block;
    color: var(--invoice-accent-deep);
    font-weight: 600;
    width: auto;
}

/* Notes card */
.notes-card {
    background-color: var(--invoice-tint);
    border: 1px solid var(--invoice-border);
    border-left: 3px solid var(--invoice-accent);
    padding: 1rem 1.1rem;
    border-radius: 0 8px 8px 0;
}

.notes-card h4 {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--invoice-accent);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.notes-content {
    font-size: 0.74rem;
    color: var(--invoice-text-light);
    white-space: pre-line;
    line-height: 1.65;
}

/* Totals */
.invoice-totals-block {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

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

.totals-table td {
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--invoice-text);
}

.totals-table tr td:first-child {
    color: var(--invoice-text-light);
    font-weight: 500;
}

.totals-table td.val {
    text-align: right;
    font-weight: 600;
    color: var(--invoice-ink);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Grand total — unmistakable */
.totals-table tr.grand-total td {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--invoice-ink);
    border-top: 2px solid var(--invoice-accent);
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
    background-color: var(--invoice-accent-soft);
    letter-spacing: -0.01em;
}

.totals-table tr.grand-total td:first-child {
    color: var(--invoice-accent-deep);
    padding-left: 0.7rem;
    border-top-left-radius: 6px;
}

.totals-table tr.grand-total td.val {
    color: var(--invoice-accent-deep);
    padding-right: 0.7rem;
    border-top-right-radius: 6px;
    font-variant-numeric: tabular-nums;
}

/* Discount row — success */
.totals-table tr.discount-row td {
    color: var(--invoice-success);
    padding-top: 0.7rem;
    font-weight: 600;
}
.totals-table tr.discount-row td.val {
    color: var(--invoice-success);
    font-weight: 800;
    font-size: 0.95rem;
}

.discount-tag {
    background-color: var(--success-soft);
    color: var(--invoice-success);
    font-size: 0.72rem;
    padding: 0.45rem 0.65rem;
    border-radius: 7px;
    margin-top: 0.75rem;
    text-align: center;
    border: 1px dashed rgba(5, 150, 105, 0.45);
    font-weight: 600;
    line-height: 1.4;
}

/* -----------------------------------------------------------------------------
   Invoice footer
   -------------------------------------------------------------------------- */
.invoice-footer {
    border-top: 1px solid var(--invoice-border);
    padding-top: 1.4rem;
    margin-top: 2.75rem;
    text-align: center;
    font-size: 0.72rem;
    color: var(--invoice-text-light);
    letter-spacing: 0.01em;
}

/* =============================================================================
   Responsive — stack the app
   ============================================================================= */
@media (max-width: 1200px) {
    header {
        padding: 0.85rem 1.25rem;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .editor-panel {
        width: 100%;
        min-width: 100%;
        height: auto;
        overflow-y: visible;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .preview-panel {
        padding: 2rem 1rem;
        overflow-y: visible;
    }

    .invoice-paper {
        width: 100%;
        min-height: auto;
        padding: 2rem;
    }
}

@media (max-width: 640px) {
    .header-actions .btn {
        padding: 0.55rem 0.7rem;
    }
    .invoice-bottom-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .invoice-parties {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .invoice-top {
        flex-direction: column;
        gap: 1.25rem;
    }
    .invoice-title-block,
    .invoice-meta-grid {
        text-align: left;
        justify-content: start;
    }
}

/* =============================================================================
   Print — clean A4 PDF, only the invoice
   ============================================================================= */
@media print {
    @page {
        size: A4;
        margin: 0;
    }

    html, body {
        background: #fff !important;
        background-image: none !important;
        color: #000 !important;
        height: auto !important;
        overflow: visible !important;
    }

    header,
    .editor-panel,
    .header-actions,
    .btn,
    .discount-tag {
        display: none !important;
    }

    .app-container {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }

    .preview-panel {
        background: none !important;
        background-image: none !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        display: block !important;
    }

    .invoice-paper {
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 15mm 15mm !important;
        page-break-inside: auto;
    }

    /* Keep accent band & colored surfaces in print */
    .invoice-paper::before,
    .party-box::before {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .invoice-items-table th {
        background-color: #0f172a !important;
        color: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .bank-info-card,
    .notes-card {
        background-color: #f7f8fb !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .bank-iban {
        background-color: #eef0fe !important;
        color: #3730a3 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .totals-table tr.grand-total td {
        background-color: #eef0fe !important;
        color: #3730a3 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .totals-table tr.discount-row td {
        color: #059669 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Avoid awkward breaks inside key blocks */
    .invoice-parties,
    .invoice-items-table,
    .invoice-bottom-layout,
    .bank-info-card,
    .notes-card,
    .invoice-totals-block {
        page-break-inside: avoid;
    }
}

/* =============================================================================
   Proje Bilgileri kartı (fatura üzerinde)
   ============================================================================= */
/* İki sütunlu hizalı satırlar (Proje + Banka kutuları): etiket | değer, ikisi de sola yaslı,
   değerler kendi sütununda dikey olarak aynı hizada. */
.bank-info-card .bank-row {
    display: grid;
    grid-template-columns: 92px 1fr;
    column-gap: 0.45rem;
    align-items: baseline;
    color: var(--invoice-text);
    line-height: 1.45;
}
.bank-info-card .bank-row strong {
    display: block;
    width: auto;
    margin: 0;
    color: var(--invoice-text-light);
    font-weight: 600;
}
.bank-info-card .bank-row span {
    text-align: left;
}
/* IBAN satırı istisnası: geniş mono çip için etiket üstte, değer altta tam genişlik */
.bank-info-card .bank-row:has(.bank-iban) {
    display: block;
}

/* =============================================================================
   Kayıtlı Faturalar — modal (popup) + toast bildirim
   ============================================================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 6vh 1.25rem 2rem;
    background: rgba(3, 6, 14, 0.66);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    overflow-y: auto;
}
.modal-overlay.is-open {
    display: flex;
    animation: modalFade 0.18s ease;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }

.modal {
    width: 100%;
    max-width: 640px;
    background: var(--bg-card-solid);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalRise 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalRise { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.09), transparent);
}
.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.modal-close {
    background: var(--bg-elev);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    transition: color 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}
.modal-close:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: var(--accent-soft);
}

.modal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.4rem;
    border-bottom: 1px solid var(--border-color);
}
.modal-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.modal-body {
    padding: 1rem 1.4rem 1.4rem;
    max-height: 56vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    background: var(--bg-elev);
    border: 1px solid var(--border-color);
    border-radius: 11px;
    transition: border-color 0.18s ease, transform 0.18s ease;
}
.history-item:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}
.history-item.is-current {
    border-color: var(--border-hover);
    box-shadow: 0 0 0 1px var(--accent-ring);
}
.history-item-main { min-width: 0; }
.history-item-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.history-item-sub {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.22rem;
}
.history-item-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.28rem;
}
.badge-current {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--accent-soft);
    color: var(--accent-strong);
    border: 1px solid rgba(99, 102, 241, 0.3);
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    font-weight: 700;
}

.history-item-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.6rem;
    flex-shrink: 0;
}
.history-item-total {
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--accent-strong);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.history-item-actions { display: flex; gap: 0.4rem; }

.hbtn {
    border: 1px solid var(--border-color);
    background: var(--bg-card-solid);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.34rem 0.65rem;
    border-radius: 7px;
    cursor: pointer;
    transition: color 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}
.hbtn-load:hover { color: #fff; background: var(--accent); border-color: var(--accent); }
.hbtn-del:hover { color: #fff; background: var(--danger); border-color: var(--danger); }

.history-empty {
    text-align: center;
    padding: 2.75rem 1rem;
    color: var(--text-secondary);
}
.history-empty-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.history-empty p { font-weight: 600; color: var(--text-primary); margin-bottom: 0.3rem; }
.history-empty span { font-size: 0.78rem; color: var(--text-muted); }

/* Toast bildirim */
.toast {
    position: fixed;
    bottom: 1.6rem;
    left: 50%;
    transform: translateX(-50%) translateY(1.5rem);
    z-index: 1100;
    background: var(--bg-card-solid);
    border: 1px solid var(--border-hover);
    color: var(--text-primary);
    padding: 0.7rem 1.15rem;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 640px) {
    .history-item { flex-direction: column; }
    .history-item-side { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
}

@media print {
    .modal-overlay,
    .toast { display: none !important; }
}

/* =============================================================================
   Tek sayfaya sığdırma — yalnızca yazdırma (ekran görünümü değişmez)
   ============================================================================= */
@media print {
    .invoice-paper {
        font-size: 10.3px;
        line-height: 1.4;
        padding: 9mm 12mm !important;
        /* Sayfayı doldur ki footer en altta otursun, altında büyük boşluk kalmasın
           (296mm < 297mm A4 => 2. sayfa taşması olmaz). space-between footer'ı dibe iter. */
        min-height: 296mm !important;
        height: auto !important;
        overflow: visible !important;
    }
    .invoice-paper::before { height: 5px; }

    .invoice-top { margin-bottom: 0.9rem; padding-top: 0.35rem; }
    .invoice-title-block h2 { font-size: 1.45rem; margin-bottom: 0.45rem; }
    .company-brand { font-size: 1.1rem; margin-bottom: 0.2rem; }
    .company-subtitle { font-size: 0.72rem; }
    .invoice-meta-grid { gap: 0.12rem 0.8rem; font-size: 0.72rem; }

    .invoice-parties { padding: 0.8rem 0; margin-bottom: 0.85rem; gap: 1.5rem; }
    .party-box h3 { margin-bottom: 0.35rem; }
    .party-name { font-size: 0.9rem; margin-bottom: 0.35rem; }
    .party-details { gap: 0.14rem; font-size: 0.73rem; }

    .invoice-items-table { margin-bottom: 0.85rem; font-size: 0.73rem; }
    .invoice-items-table th { padding: 0.42rem 0.65rem; font-size: 0.63rem; }
    .invoice-items-table td { padding: 0.42rem 0.65rem; }
    .item-desc { line-height: 1.3; margin-bottom: 0.08rem; }
    .item-sub-desc { font-size: 0.66rem; }

    .invoice-bottom-layout { gap: 1.4rem; margin-top: 0; }
    .invoice-notes-block { gap: 0.5rem; }
    .bank-info-card, .notes-card { padding: 0.58rem 0.78rem; }
    .bank-info-card h4, .notes-card h4 { margin-bottom: 0.28rem; font-size: 0.64rem; }
    .bank-row { margin-bottom: 0.14rem; font-size: 0.7rem; }
    .bank-iban { margin-top: 0.2rem; padding: 0.24rem 0.4rem; font-size: 0.7rem; }
    .notes-content { font-size: 0.66rem; line-height: 1.4; }

    .totals-table td { padding: 0.3rem 0; font-size: 0.76rem; }
    .totals-table tr.grand-total td { font-size: 0.98rem; padding-top: 0.5rem; padding-bottom: 0.5rem; }

    .invoice-footer { margin-top: 0; padding-top: 0.65rem; font-size: 0.64rem; }
}
