:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --text: #1c2430;
    --muted: #667085;
    --border: #dde1e7;
    --accent: #2456d6;
    --accent-dark: #1b43ab;
    --danger: #c9302c;
    --ok-bg: #e6f4ea; --ok-text: #1e6b34;
    --err-bg: #fdecea; --err-text: #a12622;
    --warn-bg: #fff4e0; --warn-text: #8a5a00;
    --radius: 8px;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

.topbar { display: flex; align-items: center; gap: 1.5rem; background: #17202e; color: #fff; padding: 0 1.25rem; height: 52px; position: sticky; top: 0; z-index: 30; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 1.05rem; }
.topbar nav { display: flex; gap: .25rem; flex: 1; }
.topbar nav a { color: #c8d0dc; padding: .45rem .8rem; border-radius: 6px; }
.topbar nav a:hover { background: #26324a; text-decoration: none; color: #fff; }
.topbar nav a.active { background: #2b3a57; color: #fff; }
.userbox { display: flex; align-items: center; gap: .6rem; }
.userbox a { color: #c8d0dc; }
.userbox form { margin: 0; }

.wrap { padding: 1.25rem; max-width: 1600px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card.narrow { max-width: 520px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
.stat .n { font-size: 1.6rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; }

.flash { padding: .65rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); border-color: #c5e3cd; }
.flash-err { background: var(--err-bg); color: var(--err-text); border-color: #f3c6c2; }
.flash-warn { background: var(--warn-bg); color: var(--warn-text); border-color: #f0dcb0; }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .75rem; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=file], select, textarea {
    display: block; width: 100%; margin-top: .25rem; padding: .45rem .6rem; font: inherit; color: var(--text);
    background: #fff; border: 1px solid var(--border); border-radius: 6px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b6c8f5; border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
input[type=checkbox] { width: auto; margin: 0 .4rem 0 0; }
label.check { display: flex; align-items: center; color: var(--text); font-size: .95rem; }

.btn { display: inline-block; padding: .45rem .95rem; font: inherit; font-size: .9rem; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--danger); border-color: #e7b4b2; }
.btn-danger:hover { background: var(--err-bg); }
.btn-ghost { background: transparent; border-color: #3b4a66; color: #c8d0dc; }
.btn-ghost:hover { background: #26324a; }
.btn-sm { padding: .25rem .6rem; font-size: .82rem; }
.btn-block { display: block; width: 100%; }

.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; }
.inline-form label { margin: 0; }
.inline-form input, .inline-form select { margin-top: .25rem; }

.login-box { max-width: 380px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.75rem; }
.login-box h1 { margin-bottom: .25rem; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; background: #eef1f6; color: #3a4658; font-size: .78rem; }
.badge-aktif { background: #e3f4e8; color: #1e6b34; }
.badge-2li_box { background: #e7eefc; color: #1b43ab; }
.badge-son_stok { background: #fff1d6; color: #8a5a00; }
.badge-kalkmis { background: #f1f1f1; color: #666; }
.badge-yeni { background: #fbe6f3; color: #9a1f6a; }
.badge-manuel { background: #efe6fb; color: #5a2ea6; }

/* Ürün listesi */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: .75rem; }
.toolbar label { margin: 0; }
.toolbar .grow { flex: 1; min-width: 220px; }
.toolbar select, .toolbar input { margin-top: .2rem; }
.tablewrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 250px); }
.ptable { border-collapse: separate; border-spacing: 0; font-size: .85rem; min-width: 100%; }
.ptable th, .ptable td { padding: .4rem .55rem; border-bottom: 1px solid var(--border); border-right: 1px solid #f0f2f5; white-space: nowrap; text-align: left; vertical-align: middle; }
.ptable thead th { position: sticky; top: 0; background: #f8f9fb; z-index: 2; font-size: .75rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
.ptable thead tr.filters th { top: 33px; background: #fff; padding: .25rem .35rem; z-index: 2; }
.ptable thead tr.filters input { margin: 0; padding: .2rem .35rem; font-size: .8rem; min-width: 70px; }
.ptable th a { color: inherit; }
.ptable tbody tr:hover td { background: #f7f9fe; }
.ptable td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ptable td.wide { white-space: normal; min-width: 240px; max-width: 360px; }
.ptable .thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); background: #f3f4f6; display: block; }
.ptable .thumb-empty { width: 44px; height: 44px; border: 1px dashed var(--border); border-radius: 4px; }
.ptable .is-hidden { display: none; }
.ptable td.cm { box-shadow: inset 0 -2px 0 #b79be6; }
.colpanel { position: relative; }
.colpanel .panel { display: none; position: absolute; right: 0; top: 110%; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; z-index: 40; width: 260px; max-height: 60vh; overflow: auto; box-shadow: 0 6px 24px rgba(0,0,0,.12); }
.colpanel .panel.open { display: block; }
.colpanel .panel label { margin: .15rem 0; display: flex; align-items: center; color: var(--text); font-size: .88rem; }
.bulkbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; background: #eef3ff; border: 1px solid #cddafb; border-radius: var(--radius); padding: .5rem .75rem; margin-bottom: .75rem; }
.bulkbar select { width: auto; margin: 0; }
.pager { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin: .75rem 0; }
.pager a, .pager span { padding: .3rem .65rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: .85rem; color: var(--text); }
.pager a:hover { background: #f0f2f5; text-decoration: none; }
.pager .cur { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager .gap { border: none; background: none; }

/* Ürün formu */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-group-title { grid-column: 1 / -1; margin: .75rem 0 .5rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; background: #efe6fb; color: #5a2ea6; border-radius: 999px; padding: .1rem .6rem; font-size: .8rem; }
.chip input { margin: 0 .35rem 0 0; }
.img-grid { display: flex; flex-wrap: wrap; gap: 1rem; }
.img-item { width: 190px; border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem; background: #fff; }
.img-item img { width: 100%; height: 160px; object-fit: contain; background: #f3f4f6; border-radius: 4px; display: block; }
.img-item .actions { display: flex; gap: .4rem; margin-top: .4rem; flex-wrap: wrap; }
.img-item.main { border-color: var(--accent); box-shadow: 0 0 0 2px #cddafb; }
.actions-row { display: flex; gap: .6rem; align-items: center; margin-top: 1rem; }
.err-list { margin: 0 0 1rem; padding-left: 1.2rem; color: var(--err-text); }

/* Import */
.status { font-weight: 600; }
.status-tamam { color: var(--ok-text); }
.status-hata { color: var(--err-text); }
.status-calisiyor, .status-bekliyor { color: var(--warn-text); }
pre.msg { white-space: pre-wrap; margin: 0; font-family: inherit; }
.tree-indent { display: inline-block; color: var(--muted); }

@media (max-width: 700px) {
    .topbar { flex-wrap: wrap; height: auto; padding: .5rem 1rem; gap: .5rem 1rem; }
    .topbar nav { order: 3; width: 100%; overflow-x: auto; }
    .wrap { padding: .75rem; }
    .tablewrap { max-height: none; }
}
