:root {
    --sidebar-width: min(400px, 92vw);
    --primary: #0c4a6e;
    --primary-hover: #1b6b9e;
    --secondary: #3282b8;
    --accent: #00a8e8;
    --surface: #ffffff;
    --surface-elevated: #f8fafc;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #059669;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(15, 76, 117, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 76, 117, 0.1), 0 2px 8px rgba(15, 76, 117, 0.06);
    --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
    --font: "Plus Jakarta Sans", "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
    --transition: 0.2s ease;
    --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
    --header-sticky-offset: 0px;
}

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

@keyframes authPanelIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

/* PDF anlık görüntüsü: oturum çubuğu gizlenir; cam efekt / filtre kaldırılır (html2canvas boş çıktı vermesin) */
html.is-pdf-snapshot,
body.is-pdf-snapshot {
    overflow: visible !important;
    height: auto !important;
}

body.is-pdf-snapshot .layout-root,
body.is-pdf-snapshot .layout-main,
body.is-pdf-snapshot .app-shell {
    overflow: visible !important;
    max-height: none !important;
}

body.is-pdf-snapshot #auth-gate[hidden] {
    display: none !important;
}

body.is-pdf-snapshot #invoice-container .session-bar {
    display: none !important;
}

body.is-pdf-snapshot #invoice-container {
    box-shadow: none !important;
    border: 1px solid var(--border) !important;
    background: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
}

body.is-pdf-snapshot .section-heading {
    display: none !important;
}

/* Üst öğede kalan transform/opacity html2canvas’ı boş çıktıya itebilir */
body.is-pdf-snapshot .layout-main {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
}

body.is-pdf-snapshot #invoice-container .table-responsive {
    overflow: visible !important;
}

body.is-pdf-snapshot #invoice-container * {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

body {
    font-family: var(--font);
    line-height: 1.55;
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(0, 168, 232, 0.12), transparent 55%),
        radial-gradient(900px 500px at 100% 20%, rgba(15, 76, 117, 0.08), transparent 50%),
        linear-gradient(180deg, #eef4f8 0%, #e8eef3 100%);
    min-height: 100dvh;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ——— Sol panel + ana düzen ——— */
.layout-root {
    min-height: 100dvh;
    position: relative;
}

.layout-main {
    min-width: 0;
}

body:not(.ui-ready) .layout-main {
    opacity: 0;
    transform: translateY(14px);
}

body.ui-ready .layout-main {
    animation: layoutReveal 0.52s var(--ease-smooth) forwards;
}

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100dvh;
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 250;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    transition: transform 0.28s ease;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.layout-root.sidebar-open .app-sidebar {
    transform: translateX(0);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 240;
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border: none;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    appearance: none;
}

.sidebar-backdrop[hidden] {
    display: none !important;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface-elevated), var(--surface));
    flex-shrink: 0;
}

.sidebar-brand {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sidebar-close-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--surface-elevated);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), background var(--transition);
}

.sidebar-close-btn:hover {
    color: var(--text);
    background: var(--border);
}

.sidebar-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
}

.sidebar-tab {
    flex: 1;
    padding: 10px 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background var(--transition), color var(--transition), border-color var(--transition), transform 0.15s ease;
}

.sidebar-tab i {
    font-size: 0.9rem;
    opacity: 0.88;
}

.sidebar-tab:active {
    transform: scale(0.98);
}

.sidebar-tab:hover {
    color: var(--primary);
    background: var(--surface-elevated);
}

.sidebar-tab.is-active {
    color: var(--primary);
    background: rgba(0, 168, 232, 0.12);
    border-color: rgba(0, 168, 232, 0.35);
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
}

.sidebar-panel {
    display: none;
}

.sidebar-panel.is-active {
    display: block;
}

.sidebar-search-wrap {
    position: relative;
    margin-bottom: 10px;
}

.sidebar-search-wrap .fa-magnifying-glass {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8125rem;
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.85;
}

.sidebar-search-input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    margin-bottom: 0;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.sidebar-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.15);
}

.sidebar-search-wrap:focus-within .fa-magnifying-glass {
    color: var(--accent);
    opacity: 1;
}

.sidebar-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin-bottom: 10px;
}

.sidebar-form-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.sidebar-input,
.sidebar-textarea {
    width: 100%;
    padding: 9px 11px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8125rem;
}

.sidebar-textarea {
    resize: vertical;
    min-height: 56px;
}

