/* Giriş, bayi paneli ve kullanıcı menüsü */
:root {
    --auth-accent: #22a1b8;
    --auth-accent-dark: #17798c;
    --auth-danger: #d6453d;
    --auth-bg: #eef2f4;
    --auth-text: #2b3a42;
    --auth-muted: #6b7c85;
    --auth-border: #d5dee3;
}

body.auth-page {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--auth-bg);
    color: var(--auth-text);
}

/* --- Giriş --- */
.login-wrap {
    box-sizing: border-box;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 14px;
    padding: 32px 28px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.login-card .brand { text-align: center; font-size: 40px; line-height: 1; }
.login-card h1 { margin: 10px 0 4px; text-align: center; font-size: 20px; }
.login-card .sub { margin: 0 0 22px; text-align: center; color: var(--auth-muted); font-size: 13px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 600; }
.field input {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 12px;
    border: 1px solid var(--auth-border);
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
    color: var(--auth-text);
}
.field input:focus { outline: 2px solid var(--auth-accent); outline-offset: 0; border-color: var(--auth-accent); }

.btn-auth {
    width: 100%;
    padding: 12px;
    border: 0;
    border-radius: 8px;
    background: var(--auth-accent);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}
.btn-auth:hover { background: var(--auth-accent-dark); }
.btn-auth:disabled { opacity: 0.6; cursor: wait; }

.auth-error {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fdecea;
    color: #a52a22;
    font-size: 13px;
    display: none;
}
.auth-error.show { display: block; }

/* --- Bayi paneli --- */
.admin-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 20px;
    background: #fff;
    border-bottom: 1px solid var(--auth-border);
}
.admin-top h1 { margin: 0; font-size: 18px; }
.admin-top .who { color: var(--auth-muted); font-size: 13px; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.admin-main { max-width: 1100px; margin: 20px auto; padding: 0 16px 40px; }

.btn-sm {
    padding: 8px 14px;
    border: 1px solid var(--auth-border);
    border-radius: 8px;
    background: #fff;
    color: var(--auth-text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.btn-sm:hover { border-color: var(--auth-accent); color: var(--auth-accent-dark); }
.btn-sm.primary { background: var(--auth-accent); border-color: var(--auth-accent); color: #fff; }
.btn-sm.primary:hover { background: var(--auth-accent-dark); color: #fff; }
.btn-sm.danger { color: var(--auth-danger); }
.btn-sm.danger:hover { border-color: var(--auth-danger); color: var(--auth-danger); }

.dealer-table-wrap { background: #fff; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.06); overflow-x: auto; }
table.dealers { width: 100%; border-collapse: collapse; font-size: 14px; }
table.dealers th, table.dealers td { padding: 12px 14px; text-align: left; border-bottom: 1px solid #edf1f3; vertical-align: middle; }
table.dealers th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--auth-muted); background: #f8fafb; }
table.dealers tr:last-child td { border-bottom: 0; }
table.dealers tr.inactive td { opacity: 0.55; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.on { background: #e3f6ea; color: #1c7a3c; }
.badge.off { background: #f1f1f1; color: #777; }
.badge.admin { background: #e5f2fb; color: #17608a; }

.admin-empty { padding: 30px; text-align: center; color: var(--auth-muted); }
.summary-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.summary-card { flex: 1 1 150px; background: #fff; border-radius: 12px; padding: 14px 16px; box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.summary-card strong { display: block; font-size: 24px; }
.summary-card span { font-size: 12px; color: var(--auth-muted); }

/* --- Pencere --- */
.dlg-back {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    display: none; align-items: center; justify-content: center; z-index: 3000; padding: 16px;
}
.dlg-back.show { display: flex; }
.dlg {
    width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 24px;
    max-height: 92vh; overflow-y: auto;
}
.dlg h2 { margin: 0 0 16px; font-size: 18px; }
.dlg .btn-row { display: flex; gap: 8px; margin-top: 18px; }
.dlg .btn-row .btn-sm { flex: 1; text-align: center; padding: 11px; }
.pw-row { display: flex; gap: 8px; }
.pw-row input { flex: 1; }
.dlg .hint { font-size: 12px; color: var(--auth-muted); margin: -6px 0 12px; }
.dlg .result-box {
    padding: 12px; background: #eef8fa; border-left: 3px solid var(--auth-accent);
    border-radius: 6px; font-size: 14px; word-break: break-all; margin-top: 12px;
}

/* --- Editördeki kullanıcı menüsü --- */
.user-box { position: relative; display: inline-block; margin-left: 6px; }
.user-btn {
    padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 6px; background: #fff;
    font-size: 13px; cursor: pointer; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-btn:hover { border-color: var(--auth-accent); }
.user-menu {
    position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; background: #fff;
    border: 1px solid var(--auth-border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    padding: 6px; display: none; z-index: 4000;
}
.user-menu.open { display: block; }
.user-menu a, .user-menu button {
    display: block; width: 100%; box-sizing: border-box; text-align: left; padding: 9px 12px; border: 0; background: none;
    font-size: 13px; color: var(--auth-text); cursor: pointer; border-radius: 6px; text-decoration: none;
}
.user-menu a:hover, .user-menu button:hover { background: #eef8fa; }
.user-menu .who { padding: 8px 12px; font-size: 12px; color: var(--auth-muted); border-bottom: 1px solid #edf1f3; margin-bottom: 4px; }

@media (max-width: 640px) {
    table.dealers th:nth-child(4), table.dealers td:nth-child(4),
    table.dealers th:nth-child(6), table.dealers td:nth-child(6) { display: none; }
}

/* --- Sekmeler, süzgeçler, grafikler --- */
.admin-tabs { display: flex; gap: 4px; padding: 0 20px; background: #fff; border-bottom: 1px solid var(--auth-border); overflow-x: auto; }
.admin-tabs .tab {
    padding: 12px 16px; border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer;
    font-size: 14px; font-weight: 600; color: var(--auth-muted); white-space: nowrap;
}
.admin-tabs .tab:hover { color: var(--auth-text); }
.admin-tabs .tab.active { color: var(--auth-accent-dark); border-bottom-color: var(--auth-accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.pane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pane-head .summary-row { flex: 1; margin-bottom: 16px; }
.section-title { margin: 22px 0 10px; font-size: 15px; }

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filter-bar select, .filter-bar input {
    padding: 8px 10px; border: 1px solid var(--auth-border); border-radius: 8px; font-size: 13px; background: #fff; color: var(--auth-text);
}
.filter-bar input[type="search"] { flex: 1 1 180px; min-width: 150px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--auth-muted); }
.table-foot { margin-top: 8px; font-size: 13px; color: var(--auth-muted); }
td small { color: var(--auth-muted); }
tr.warn-row td { background: #fff6f4; }

.badge.st-new { background: #e5f2fb; color: #17608a; }
.badge.st-preparing { background: #fff2d6; color: #8a5a00; }
.badge.st-printed { background: #ece6fb; color: #5a3ea8; }
.badge.st-delivered { background: #e3f6ea; color: #1c7a3c; }
.badge.st-cancelled { background: #f1f1f1; color: #777; }
.badge.pay-unpaid { background: #fdecea; color: #a52a22; }
.badge.pay-partial { background: #fff2d6; color: #8a5a00; }
.badge.pay-paid { background: #e3f6ea; color: #1c7a3c; }

.meter { width: 110px; height: 8px; border-radius: 99px; background: #e8eef1; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--auth-accent); }
.meter.warn i { background: #e0a000; }
.meter.full i { background: var(--auth-danger); }
.quota-cell small { display: block; margin-top: 3px; }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.chart-card { background: #fff; border-radius: 12px; padding: 14px 16px; box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.chart-card h3 { margin: 0 0 8px; font-size: 14px; }
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-card .bar { fill: var(--auth-accent); }
.chart-card .bar:hover { fill: var(--auth-accent-dark); }
.chart-card .axis { stroke: var(--auth-border); stroke-width: 1; }
.chart-card .ax { font-size: 11px; fill: var(--auth-muted); }

.summary-card.bad { border-left: 4px solid var(--auth-danger); }
.summary-card.good { border-left: 4px solid #2e9d57; }
.sys-notes { padding: 14px 18px; }
.sys-notes ul { margin: 0; padding-left: 18px; line-height: 1.9; font-size: 14px; }
.sys-notes code { background: #f1f4f6; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

.news-form { background: #fff; border-radius: 12px; padding: 18px 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.06); max-width: 640px; }
.news-form h3 { margin: 0 0 12px; font-size: 15px; }

.dlg-wide { max-width: 560px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 10px; margin-top: 4px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 400; cursor: pointer; }
.field span + .check-grid { margin-top: 6px; }
@media (max-width: 520px) { .two-col { grid-template-columns: 1fr; } }

/* --- Kota göstergesi, özet, duyurular (editör) --- */
.quota-box { padding: 8px 12px 10px; border-bottom: 1px solid #edf1f3; margin-bottom: 4px; }
.quota-box .quota-line { font-size: 12px; color: var(--auth-muted); margin-bottom: 5px; }
.quota-box .meter { width: 100%; }
.user-btn.quota-warn { border-color: #e0a000; }
.meter.wide { width: 100%; height: 10px; margin: 6px 0 12px; }
.sum-line { margin: 8px 0; font-size: 14px; }
.sum-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.sum-table th, .sum-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #edf1f3; }
.sum-table th { font-size: 11px; text-transform: uppercase; color: var(--auth-muted); }

.news-toasts { position: fixed; right: 14px; bottom: 14px; z-index: 3500; display: flex; flex-direction: column; gap: 8px; max-width: min(340px, calc(100vw - 28px)); }
.news-toast {
    position: relative; background: #fff; border: 1px solid var(--auth-border); border-left: 4px solid var(--auth-accent);
    border-radius: 10px; padding: 10px 34px 10px 12px; box-shadow: 0 6px 20px rgba(0,0,0,0.18); font-size: 13px;
}
.news-toast.warn { border-left-color: #e0a000; background: #fffaf0; }
.news-toast .news-text { margin-top: 4px; color: var(--auth-muted); line-height: 1.4; }
.news-toast .news-x { position: absolute; top: 6px; right: 6px; border: 0; background: none; cursor: pointer; font-size: 13px; color: #888; padding: 4px 6px; border-radius: 6px; }
.news-toast .news-x:hover { background: #f0f0f0; }

/* --- Hızlı sipariş: isim listesi araçları --- */
.qo-count-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.qo-count-row .qo-count { margin: 0; }
.qo-count-warn { color: #b26a00; font-weight: 600; }
.qo-mini-btn { padding: 4px 10px; border: 1px solid #cfd8dc; border-radius: 99px; background: #fff; font-size: 12px; cursor: pointer; color: #355; }
.qo-mini-btn:hover { border-color: var(--auth-accent); color: var(--auth-accent-dark); }

/* --- Sipariş listesi: teslim uyarısı --- */
.order-due { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.order-due.due-late { background: #fdecea; color: #a52a22; }
.order-due.due-today { background: #ffe9d6; color: #a04a00; }
.order-due.due-soon { background: #fff2d6; color: #8a5a00; }
.order-due-count { margin-left: 8px; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; background: #fdecea; color: #a52a22; }

.cred-text {
    width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--auth-border); border-radius: 8px;
    font-family: ui-monospace, Consolas, monospace; font-size: 13px; line-height: 1.5; resize: none; background: #f8fafb; color: var(--auth-text);
}

/* --- Üst bar hızlı araçlar ve metin çubuğu --- */
.icon-btn#rotLeftBtn, .icon-btn#rotRightBtn, .icon-btn#rot180Btn { font-size: 12px; font-weight: 700; width: auto; min-width: 40px; padding: 0 8px; }
.quick-bg { display: inline-flex; align-items: center; gap: 5px; }
.quick-bg-label { font-size: 12px; color: #666; }
.quick-bg-input { width: 30px; height: 30px; padding: 0; border: 1px solid #ccc; border-radius: 6px; background: none; cursor: pointer; }
.quick-sw { width: 20px; height: 20px; border-radius: 50%; border: 1px solid #bbb; cursor: pointer; padding: 0; }
.quick-sw:hover { transform: scale(1.15); border-color: #22a1b8; }

.text-quick-bar {
    position: fixed; z-index: 1500; align-items: center; gap: 6px; padding: 6px 8px;
    background: #fff; border: 1px solid #cfd8dc; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,0.22);
}
.text-quick-bar input[type="color"] { width: 30px; height: 30px; padding: 0; border: 1px solid #ccc; border-radius: 6px; background: none; cursor: pointer; }
.text-quick-bar select { max-width: 130px; height: 30px; border: 1px solid #ccc; border-radius: 6px; font-size: 13px; }
.text-quick-bar input[type="number"] { width: 52px; height: 28px; border: 1px solid #ccc; border-radius: 6px; text-align: center; font-size: 13px; }
.text-quick-bar button { height: 30px; min-width: 30px; border: 1px solid #ccc; border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; }
.text-quick-bar button:hover { border-color: #22a1b8; }
.text-quick-bar button.on { background: #22a1b8; color: #fff; border-color: #22a1b8; }

.bg-picker { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; font-size: 13px; color: #444; }
.bg-swatch { width: 22px; height: 22px; border-radius: 5px; border: 1px solid #bbb; flex-shrink: 0; }
.bg-hint { font-size: 12px; color: #777; margin-bottom: 8px; }
#bgOriginal { cursor: crosshair; }


/* --- Yönetim: hazır şablonlar --- */
.tpl-new { padding: 16px 18px; margin-bottom: 16px; }
.tpl-new h3 { margin: 0 0 6px; font-size: 15px; }
.tpl-hint { margin: 0 0 12px; font-size: 13px; color: #666; line-height: 1.5; }
.tpl-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tpl-form select, .tpl-form input[type="text"] { padding: 8px 10px; border: 1px solid #d9d9d9; border-radius: 8px; font: inherit; }
.tpl-form input[type="text"] { width: 170px; text-transform: uppercase; }
.tpl-form input[type="text"]::placeholder { text-transform: none; }
.tpl-ok { margin-top: 8px; font-size: 13px; color: #2e7d32; }
.tpl-count { font-size: 13px; color: #777; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tpl-card { background: #fff; border: 1px solid #e6e6e6; border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; text-align: center; }
.tpl-card.hidden-tpl { background: #f7f7f7; }
.tpl-card.hidden-tpl img { opacity: 0.4; }
.tpl-card img { width: 100%; height: 150px; object-fit: contain; background: #fafafa; border-radius: 6px; }
.tpl-card .tpl-code { font-weight: 700; letter-spacing: 0.5px; }
.tpl-card .tpl-meta { font-size: 12px; color: #777; }
.tpl-card .row-actions { justify-content: center; }
