/* === Renk değişkenleri (açık tema) === */
:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e1e7ef;
    --border-strong: #cbd5e0;
    --text: #1a2540;
    --text-muted: #5a6885;
    --text-faint: #94a3b8;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff4ff;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --warn: #ca8a04;
    --warn-soft: #fefbe8;
    --success: #16a34a;
    --success-soft: #ecfdf5;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Giriş ekranı === */
.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 16px;
}

.login-card {
    width: min(92vw, 420px);
    background: var(--surface);
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0 0 18px;
    font-size: 19px;
    font-weight: 600;
    color: var(--text);
}

.login-card label {
    display: block;
    font-size: 13px;
    margin: 12px 0 6px;
    color: var(--text-muted);
    font-weight: 500;
}

.login-card input {
    width: 100%;
    padding: 11px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    outline: none;
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}

.login-card input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.login-card .btn {
    margin-top: 18px;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
}
.login-card .btn:hover { background: var(--primary-hover); }

.err {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #fecaca;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 13px;
}

.hint {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 6px;
}

.small {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
    line-height: 1.4;
}

/* Login alt bilgi — bağlantı izi */
.client-info {
    margin-top: 18px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 11px;
    line-height: 1.5;
}
.client-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.client-row + .client-row {
    border-top: 1px dashed var(--border);
    padding-top: 4px;
    margin-top: 4px;
}
.client-label {
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
    font-size: 10px;
    align-self: center;
}
.client-val {
    color: var(--text);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    text-align: right;
    word-break: break-word;
}

/* === Üst bar === */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar h1 {
    font-size: 16px;
    margin: 0;
    font-weight: 600;
    color: var(--text);
}
.topbar .user {
    font-size: 13px;
    color: var(--text-muted);
}
.topbar .user a { margin-left: 14px; }

/* === Sayfa düzeni === */
.container {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

.card h2 {
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

/* === Form alanları === */
.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
}

@media (max-width: 800px) {
    .grid-3 { grid-template-columns: 1fr; }
}

label {
    display: block;
    font-size: 13px;
    margin: 0 0 6px;
    color: var(--text-muted);
    font-weight: 500;
}
label .req { color: var(--danger); }

input[type=text], input[type=email], input[type=password], input[type=date] {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    outline: none;
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}
input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

/* === Cari arama (autocomplete) === */
.ac-wrap { position: relative; }

.ac-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    max-height: 260px;
    overflow-y: auto;
    z-index: 20;
    display: none;
    box-shadow: var(--shadow);
}
.ac-list.open { display: block; }

