:root {
  --red: #e4002b;
  --red-dark: #b30022;
  --gold: #f5b301;
  --bg: #0b0b0f;
  --bg-soft: #14141b;
  --surface: #1b1b24;
  --surface-2: #23232e;
  --line: #2c2c39;
  --text: #f3f3f6;
  --muted: #9a9aab;
  --green: #16a34a;
  --amber: #f59e0b;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(228,0,43,.14), transparent 60%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}
h1, h2 { margin: 0; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff; font-weight: 800; font-size: 22px;
  display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(228,0,43,.4);
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--muted); }

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 32px; box-shadow: var(--shadow);
}
.login-card .brand { margin-bottom: 24px; }
.login-card h1 { font-size: 20px; margin-bottom: 20px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 12px 14px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); outline: none;
}
.login-card input:focus { border-color: var(--red); }
.login-card button {
  width: 100%; margin-top: 6px; padding: 13px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff; border: 0; border-radius: 10px; font-weight: 600;
}
.login-card button:disabled { opacity: .6; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin: 16px 0 0; }
.err { color: #ff6b81; font-size: 13px; min-height: 18px; margin-bottom: 8px; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: rgba(20,20,27,.85);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.hamburger { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); width: 40px; height: 40px; border-radius: 9px; font-size: 18px; line-height: 1; }
.hamburger:hover { border-color: var(--red); }
.whoami { font-size: 13px; color: var(--muted); }
.ghost {
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); padding: 8px 14px; border-radius: 9px;
}
.ghost:hover { border-color: var(--red); }