.sidebar-input:focus,
.sidebar-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.sidebar-form .btn {
    margin-top: 4px;
}

.sidebar-list {
    list-style: none;
    max-height: min(220px, 35vh);
    overflow-y: auto;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-elevated);
}

.sidebar-list--offers {
    max-height: min(400px, 55vh);
}

.sidebar-list li {
    padding: 10px 12px;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}

.sidebar-list li:last-child {
    border-bottom: none;
}

.sidebar-empty {
    cursor: default !important;
    color: var(--text-muted) !important;
    text-align: center;
    font-style: italic;
}

.sidebar-empty:hover {
    background: transparent !important;
}

.sidebar-list li:hover {
    background: rgba(0, 168, 232, 0.08);
}

.sidebar-list li.is-selected {
    background: rgba(0, 168, 232, 0.18);
    font-weight: 600;
}

.sidebar-list-item-title {
    display: block;
    color: var(--text);
    font-weight: 600;
}

.sidebar-list-item-meta {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.offer-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.offer-row-actions button {
    font-size: 0.6875rem;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    color: var(--primary);
}

.offer-row-actions button:hover {
    background: var(--surface-elevated);
}

.offer-row-actions button.danger {
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.35);
}

.sidebar-open-btn {
    flex-shrink: 0;
    min-width: 42px;
    min-height: 42px;
    padding: 0 12px 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.1rem;
    font-family: inherit;
    transition: box-shadow var(--transition), border-color var(--transition), background var(--transition);
}

.sidebar-open-btn:hover {
    border-color: var(--secondary);
    box-shadow: var(--shadow-sm);
    background: var(--surface-elevated);
}

.sidebar-open-btn[aria-expanded="true"] {
    border-color: var(--accent);
    background: rgba(0, 168, 232, 0.1);
}

.sidebar-open-label {
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

@media screen and (max-width: 380px) {
    .sidebar-open-label {
        display: none;
    }

    .sidebar-open-btn {
        padding: 0 10px;
    }
}

.btn-block {
    width: 100%;
}

.btn-danger-outline {
    background: transparent !important;
    color: var(--danger) !important;
    border: 1px solid rgba(220, 38, 38, 0.45) !important;
    box-shadow: none !important;
}

.btn-danger-outline:hover {
    background: rgba(220, 38, 38, 0.08) !important;
}

.app-shell {
    max-width: min(1320px, 100%);
    margin: 0 auto;
    padding: clamp(12px, 2.5vw, 28px);
    padding-bottom: calc(clamp(16px, 3vw, 32px) + env(safe-area-inset-bottom, 0px));
}

.container {
    max-width: 100%;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: clamp(18px, 4vw, 36px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.85);
}

body.is-pdf-snapshot .container {
    background: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* Geniş ekran: sağ (teklif) alanı daha geniş; sol panel her zaman hamburger ile */
@media screen and (min-width: 1100px) {
    .app-shell {
        max-width: min(1440px, 100%);
        padding-left: clamp(16px, 3vw, 32px);
        padding-right: clamp(16px, 3vw, 32px);
    }

    .container {
        padding: clamp(22px, 3.5vw, 42px);
    }

    .sidebar-list {
        max-height: min(280px, 32vh);
    }

    .sidebar-list--offers {
        max-height: min(480px, 52vh);
    }
}

/* ——— Header ——— */
.header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: clamp(12px, 3vw, 24px);
    margin-bottom: clamp(20px, 4vw, 32px);
    padding-bottom: clamp(16px, 3vw, 24px);
    border-bottom: 1px solid var(--border);
}

.title-section h1 {
    font-size: clamp(1.15rem, 4vw, 1.65rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--primary);
    text-transform: uppercase;
    text-align: left;
    line-height: 1.25;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.header-title-icon {
    font-size: 1.05rem;
    opacity: 0.88;
    color: var(--secondary);
}

.logo-section {
    justify-self: end;
}

.logo-section img {
    max-height: clamp(44px, 11vw, 72px);
    max-width: min(280px, 62vw);
    width: auto;
    height: auto;
    object-fit: contain;
}

/* ——— Session ——— */
.session-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: nowrap;
    margin: -8px 0 16px;
    padding: 10px 14px;
    background: var(--surface-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.session-bar-text {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    flex: 1;
    text-align: center;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.session-bar-icon {
    color: var(--success);
    font-size: 0.9rem;
    opacity: 0.9;
}

.auth-logout-btn {
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.auth-logout-btn:hover {
    border-color: var(--secondary);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* ——— Bölüm başlıkları ——— */
.section-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(0, 168, 232, 0.28);
    animation: fadeInUp 0.42s var(--ease-smooth) both;
}

.section-heading--compact {
    margin-top: 4px;
}

.section-heading-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(145deg, rgba(0, 168, 232, 0.18), rgba(15, 76, 117, 0.08));
    color: var(--primary);
    font-size: 0.95rem;
    flex-shrink: 0;
}

/* ——— Müşteri bilgileri ——— */
.customer-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: clamp(16px, 3vw, 28px);
    margin-bottom: clamp(20px, 4vw, 32px);
}

.left-info,
.right-info {
    min-width: 0;
}

.info-row {
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-row label {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--primary);
    letter-spacing: 0.02em;
}

.info-row .field-hint {
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0;
    text-transform: none;
}

.info-row input,
.info-row textarea {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
    min-width: 0;
}

.info-row input:focus,
.info-row textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.18);
}

.info-row input[readonly] {
    background: var(--surface-elevated);
    color: var(--text-muted);
    cursor: default;
}

.info-row textarea {
    min-height: 72px;
    resize: vertical;
}

/* ——— Tablo ——— */
.items-section {
    margin-bottom: clamp(20px, 4vw, 32px);
}

/* ——— OpenRouter / görsel ürün içe aktarma ——— */
body.is-pdf-snapshot .openrouter-panel {
    display: none !important;
}

.openrouter-panel {
    margin-bottom: clamp(24px, 4vw, 36px);
    padding: clamp(16px, 3vw, 22px);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: linear-gradient(165deg, rgba(0, 168, 232, 0.06) 0%, var(--surface) 48%);
    box-shadow: var(--shadow-sm);
}

.openrouter-panel > summary {
    list-style: none;
}

.openrouter-panel > summary::-webkit-details-marker {
    display: none;
}

.openrouter-panel-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    margin: 0;
    padding: 0 0 10px;
    border-bottom: 2px solid rgba(0, 168, 232, 0.28);
}

