:root {
  --bg: #0f1117; --bg2: #161a24; --surface: #1c2130; --surface-2: #242b3d; --border: #2c3448;
  --text: #eef1f8; --muted: #8b95ad; --accent: #ff3d81; --accent-2: #8b5cf6; --ok: #22c55e; --warn: #f59e0b; --danger: #ef4444;
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1rem; margin-bottom: 12px; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
[hidden] { display: none !important; }

input, select, textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg2); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(139,92,246,.2); }
input[type=range] { padding: 0; accent-color: var(--accent); }
input[type=color] { padding: 4px; height: 42px; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=file] { padding: 8px; }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 500; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--text); }
label output { font-weight: 700; color: var(--text); }
label.check { flex-direction: row; align-items: center; color: var(--text); }

.btn { border: 0; padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .9rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--surface-2); color: var(--text); transition: .2s; }
.btn:hover { filter: brightness(1.15); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-ghost { background: var(--surface-2); }
.btn-danger { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.35); }
.btn-sm { padding: 6px 10px; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-icon { background: transparent; border: 0; color: var(--muted); font-size: 1rem; padding: 6px; border-radius: 8px; }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

/* Giriş */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(800px 500px at 30% 0%, #2a1442, var(--bg) 70%); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 60px rgba(0,0,0,.5); }
.login-icon { font-size: 2.5rem; text-align: center; }
.login-card h1 { text-align: center; font-size: 1.5rem; }
.login-card p { text-align: center; margin: 0 0 6px; }
.error { color: #fca5a5; font-size: .85rem; min-height: 1.2em; }
.back { text-align: center; color: var(--muted); font-size: .85rem; }

/* Yerleşim */
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 20px; }
.side-brand span { font-size: 1.8rem; }
.side-brand b { display: block; }
.side-brand small { color: var(--muted); }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { text-align: left; background: transparent; border: 0; color: var(--muted); padding: 11px 12px; border-radius: 10px; font-weight: 600; font-size: .92rem; display: flex; align-items: center; gap: 8px; transition: .2s; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(255,61,129,.2), rgba(139,92,246,.2)); color: var(--text); }
.nav-item .count { margin-left: auto; background: var(--surface-2); padding: 2px 8px; border-radius: 999px; font-size: .75rem; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.content { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.menu-toggle { display: none; }
.view { display: flex; flex-direction: column; gap: 18px; }
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Pano */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 1.8rem; font-weight: 800; }
.stat span { color: var(--muted); font-size: .8rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.bar { flex: 1; background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; }
.bar:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 3px 8px; border-radius: 6px; font-size: .7rem; white-space: nowrap; margin-bottom: 4px; }
.cat-bars { display: flex; flex-direction: column; gap: 8px; }
.cat-bar { display: grid; grid-template-columns: 120px 1fr 50px; gap: 8px; align-items: center; font-size: .85rem; }
.cat-bar .track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.cat-bar .fill { height: 100%; border-radius: 5px; }
.rank { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.rank li span { color: var(--muted); float: right; }
.danger-zone { display: flex; justify-content: flex-end; }

/* Tablo */
.toolbar { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 8px; }
.bulk { display: flex; gap: 8px; align-items: center; background: rgba(139,92,246,.12); border: 1px solid rgba(139,92,246,.3); border-radius: 10px; padding: 8px 12px; flex-wrap: wrap; }
.bulk select { width: auto; padding: 6px 10px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.table th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.inactive td { opacity: .5; }
.table td.name { white-space: normal; min-width: 180px; }
.table td.name b { display: block; }
.table td.name small { color: var(--muted); }
.thumb { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; display: grid; place-items: center; font-size: 1.4rem; background: var(--surface-2); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; color: #fff; }
.tog { width: 40px; height: 22px; border-radius: 11px; border: 0; background: var(--surface-2); position: relative; transition: .2s; }
.tog::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.tog.on { background: var(--ok); }
.tog.on::after { left: 21px; }
.actions { display: flex; gap: 2px; }

/* Kategoriler */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.cat-card { background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--c); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.cat-card .cat-top { display: flex; align-items: center; gap: 10px; }
.cat-card .cat-top span { font-size: 1.6rem; }
.cat-card .cat-top b { font-size: 1.05rem; }
.cat-card .cat-meta { color: var(--muted); font-size: .8rem; }
.cat-card .actions { margin-top: auto; }

/* Zar düzenleyici */
.dice-editor { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.die-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.die-card.off { opacity: .55; }
.die-head { display: flex; gap: 8px; align-items: center; }
.die-head input[data-f=icon] { width: 60px; text-align: center; }
.die-head input[data-f=name] { flex: 1; }
.faces { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.faces label { flex-direction: row; align-items: center; gap: 6px; }
.faces label b { width: 18px; color: var(--muted); }
.die-foot { display: flex; justify-content: space-between; align-items: center; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 50; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal-card { width: 100%; max-width: 720px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 30px 70px rgba(0,0,0,.6); display: flex; flex-direction: column; max-height: 95vh; }
.modal-card.small { max-width: 440px; }
.modal-card header, .modal-card footer { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.modal-card header { border-bottom: 1px solid var(--border); }
.modal-card footer { border-top: 1px solid var(--border); justify-content: flex-end; }
.modal-card .x { background: transparent; border: 0; color: var(--muted); font-size: 1.1rem; }
.modal-body { padding: 20px; overflow-y: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.image-box { display: flex; flex-direction: column; gap: 6px; }
.image-row { display: flex; gap: 14px; }
.image-preview { width: 120px; height: 120px; border-radius: 12px; background: var(--bg2); border: 1px dashed var(--border); display: grid; place-items: center; color: var(--muted); font-size: .8rem; overflow: hidden; flex-shrink: 0; }
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-preview:has(img[src^="/img/positions/"]) { background: #eee5e2; }
.image-preview img[src^="/img/positions/"] { object-fit: contain; }
.image-controls { flex: 1; display: flex; flex-direction: column; gap: 8px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 80px); background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 12px; font-weight: 600; font-size: .9rem; z-index: 90; opacity: 0; transition: .25s; pointer-events: none; }
.toast.show { transform: translateX(-50%); opacity: 1; }
.toast.err { background: var(--danger); color: #fff; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 260px; transform: translateX(-100%); transition: .3s; }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  .menu-toggle { display: inline-flex; position: fixed; top: 12px; left: 12px; z-index: 45; width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 1.2rem; align-items: center; justify-content: center; }
  .content { padding-top: 64px; }
  .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .image-row { flex-direction: column; }
}