/* ---------- Layout (sidebar + icerik) ---------- */
.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 18px 60px; }
.layout { display: flex; align-items: flex-start; }
.sidebar {
  width: 230px; flex-shrink: 0; align-self: stretch;
  border-right: 1px solid var(--line); background: var(--bg-soft);
  transition: margin-left .25s ease;
}
.side-nav { position: sticky; top: 72px; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.side-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: none; border: 0; color: var(--muted); padding: 12px 14px;
  border-radius: 10px; font-weight: 500; font-size: 14px; white-space: nowrap;
}
.side-item:hover { background: var(--surface); color: var(--text); }
.side-item.active { background: rgba(228,0,43,.15); color: #fff; box-shadow: inset 3px 0 0 var(--red); }
.si-ico { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.content { flex: 1; min-width: 0; padding: 24px 24px 60px; }
.content > * { max-width: 1080px; margin-left: auto; margin-right: auto; }
.backdrop { display: none; }

/* Masaustu: menuyu kapat (disari kaydir) */
body.sidebar-collapsed .sidebar { margin-left: -231px; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px; }
.card-val { font-size: 26px; font-weight: 700; }
.card-val.warn { color: var(--amber); }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: 0; color: var(--muted);
  padding: 12px 18px; border-bottom: 2px solid transparent; font-weight: 500;
}
.tab.active { color: var(--text); border-bottom-color: var(--red); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 16px; }

.primary {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff; border: 0; padding: 10px 16px; border-radius: 9px; font-weight: 600;
}
.primary:hover { filter: brightness(1.08); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 14px; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; }
td.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; padding: 12px 20px; }
.name-link { color: var(--text); font-weight: 600; cursor: pointer; }
.name-link:hover { color: var(--gold); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.mini { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); padding: 6px 10px; border-radius: 7px; font-size: 12px; }
.mini:hover { border-color: var(--red); }
.mini.danger:hover { border-color: #ff6b81; color: #ff6b81; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.paid { background: rgba(22,163,74,.18); color: #4ade80; }
.badge.pending { background: rgba(245,158,11,.18); color: var(--amber); }
.badge.role-owner { background: rgba(228,0,43,.18); color: #ff6b81; }
.badge.role-admin { background: var(--surface-2); color: var(--muted); }
.inactive-tag { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: grid; place-items: center; padding: 18px; z-index: 50; }
.modal-bg[hidden] { display: none; }
.toast[hidden] { display: none; }
.modal { width: 100%; max-width: 480px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px; }
.modal .x { background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 9px; color: var(--text); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--red); }
.field textarea { resize: vertical; min-height: 60px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.modal .err { margin: 0 0 10px; }

/* Odeme gecmisi listesi (calisan detay) */
.pay-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.pay-item:last-child { border-bottom: 0; }
.pay-main { display: flex; flex-direction: column; gap: 3px; }
.pay-amt { font-weight: 700; font-size: 15px; }
.pay-meta { font-size: 12px; color: var(--muted); }

/* ---------- Paylasim izgarasi ---------- */
.grid-controls { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ctrl { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.ctrl input, .ctrl select { padding: 7px 10px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; color: var(--text); outline: none; }
.grid-hint { font-size: 12px; margin-left: auto; }
.grid-wrap { overflow: auto; max-height: 72vh; }
table.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
table.grid th, table.grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; margin: 0; }
table.grid thead th {
  position: sticky; top: 0; z-index: 3; background: var(--surface-2);
  color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase;
  padding: 8px 6px; text-align: center; white-space: nowrap; min-width: 92px;
}
table.grid thead th.sticky-col { z-index: 5; left: 0; }
table.grid th.sticky-col, table.grid td.sticky-col {
  position: sticky; left: 0; z-index: 2; background: var(--surface);
  min-width: 150px; max-width: 190px; border-right: 2px solid var(--line);
}
table.grid td.sticky-col { padding: 0; }
.p-name { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 10px; }
.p-name .p-label { font-weight: 600; font-size: 13px; color: var(--red); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-name .p-label:hover { color: var(--gold); }
.p-name .p-label.inactive { color: var(--muted); }
table.grid tbody tr:nth-child(even) td.sticky-col { background: var(--surface); }
table.grid td.cell { min-width: 92px; }
table.grid input.cell-in {
  width: 100%; height: 100%; min-height: 34px; border: 0; outline: none;
  background: transparent; color: var(--text); text-align: center; font-size: 13px; padding: 6px 4px;
}
table.grid input.cell-in:focus { background: rgba(228,0,43,.12); box-shadow: inset 0 0 0 2px var(--red); }
table.grid td.cell.v-yok input.cell-in { color: var(--muted); font-style: italic; }
table.grid td.cell.v-aff { background: rgba(59,130,246,.12); }
table.grid td.cell.v-aff input.cell-in { color: #93c5fd; font-weight: 600; }
table.grid td.cell.v-num input.cell-in { color: #4ade80; }
.p-move { display: flex; flex-direction: column; gap: 1px; }
.p-arrow { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); width: 20px; height: 15px; line-height: 1; border-radius: 4px; font-size: 9px; padding: 0; }
.p-arrow:hover { border-color: var(--red); color: var(--text); }
table.grid th.today { color: var(--gold); background: rgba(245,179,1,.14); }
table.grid td.today { background: rgba(245,179,1,.06); }
table.grid td.today.v-aff { background: rgba(59,130,246,.12); }
table.grid td.cell.cell-saved { animation: cellsave .7s ease; }
@keyframes cellsave { from { background: rgba(22,163,74,.4); } to { } }

/* ---------- Veriler tablosu ---------- */
.d-in { width: 100%; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text); padding: 7px 9px; text-align: right; font-size: 14px; outline: none; font-variant-numeric: tabular-nums; }
.d-in:hover { border-color: var(--line); }
.d-in:focus { border-color: var(--red); background: rgba(228,0,43,.1); }
tr.cell-saved { animation: cellsave .6s ease; }
.color-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 14px; }
.swatch:hover { border-color: var(--red); }

/* ---------- Veriler izgarasi (partner x tarih, Y/C/U) ---------- */
table.grid.grid-m thead th { min-width: 122px; }
table.grid td.m-cell { min-width: 122px; vertical-align: top; padding: 0; }
.metric-cell { display: grid; grid-template-columns: 13px 1fr; gap: 3px 4px; align-items: center; padding: 5px 7px; }
.mlab { font-size: 10px; color: var(--muted); text-align: center; font-weight: 700; }
.m-in { width: 100%; min-width: 55px; background: transparent; border: 1px solid var(--line); border-radius: 5px; color: var(--text); font-size: 12px; padding: 3px 5px; text-align: right; outline: none; font-variant-numeric: tabular-nums; }
.m-in:hover { border-color: var(--muted); }
.m-in:focus { border-color: var(--red); background: rgba(228,0,43,.12); }
table.grid td.m-cell.cell-saved { animation: cellsave .6s ease; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 80; font-size: 14px;
}
.toast.ok { border-color: var(--green); }
.toast.bad { border-color: #ff6b81; }

@media (max-width: 720px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}

/* Mobil: sidebar cekmece (drawer) */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; top: 66px; left: 0; bottom: 0; z-index: 45;
    margin-left: 0 !important; width: 240px;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: var(--shadow); overflow-y: auto;
  }
  body.sidebar-open .sidebar { transform: none; }
  .backdrop { position: fixed; inset: 66px 0 0 0; background: rgba(0,0,0,.55); z-index: 44; }
  body.sidebar-open .backdrop { display: block; }
  .content { padding: 18px 14px 60px; }
  .content > * { max-width: none; }
  .topbar { padding: 12px 14px; }
}