.openrouter-panel-summary-title.section-heading {
    margin: 0;
    padding: 0;
    border: none;
    flex: 1;
    min-width: 0;
    animation: none;
}

.openrouter-panel-chevron {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--primary);
    font-size: 0.75rem;
    transition: transform 0.22s var(--ease-smooth);
}

.openrouter-panel[open] .openrouter-panel-chevron {
    transform: rotate(180deg);
}

.openrouter-panel-body {
    padding-top: 16px;
}

.openrouter-hint .inline-code {
    font-family: ui-monospace, "Cascadia Code", monospace;
    font-size: 0.88em;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(15, 76, 117, 0.08);
    color: var(--primary);
}

.file-io-actions {
    margin-top: 0;
    margin-bottom: 6px;
}

.openrouter-hint {
    margin: 0 0 16px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.openrouter-grid {
    display: grid;
    gap: 16px 20px;
    grid-template-columns: 1fr;
}

@media (min-width: 720px) {
    .openrouter-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.openrouter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.openrouter-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
}

.openrouter-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    background: var(--surface);
}

.openrouter-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.15);
}

.openrouter-field-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.openrouter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.openrouter-sep {
    margin: 18px 0;
    border: none;
    border-top: 1px solid var(--border);
}

.openrouter-file-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.openrouter-file-name {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.openrouter-textarea {
    width: 100%;
    min-height: 180px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
    font-size: 0.8rem;
    line-height: 1.45;
    background: var(--surface);
    resize: vertical;
}

.openrouter-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.15);
}

.openrouter-status {
    margin: 12px 0 0;
    font-size: 0.8125rem;
    min-height: 1.25em;
    color: var(--text-muted);
}

.openrouter-status.is-error {
    color: #b91c1c;
}

.openrouter-status.is-ok {
    color: #0d9488;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* Ürün tablosu: yatay kaydırma için tut-sürükle */
.items-table-scroll {
    cursor: grab;
    scroll-behavior: auto;
}

.items-table-scroll.is-dragging {
    cursor: grabbing;
    user-select: none;
}

.table-responsive:focus-within {
    box-shadow: 0 0 0 2px rgba(0, 168, 232, 0.25);
}

table {
    width: 100%;
    min-width: 1360px;
    border-collapse: separate;
    border-spacing: 0;
}

/* Ürün adı / açıklama: dar sütunda kırpılmayı azalt */
#items-table th:nth-child(1),
#items-table td:nth-child(1) {
    width: 2.75rem;
    min-width: 2.75rem;
    max-width: 3.25rem;
    text-align: center;
}

