/* NemraPOS Kernel — yönetim paneli. Renk paleti NemraONE client'ı ile aynı (client/src/index.css):
   derin indigo/lacivert zemin + zümrüt vurgu, düz zemin (glow yok). Harici font/CDN yok (sunucu internetsiz çalışabilir). */
:root {
  --bg: #12142a;
  --surface: #191d3c;
  --surface-2: #1f2447;
  --surface-3: #282e57;
  --border: #2b3155;
  --border-strong: #363c68;
  --text: #e9eaf6;
  --muted: #9aa1c7;
  --faint: #6c739c;
  --accent: #10b981;
  --accent-hover: #4ade80;
  --accent-ink: #06281d;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.13);
  --info: #818cf8;
  --info-soft: rgba(129, 140, 248, 0.14);
  --scroll-thumb: #2b3155;
  --scroll-thumb-hover: #363c68;
  --radius: 10px;
  --shadow: 0 8px 28px rgba(5, 6, 20, 0.45);
  color-scheme: dark;
}
:root[data-theme='light'] {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #eef0f9;
  --surface-3: #e4e7f4;
  --border: #dfe2f0;
  --border-strong: #c9cde3;
  --text: #1b1e36;
  --muted: #676c8f;
  --faint: #8f94b3;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-ink: #06281d;
  --accent-soft: rgba(16, 185, 129, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.09);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.1);
  --info: #4f46e5;
  --info-soft: rgba(79, 70, 229, 0.09);
  --scroll-thumb: #d5d8ea;
  --scroll-thumb-hover: #b9bdd9;
  --shadow: 0 8px 24px rgba(27, 30, 54, 0.14);
  color-scheme: light;
}

/* İnce scrollbar (NemraONE client'taki gibi): yuvarlak thumb, şeffaf kanal. Firefox için
   scrollbar-width/color, Chromium/Edge için ::-webkit-scrollbar. */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0 0 10px; }
small, .muted { color: var(--muted); }
.mono { font-family: Consolas, 'Cascadia Mono', monospace; font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.icon { flex: none; vertical-align: -0.2em; }

/* ── Kabuk ─────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
}
/* Logo (.brand) ve alt bilgi sabit; yalnızca menü listesi kayar. */
.sidebar-nav {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 4px;
  margin: 0 -6px; padding: 0 6px; /* scrollbar kenara yaslansın, bağlantılar hizada kalsın */
  scrollbar-gutter: stable;
}
.sidebar-nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: transparent; border-width: 2px; }
.sidebar:hover .sidebar-nav::-webkit-scrollbar-thumb { background: var(--scroll-thumb); }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }
.brand { flex: none; display: flex; align-items: center; gap: 8px; padding: 4px 10px 16px; margin-bottom: 2px; border-bottom: 1px solid var(--border); font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.brand-nemra { background: linear-gradient(135deg, #10b981, #4ade80); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-chip { background: linear-gradient(135deg, #10b981, #4ade80); color: var(--accent-ink); font-size: 12px; padding: 2px 8px; border-radius: 6px; font-weight: 800; letter-spacing: 0.04em; }
.brand-sub { color: var(--faint); font-size: 11px; font-weight: 500; margin-left: 2px; }
.nav-section { margin: 14px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--muted); cursor: pointer; transition: background 0.12s, color 0.12s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.sidebar-foot { flex: none; padding: 12px 10px 0; margin-top: 8px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hamburger { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-chip .role { color: var(--faint); font-size: 12px; }
.content { padding: 24px 28px 48px; width: 100%; max-width: 1360px; }

/* ── Bileşenler ────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .grid > * + * { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--faint); font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 550; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.btn:hover { background: var(--surface-3); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: var(--danger-soft); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 22%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.icon-only { padding: 7px; }
form.inline { display: inline; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent-hover); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.ok { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dot.danger { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }

/* Tablo */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.toolbar .search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.toolbar .search input { padding-left: 34px; }
.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); }

/* Form */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label, .field > .label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .help { font-size: 12px; color: var(--faint); }
input[type='text'], input[type='password'], input[type='number'], input[type='date'], input[type='search'], input[type='email'], select, textarea {
  width: 100%; padding: 8px 11px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 8px; font: inherit; outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly] { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* Anahtar (switch) */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--accent-ink); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch .text { font-weight: 550; }

/* Uyarı kutuları */
.notice { padding: 11px 14px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface-2); margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.notice.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.notice.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 40%, transparent); }
.notice.ok { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.keybox { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px dashed var(--border-strong); border-radius: 8px; padding: 8px 12px; word-break: break-all; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist .state { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--faint); flex: none; }
.checklist li.done .state { background: var(--accent); color: var(--accent-ink); }
.checklist li.done .title { color: var(--muted); }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

/* Hızlı ekran düzenleyici */
.qs-group { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; }
.qs-group-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.qs-buttons { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
.qs-button { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-2); border-left: 5px solid var(--qs-color, var(--accent)); }
.qs-search-results { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; margin-top: 8px; }
.qs-search-results button { display: flex; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 7px 12px; background: none; border: 0; border-bottom: 1px solid var(--border); color: var(--text); font: inherit; cursor: pointer; }
.qs-search-results button:hover { background: var(--accent-soft); }

/* Diyalog + toast */
dialog { border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); color: var(--text); padding: 22px; max-width: 440px; width: calc(100% - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 10, 28, 0.62); backdrop-filter: blur(2px); }
dialog h2 { margin-bottom: 8px; font-size: 16px; }
dialog .form-actions { justify-content: flex-end; margin-top: 18px; }

[hidden] { display: none !important; }

/* Seçim penceresi (picker.js) */
dialog.picker { max-width: 640px; padding: 18px 20px; }
.picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.picker-head h2 { margin: 0; }
.picker-list { margin-top: 12px; max-height: min(52vh, 420px); overflow: auto; }
.picker-list thead th { position: sticky; top: 0; z-index: 1; }
.picker-list tbody tr { cursor: pointer; }
.picker-list tbody tr.active td { background: var(--accent-soft); }
.picker-list tbody tr.selected td:first-child { font-weight: 700; }
.picker-list tbody tr.picked td { color: var(--muted); }
.picker-list tbody tr.picked td:first-child::before { content: '✓ '; color: var(--accent); }
.picker-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.picker-status { font-size: 12.5px; color: var(--muted); }
.picker-status.error { color: var(--danger); }
.picker-group { display: flex; gap: 6px; align-items: stretch; }
.picker-group input { flex: 1; min-width: 0; }
.picker-group .btn { padding: 7px 10px; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { background: var(--surface-3); border: 1px solid var(--border-strong); border-left: 4px solid var(--accent); border-radius: 9px; padding: 11px 16px; box-shadow: var(--shadow); max-width: 380px; animation: toast-in 0.2s ease-out; }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Giriş / kurulum */
.bare { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1000px 500px at 20% -10%, var(--accent-soft), transparent), var(--bg); }
.bare-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 30px; box-shadow: var(--shadow); }
.bare-card .brand { padding: 0 0 20px; margin: 0; border-bottom: 0; font-size: 24px; }

@media print {
  .sidebar, .topbar, .toolbar, .no-print, .toasts { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
  .card, .table-wrap { border-color: #bbb; background: #fff; }
  table.data th { background: #eee; color: #000; }
  :root { --text: #000; --muted: #333; }
}

@media (max-width: 960px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; width: 272px; transform: translateX(-100%); transition: transform 0.2s; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 40; }
  .hamburger { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .form-grid { grid-template-columns: 1fr; }
  .user-chip .who { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}