.ac-item {
    padding: 9px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.active { background: var(--primary-soft); }
.ac-item .code {
    color: var(--text-faint);
    font-size: 12px;
    margin-left: 6px;
}
.ac-empty, .ac-loading {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.ac-loading::before {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Quill editör override === */
.editor-wrap { display: flex; flex-direction: column; }

.ql-toolbar.ql-snow {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--surface-2);
}
.ql-container.ql-snow {
    border: 1px solid var(--border-strong);
    border-top: 0;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    min-height: 140px;
    max-height: 60vh;
    overflow-y: auto;
}
.ql-editor { min-height: 140px; }
.ql-editor.ql-blank::before {
    color: var(--text-faint);
    font-style: normal;
}

.editor-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 12px;
}

/* === Sipariş kalemleri tablosu === */
.info-banner {
    background: var(--primary-soft);
    border: 1px solid #c7d8ff;
    color: var(--text);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 12px;
    line-height: 1.5;
}
.info-banner b { color: var(--primary-hover); }

.paste-zone {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow: hidden;
}
.paste-zone:focus-within { border-color: var(--primary); }

table.items {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
}
table.items col.col-flex { width: auto; }
table.items th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
table.items td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
table.items tr:last-child td { border-bottom: 0; }
table.items td.idx { color: var(--text-faint); text-align: center; }
table.items td.ok { text-align: center; }
table.items td.act { text-align: center; }
table.items td[contenteditable] { outline: none; }
table.items td[contenteditable]:focus {
    background: var(--primary-soft);
    white-space: normal;
    overflow: visible;
}
table.items td.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty-row td {
    text-align: center;
    color: var(--text-faint);
    padding: 30px 12px;
    font-size: 13px;
    background: var(--surface);
}

.ok-icon {
    font-size: 16px;
    cursor: help;
    user-select: none;
    display: inline-block;
    line-height: 1;
}
.ok-ok { color: var(--success); }
.ok-warn { color: var(--warn); }
.ok-err { color: var(--danger); }
.ok-pending { color: var(--text-faint); }
.ok-divided { color: #b45309; }

/* Dilimli HM bobin etiketi (Stok Kodu yanı + Toplam chip) */
.ym2-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 11px;
    color: #92400e;
    background: #FCE4D6;
    border: 1px solid #fbd5b5;
    border-radius: 9px;
    font-weight: 600;
    vertical-align: middle;
}
.totals .chip.chip-divided {
    background: #FCE4D6;
    border-color: #fbd5b5;
}
.totals .chip.chip-divided .label,
.totals .chip.chip-divided .val { color: #92400e; }

/* === Butonlar === */
.btn {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, border-color .15s, color .15s;
    background: var(--surface);
    color: var(--text);
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 600;
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:disabled {
    background: var(--surface-2);
    color: var(--text-faint);
    border-color: var(--border);
    cursor: not-allowed;
}
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border-strong);
}
.btn-ghost:hover {
    background: var(--surface-2);
    color: var(--text);
}

.del-btn {
    background: transparent;
    border: 0;
    color: var(--danger);
    cursor: pointer;
    font-size: 18px;
    padding: 2px 8px;
    line-height: 1;
    border-radius: 6px;
}
.del-btn:hover { background: var(--danger-soft); }

.actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.totals {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}
.totals .chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    line-height: 1;
}
.totals .chip .label {
    color: var(--text-faint);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 500;
}
.totals .chip .val {
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}
.totals .chip .unit {
    color: var(--text-faint);
    font-size: 11px;
    margin-left: 1px;
}
.totals .chip.primary {
    background: var(--primary-soft);
    border-color: #c7d8ff;
}
.totals .chip.primary .val { color: var(--primary-hover); }

/* === Hata vurguları (input + hücre) === */
input.input-bad,
input.input-bad:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

table.items td.bad-numeric {
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 600;
    cursor: help;
}

/* === Başarı sayfası === */
.saved-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.saved-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 36px 40px;
    box-shadow: var(--shadow);
    width: min(92vw, 480px);
    text-align: center;
}
.saved-check {
    margin-bottom: 14px;
}
.saved-card h1 {
    font-size: 20px;
    margin: 0 0 18px;
    color: var(--success);
    font-weight: 600;
}
.saved-meta {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.saved-meta > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.saved-meta .meta-label {
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 500;
}
.saved-meta .meta-val {
    font-size: 14px;
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.countdown {
    position: relative;
    display: inline-grid;
    place-items: center;
    margin-top: 4px;
}
.countdown-svg {
    transform: rotate(-90deg);
}
.countdown-track {
    fill: none;
    stroke: var(--border);
    stroke-width: 6;
}
.countdown-bar {
    fill: none;
    stroke: var(--primary);
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 100ms linear;
}
.countdown-num {
    position: absolute;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.countdown-label {
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-muted);
}

/* === Gönder butonu alt çubuğu === */
.submit-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 22px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.validation-msg {
    font-size: 13px;
    color: var(--text-muted);
}
.validation-msg.bad { color: var(--danger); }
.validation-msg.good { color: var(--success); }

.submit-btn {
    background: var(--primary);
    color: #fff;
    border: 0;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.submit-btn:hover { background: var(--primary-hover); }
.submit-btn:disabled {
    background: var(--border-strong);
    color: var(--surface);
    cursor: not-allowed;
}