#items-table th:nth-child(2),
#items-table td:nth-child(2) {
    min-width: 200px;
    width: 220px;
}

#items-table th:nth-child(3),
#items-table td:nth-child(3) {
    min-width: 260px;
    width: 280px;
}

#items-table .item-input.product-name {
    min-width: 180px;
}

#items-table .item-input.description {
    min-width: 240px;
}

#items-table th:nth-child(4),
#items-table td:nth-child(4) {
    min-width: 4.5rem;
}

#items-table th:nth-child(5),
#items-table td:nth-child(5) {
    min-width: 5.5rem;
}

#items-table th:nth-child(6),
#items-table td:nth-child(6),
#items-table th:nth-child(8),
#items-table td:nth-child(8),
#items-table th:nth-child(9),
#items-table td:nth-child(9),
#items-table th:nth-child(10),
#items-table td:nth-child(10) {
    min-width: 6.5rem;
}

#items-table th:nth-child(7),
#items-table td:nth-child(7) {
    min-width: 5rem;
}

#items-table th:nth-child(11),
#items-table td:nth-child(11) {
    min-width: 5rem;
}

#items-table th:nth-child(12),
#items-table td:nth-child(12) {
    min-width: 3.5rem;
    width: 3.75rem;
    text-align: center;
}

#items-table .total-kdvli-mirror {
    background: rgba(15, 76, 117, 0.06);
    cursor: default;
    color: var(--text);
}

#items-table .money-input,
#items-table .total-kdvli-mirror {
    text-align: right;
}

th,
td {
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 10px 12px;
    text-align: left;
    font-size: 0.8125rem;
    vertical-align: middle;
}

th:last-child,
td:last-child {
    border-right: none;
}

thead th {
    background: linear-gradient(180deg, var(--primary) 0%, #0a3a5c 100%);
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: var(--header-sticky-offset);
    z-index: 2;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

thead th:first-child {
    border-radius: var(--radius-md) 0 0 0;
}

thead th:last-child {
    border-radius: 0 var(--radius-md) 0 0;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: background 0.18s var(--ease-smooth);
}

tbody tr:nth-child(even) {
    background: rgba(15, 76, 117, 0.03);
}

tbody tr:hover {
    background: rgba(0, 168, 232, 0.06);
}

.item-input {
    width: 100%;
    min-width: 56px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    font-family: inherit;
    font-size: 0.8125rem;
}

.item-input:focus {
    border-color: var(--accent);
    outline: none;
    background: var(--surface);
    box-shadow: 0 0 0 2px rgba(0, 168, 232, 0.15);
}

.item-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8125rem;
    background: var(--surface);
    cursor: pointer;
}

.delete-btn {
    background: var(--danger);
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    transition: background var(--transition), transform 0.15s ease;
}

.delete-btn:hover {
    background: var(--danger-hover);
}

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

/* ——— Özet ——— */
.summary-section {
    width: min(100%, 26rem);
    margin-left: auto;
    margin-bottom: clamp(20px, 4vw, 32px);
    padding: clamp(16px, 3vw, 22px);
    background: linear-gradient(145deg, var(--surface-elevated), #fff);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9375rem;
}

.summary-row label {
    font-weight: 500;
    color: var(--text-muted);
}

.vat-details {
    background: rgba(15, 76, 117, 0.05);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin: 12px 0;
    border: 1px dashed var(--border);
}

.vat-detail {
    padding: 6px 0;
    font-size: 0.8125rem;
    color: var(--primary);
    border-bottom: 1px dotted var(--border);
}

.vat-detail:last-child {
    border-bottom: none;
}

.total-row {
    font-weight: 700;
    font-size: 1.05rem;
    border-bottom: none;
    background: linear-gradient(90deg, rgba(0, 168, 232, 0.12), transparent);
    margin: 8px -12px -12px;
    padding: 16px 12px !important;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    border-top: 2px solid var(--primary);
}

/* ——— Koşullar ——— */
.terms-section {
    margin-bottom: clamp(20px, 4vw, 32px);
}

.terms-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}

.terms-main-heading {
    color: var(--primary);
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    padding: 0;
    border: none;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.terms-heading-part {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.terms-main-heading i {
    font-size: 0.95rem;
    opacity: 0.88;
    color: var(--secondary);
}

.terms-title-sep {
    color: var(--text-muted);
    font-weight: 600;
    opacity: 0.65;
    user-select: none;
}

.sales-notes-block {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
}

.sales-notes-heading {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sales-notes-heading i {
    font-size: 0.9rem;
    opacity: 0.85;
    color: var(--secondary);
}

.sales-notes-display {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--text);
    white-space: pre-wrap;
    padding-left: 2px;
}

.terms-editor-label--notes {
    margin-top: 16px;
}

.terms-editor--notes {
    min-height: 100px;
}

.terms-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.terms-tool-btn {
    font-size: 0.8125rem !important;
    padding: 8px 12px !important;
    min-height: 40px !important;
}

.terms-list p,
#terms-list p {
    margin-bottom: 8px;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--text);
    padding-left: 4px;
}

.terms-editor-wrap {
    margin-top: 4px;
    padding: 14px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.terms-editor-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 10px;
    line-height: 1.45;
}

.terms-editor {
    width: 100%;
    min-height: 160px;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    resize: vertical;
    margin-bottom: 12px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.terms-editor:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.15);
}

