:root {
  --red: #c8102e; --red-d: #a50d26; --ink: #1d2433; --muted: #6b7280; --line: #e3e6eb;
  --bg: #f4f5f7; --card: #fff; --ok: #0f7b4f; --err: #b42318; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--red); }
button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 12px; border-radius: 8px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: #c3c8d0; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-d); border-color: var(--red-d); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #eef0f3; }
.btn-sm { padding: 4px 8px; font-size: 12.5px; }
.btn-danger { color: var(--err); }
button:disabled { opacity: .55; cursor: default; }
input[type=text], input[type=url], input[type=password], input[type=email], select, textarea {
  font: inherit; width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus, .rte:focus { outline: 2px solid rgba(200,16,46,.25); border-color: var(--red); }
label.f { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }

.topbar { height: 54px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 18px; position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; }
.topbar .spacer { flex: 1; }
.topbar .user { color: var(--muted); font-size: 13px; }
.status { font-size: 12.5px; color: var(--muted); }
.status.ok { color: var(--ok); } .status.err { color: var(--err); }

/* liste */
.page { max-width: 980px; margin: 28px auto; padding: 0 16px; }
.page h1 { font-size: 22px; margin: 0 0 16px; display: flex; align-items: center; gap: 12px; }
.page h1 .spacer { flex: 1; }
.list { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .t { flex: 1; min-width: 0; }
.row .t a { font-weight: 600; color: var(--ink); text-decoration: none; }
.row .meta { color: var(--muted); font-size: 12.5px; }
.row form { margin: 0; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* login */
.login { max-width: 360px; margin: 12vh auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login h1 { font-size: 19px; margin: 0 0 18px; }
.login .err { color: var(--err); font-size: 13px; margin-top: 10px; }
.login button { width: 100%; justify-content: center; margin-top: 18px; }

/* editör */
.editor { display: grid; grid-template-columns: minmax(420px, 560px) 1fr; height: calc(100vh - 54px); }
.pane-left { overflow-y: auto; padding: 16px 18px 80px; border-right: 1px solid var(--line); background: var(--bg); }
.pane-right { display: flex; flex-direction: column; min-width: 0; background: #e9ebef; }
.box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.box h3 { margin: 0 0 4px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1.3fr 1fr 1.3fr; gap: 0 10px; }
.section { border-left: 4px solid #8a8f98; }
.section.sektor { border-left-color: var(--red); }
.sec-head { display: flex; gap: 8px; align-items: center; }
.sec-head input { font-weight: 700; }
.sec-head select { width: auto; }
.item { border: 1px solid var(--line); border-radius: 9px; margin-top: 12px; background: #fcfcfd; }
.item-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; cursor: pointer; user-select: none; }
.item-head .num { font-size: 12px; color: var(--muted); min-width: 22px; }
.item-head .ttl { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-head .chev { transition: transform .15s; color: var(--muted); }
.item.open .chev { transform: rotate(90deg); }
.item-body { display: none; padding: 0 12px 12px; border-top: 1px solid var(--line); }
.item.open .item-body { display: block; }
.rte-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; align-items: center; }
.rte-bar button { padding: 3px 9px; font-size: 13px; }
.rte-bar button.al { padding: 4px 6px; }
.rte-bar .rte-sel { width: auto; padding: 3px 4px; font-size: 13px; }
.rte { min-height: 140px; max-height: 360px; overflow-y: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; text-align: justify; }
.rte p { margin: 0 0 8px; }
.rte:empty::before { content: attr(data-ph); color: #9aa0aa; }
.counter { font-size: 11.5px; color: var(--muted); text-align: right; margin-top: 3px; }
.img-row { display: flex; gap: 10px; align-items: center; }
.img-row .thumb { width: 96px; height: 64px; border: 1px dashed #c5cad3; border-radius: 6px; background: #f3f4f6 center / cover no-repeat; flex: none; }
.src-box { background: #fff5f6; border: 1px solid #f3c9d0; border-radius: 8px; padding: 2px 10px 10px; margin-top: 12px; }
.add-row { display: flex; gap: 8px; margin-top: 12px; }
.hint { font-size: 12px; color: var(--muted); }

.pv-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 6px 11px; }
.seg button.on { background: var(--ink); color: #fff; }
.pv-wrap { flex: 1; overflow: auto; display: flex; justify-content: center; padding: 18px; }
.pv-frame { background: #fff; border: 0; width: 820px; height: 100%; min-height: 600px; box-shadow: 0 2px 14px rgba(0,0,0,.08); transition: width .2s; }
.pv-frame.mobile { width: 375px; border-radius: 22px; border: 10px solid #1f2430; }
.pv-bar .spacer { flex: 1; }

.drawer { position: fixed; inset: 0; background: rgba(15,18,25,.35); display: none; align-items: center; justify-content: center; z-index: 50; }
.drawer.show { display: flex; }
.dialog { background: #fff; border-radius: 14px; width: min(560px, 94vw); max-height: 88vh; overflow: auto; padding: 20px; }
.dialog h2 { margin: 0 0 10px; font-size: 18px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
table.hist { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 14px; }
table.hist td, table.hist th { border-top: 1px solid var(--line); padding: 6px 4px; text-align: left; vertical-align: top; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 9px; display: none; z-index: 60; max-width: 90vw; }
.toast.err { background: var(--err); }
.toast.show { display: block; }
.warn { background: #fff8e6; border: 1px solid #f5d27a; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; }

@media (max-width: 1000px) {
  .editor { grid-template-columns: 1fr; height: auto; }
  .pane-left { border-right: 0; }
  .pane-right { min-height: 80vh; }
}