.terms-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* ——— İmzalar ——— */
.signatures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: clamp(24px, 5vw, 40px);
    margin-top: clamp(28px, 5vw, 48px);
    padding-top: clamp(20px, 4vw, 28px);
    border-top: 1px solid var(--border);
}

.signature-block {
    text-align: center;
    padding: clamp(16px, 3vw, 24px);
    background: var(--surface-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.signature-block h3 {
    margin-bottom: 16px;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.signature-name,
.signature-email {
    margin-bottom: 10px;
    min-height: 28px;
    border-bottom: 1px dashed var(--border);
    padding: 8px 4px;
    font-size: 0.875rem;
}

.signature-image {
    height: 88px;
    border-bottom: 2px solid var(--border);
    margin-top: 20px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.6);
}

/* ——— Butonlar ——— */
.btn {
    background: linear-gradient(180deg, var(--primary-hover), var(--primary));
    color: #fff;
    border: none;
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.15s ease, box-shadow var(--transition), filter var(--transition);
    box-shadow: 0 2px 8px rgba(15, 76, 117, 0.25);
    white-space: nowrap;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    filter: brightness(1.05);
    box-shadow: 0 4px 14px rgba(15, 76, 117, 0.3);
}

.btn:active {
    transform: translateY(1px);
}

.btn i {
    font-size: 1rem;
    opacity: 0.95;
}

.btn-secondary {
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    border-color: var(--secondary);
    background: var(--surface-elevated);
    filter: none;
}

.btn-ghost {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
    box-shadow: none;
}

.btn-ghost:hover {
    background: var(--surface-elevated);
    filter: none;
}

#add-item {
    margin-top: 4px;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-top: clamp(12px, 3vw, 20px);
    padding: clamp(14px, 3vw, 20px);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
}

/* ——— Modal ——— */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    padding: 16px;
    background-color: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    position: relative;
    background: var(--surface);
    padding: clamp(20px, 4vw, 28px);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 520px;
    max-height: min(90dvh, 640px);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: modalOpen 0.32s var(--ease-smooth);
}

@keyframes modalOpen {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    padding: 8px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), background var(--transition);
}

.close:hover {
    color: var(--text);
    background: var(--surface-elevated);
}

.close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

#modal-title {
    font-size: 1.25rem;
    color: var(--primary);
    padding-right: 32px;
    margin-bottom: 8px;
}

/* ——— Giriş ekranı ——— */
.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(0, 168, 232, 0.2), transparent 60%),
        linear-gradient(160deg, #0a2540 0%, #0f4c75 45%, #1b6b9e 100%);
}

.auth-gate[hidden] {
    display: none !important;
}

.auth-gate-panel {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    padding: clamp(24px, 6vw, 36px);
    box-shadow: var(--shadow-lg);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.65);
    animation: authPanelIn 0.48s var(--ease-smooth) both;
}

.auth-gate-icon-wrap {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(0, 168, 232, 0.22), rgba(15, 76, 117, 0.1));
    border: 1px solid rgba(0, 168, 232, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.35rem;
    box-shadow: 0 8px 28px rgba(15, 76, 117, 0.12);
}

.auth-gate-logo {
    display: block;
    margin: 0 auto 18px;
    max-height: 72px;
    max-width: min(260px, 70vw);
    width: auto;
}

.auth-gate-heading {
    font-size: clamp(1.15rem, 4vw, 1.35rem);
    color: var(--primary);
    margin-bottom: 10px;
    font-weight: 700;
}

.auth-gate-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 22px;
    line-height: 1.5;
    text-align: left;
}

.auth-label {
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}

.auth-label .fa-fw {
    opacity: 0.85;
    color: var(--secondary);
}

.auth-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.2);
}

.auth-submit {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(180deg, var(--primary-hover), var(--primary));
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 16px rgba(15, 76, 117, 0.35);
    transition: filter var(--transition), transform 0.15s ease;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-submit i {
    font-size: 0.95rem;
    opacity: 0.95;
}

.auth-submit:hover {
    filter: brightness(1.06);
}

.auth-submit:active {
    transform: translateY(1px);
}

.auth-error {
    margin-top: 14px;
    font-size: 0.8125rem;
    color: var(--danger);
    text-align: left;
    font-weight: 500;
}

/* ——— Tablet / küçük masaüstü ——— */
@media screen and (max-width: 1024px) {
    .header {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .title-section h1 {
        text-align: center;
        justify-content: center;
    }

    .logo-section {
        justify-self: center;
    }

    table {
        min-width: 840px;
    }
}

@media screen and (max-width: 768px) {
    .header {
        gap: 16px;
    }

    thead th:first-child {
        border-radius: 0;
    }

    thead th:last-child {
        border-radius: 0;
    }

    .summary-section {
        width: 100%;
        margin-left: 0;
    }
}

/* ——— Mobil ——— */
@media screen and (max-width: 600px) {
    .action-buttons {
        position: sticky;
        bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        z-index: 50;
        margin-top: 16px;
        justify-content: stretch;
    }

    .action-buttons .btn {
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
        white-space: normal;
        text-align: center;
        font-size: 0.8125rem;
        padding: 10px 12px;
    }

    .session-bar {
        flex-wrap: wrap;
    }

    .session-bar-text {
        order: 3;
        flex: 1 1 100%;
        text-align: center;
    }

    .sidebar-open-btn {
        order: 1;
    }

    .auth-logout-btn {
        order: 2;
        margin-left: auto;
    }

    .delete-btn {
        min-height: 44px;
        min-width: 44px;
    }

    #add-item {
        width: 100%;
    }
}

@media screen and (max-width: 400px) {
    .action-buttons .btn {
        flex: 1 1 100%;
    }
}

/* ——— Yazdırma ——— */
@media print {
    :root {
        --header-sticky-offset: 0px;
    }

    .auth-gate,
    .session-bar,
    .action-buttons,
    .app-sidebar,
    .sidebar-backdrop,
    .sidebar-open-btn {
        display: none !important;
    }

    .layout-main {
        margin-left: 0 !important;
    }

    body {
        background: #fff;
    }

    .app-shell {
        padding: 0;
        max-width: none;
    }

    .container {
        background: #fff !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        box-shadow: none;
        border: none;
        border-radius: 0;
        padding: 12px;
    }

    .layout-main {
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
    }

    .table-responsive {
        overflow: visible;
        border: none;
        box-shadow: none;
    }

    table {
        min-width: 0;
    }

    thead th {
        position: static;
    }

    input,
    textarea,
    [contenteditable="true"] {
        border-color: transparent !important;
        box-shadow: none !important;
    }

    .item-input,
    .item-select {
        border: none !important;
        background-color: transparent !important;
    }

    .modal {
        display: none !important;
    }

    th,
    td {
        padding: 6px 8px;
    }

    .delete-btn {
        display: none;
    }

    .signatures {
        break-inside: avoid;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    body:not(.ui-ready) .layout-main {
        opacity: 1;
        transform: none;
    }

    body.ui-ready .layout-main {
        animation: none;
    }

    .auth-gate-panel {
        animation: none;
    }

    .modal-content {
        animation: none;
    }

    .section-heading {
        animation: none;
    }

    .app-sidebar {
        transition: none;
    }

    tbody tr {
        transition: none;
    }

    .sidebar-tab:active {
        transform: none;
    }
}
