:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f1f5f9;
  color: var(--ink);
  line-height: 1.55;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.topbar {
  background: var(--bg);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px;
  background: var(--brand);
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 1rem;
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a {
  color: #cbd5e1;
  padding: 7px 12px;
  border-radius: 9px;
  font-size: .92rem;
  font-weight: 500;
}
.nav a:hover { background: var(--bg-soft); color: #fff; text-decoration: none; }
.nav a.active { background: var(--brand); color: #fff; }
.nav .who { color: #94a3b8; font-size: .85rem; padding: 7px 4px; }

.wrap { max-width: 1100px; margin: 22px auto; padding: 0 18px; }

.page-title { margin: 0 0 4px; font-size: 1.5rem; }
.page-sub { color: var(--muted); margin: 0 0 20px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 1.1rem; }
.card h3 { margin: 0 0 10px; font-size: 1rem; }

/* ---------- Stat grid ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.6rem; font-weight: 800; margin-top: 4px; }
.stat.green .value { color: var(--green); }
.stat.red .value { color: var(--red); }
.stat.brand .value { color: var(--brand); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand); color: #fff;
  border: none; border-radius: 10px;
  padding: 9px 16px; font-size: .92rem; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.sm { padding: 6px 11px; font-size: .82rem; }
.btn.ghost { background: #f1f5f9; color: var(--ink); }
.btn.ghost:hover { background: #e2e8f0; }
.btn.green { background: var(--green); }
.btn.green:hover { background: #15803d; }
.btn.red { background: var(--red); }
.btn.red:hover { background: #b91c1c; }
.btn.block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
label { display: block; font-size: .86rem; font-weight: 600; margin-bottom: 5px; color: #334155; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: .95rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 700;
}
.badge.paid { background: var(--green-soft); color: var(--green); }
.badge.unpaid { background: var(--red-soft); color: var(--red); }
.badge.info { background: #dbeafe; color: var(--brand-dark); }
.badge.code { background: var(--amber-soft); color: var(--amber); font-family: ui-monospace, monospace; letter-spacing: .05em; }

/* ---------- Flash ---------- */
.flashes { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 11px 15px; border-radius: 10px; font-size: .92rem; font-weight: 500; }
.flash.success { background: var(--green-soft); color: #166534; }
.flash.danger  { background: var(--red-soft); color: #991b1b; }
.flash.warning { background: var(--amber-soft); color: #92400e; }
.flash.info    { background: #dbeafe; color: #1e40af; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(135deg, #1e293b, #0f172a); }
.login-card { background: #fff; border-radius: 18px; padding: 32px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card .brand-big { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-card .brand-big .logo { width: 54px; height: 54px; background: var(--brand); border-radius: 14px; display: grid; place-items: center; font-size: 1.6rem; }
.login-card .brand-big h1 { margin: 0; font-size: 1.4rem; }
.login-card .brand-big p { margin: 0; color: var(--muted); font-size: .9rem; }
.tabs { display: flex; background: #f1f5f9; border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.tabs button { flex: 1; background: transparent; border: none; padding: 9px; border-radius: 8px; font-weight: 600; cursor: pointer; color: var(--muted); }
.tabs button.active { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

/* ---------- Utility ---------- */
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex.between { justify-content: space-between; }
.flex.wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.hidden { display: none; }
.pill-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 2.5rem; margin-bottom: 8px; }
.ann { border-left: 3px solid var(--brand); padding: 4px 0 4px 14px; margin-bottom: 16px; }
.ann h4 { margin: 0 0 4px; }
.ann .date { color: var(--muted); font-size: .8rem; }
.ann p { margin: 6px 0 0; white-space: pre-wrap; }

/* ---------- Payment method badges & inline pay form ---------- */
.badge.nakit { background: #dcfce7; color: #15803d; }
.badge.banka { background: #dbeafe; color: #1d4ed8; }
.badge.lock  { background: #f1f5f9; color: #64748b; }

details.pay { display: inline-block; }
details.pay > summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--green); color: #fff;
  border-radius: 10px; padding: 6px 11px; font-size: .82rem; font-weight: 600;
}
details.pay > summary::-webkit-details-marker { display: none; }
details.pay > summary:hover { background: #15803d; }
details.pay[open] > summary { background: var(--muted); }
.pay-box {
  margin-top: 10px; padding: 14px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 12px;
  text-align: left; min-width: 260px;
}
.method-choice { display: flex; gap: 8px; margin-bottom: 10px; }
.method-choice label {
  flex: 1; margin: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; text-align: center; font-weight: 600; background: #fff;
  transition: all .12s;
}
.method-choice input { display: none; }
.method-choice input:checked + span { color: var(--brand); }
.method-choice label:has(input:checked) { border-color: var(--brand); background: #eff6ff; }

/* ---------- Phone chip ---------- */
.phone { font-variant-numeric: tabular-nums; white-space: nowrap; }
.phone.verified::after { content: " ✓"; color: var(--green); font-weight: 700; }

/* ---------- Verify code input ---------- */
.code-input {
  letter-spacing: .5em; text-align: center; font-size: 1.6rem; font-weight: 700;
  padding: 14px;
}

/* ---------- Nicer gradients on stat cards ---------- */
.stat.brand { background: linear-gradient(135deg, #eff6ff, #ffffff); border-color: #bfdbfe; }
.stat.green { background: linear-gradient(135deg, #f0fdf4, #ffffff); border-color: #bbf7d0; }
.stat.red   { background: linear-gradient(135deg, #fef2f2, #ffffff); border-color: #fecaca; }

.hint { font-size: .8rem; color: var(--muted); margin: 6px 0 0; }
.lockmsg { color: var(--muted); font-size: .82rem; }

/* ---------- Password show/hide eye ---------- */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-size: 1.15rem; line-height: 1; padding: 6px 8px;
  opacity: .45; filter: grayscale(1); transition: opacity .12s;
}
.pw-eye:hover { opacity: .8; }
.pw-eye.on { opacity: 1; filter: none; }

/* ---------- Rules text ---------- */
.rules-text {
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: .98rem;
  color: #1e293b;
}

/* ============ MODERN POLISH (v2) ============ */
body {
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 500px at 100% -10%, #e0e7ff55, transparent),
    radial-gradient(1000px 500px at -10% 0%, #dbeafe55, transparent),
    #f1f5f9;
  background-attachment: fixed;
}

:root { --brand: #4f46e5; --brand-dark: #4338ca; }

.topbar {
  background: linear-gradient(100deg, #111827, #1e293b 55%, #312e81);
  backdrop-filter: saturate(1.2);
}
.brand .logo {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 4px 14px rgba(79,70,229,.45);
}
.nav a { transition: background .15s, color .15s; }
.nav a.active { background: linear-gradient(135deg, #6366f1, #4f46e5); box-shadow: 0 4px 12px rgba(79,70,229,.4); }

.card, .stat {
  border-radius: 16px;
  transition: box-shadow .18s, transform .18s;
}
.card:hover { box-shadow: 0 2px 6px rgba(15,23,42,.08), 0 14px 40px rgba(15,23,42,.08); }
.stat { position: relative; overflow: hidden; }
.stat:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(15,23,42,.10); }
.stat .value { letter-spacing: -.02em; }

.btn {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(79,70,229,.25);
  letter-spacing: .01em;
}
.btn:hover { transform: translateY(-1px); }
.btn.ghost { box-shadow: none; }
.btn.green { box-shadow: 0 2px 8px rgba(22,163,74,.25); }
.btn.red { box-shadow: 0 2px 8px rgba(220,38,38,.22); }

input, select, textarea { border-radius: 12px; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }

th { font-size: .74rem; }
tbody tr, table tr { transition: background .12s; }
.card table tr:hover td { background: #f8fafc; }

.badge { border: 1px solid transparent; }
.badge.paid { border-color: #bbf7d0; }
.badge.unpaid { border-color: #fecaca; }
.badge.info { border-color: #bfdbfe; }

.login-page {
  background:
    radial-gradient(900px 500px at 20% 10%, #4338ca, transparent),
    radial-gradient(900px 500px at 90% 90%, #0ea5e9, transparent),
    linear-gradient(135deg, #0f172a, #1e1b4b);
}
.login-card { border-radius: 22px; }
.login-card .brand-big .logo {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 8px 24px rgba(79,70,229,.5);
}
.tabs button.active { color: var(--brand); }

details.pay > summary { border-radius: 12px; }

/* ---------- Stat alt bilgi ---------- */
.stat .sub {
  margin-top: 6px; font-size: .78rem; opacity: .8; font-weight: 500;
}

/* ---------- Segment (donem) butonlari ---------- */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: #eef2ff; padding: 4px; border-radius: 12px; }
.seg-btn {
  padding: 7px 14px; border-radius: 9px; font-size: .88rem; font-weight: 600;
  color: #4338ca; text-decoration: none; transition: background .12s, color .12s;
}
.seg-btn:hover { background: #e0e7ff; }
.seg-btn.on { background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff; box-shadow: 0 3px 10px rgba(79,70,229,.35); }

/* ---------- Ekstre tablosu ---------- */
table.statement td.pos { color: #16a34a; font-weight: 600; }
table.statement td.neg { color: #dc2626; font-weight: 600; }
table.statement tr.devir td { background: #f8fafc; color: #64748b; }
table.statement tr.total-row td { background: #f1f5f9; border-top: 2px solid #cbd5e1; font-size: .95rem; }
.count-sel { font-weight: 600; }

/* ---------- Yazdirma ---------- */
@media print {
  .no-print, .topbar, .flash, footer, .btn { display: none !important; }
  body { background: #fff; }
  .wrap { margin: 0; max-width: 100%; }
  .card { box-shadow: none; border: 1px solid #e2e8f0; }
  .stat { box-shadow: none; border: 1px solid #e2e8f0; }
}

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .nav { gap: 2px; }
  .nav a { padding: 6px 9px; font-size: .85rem; }
  .nav .who { display: none; }
  .page-title { font-size: 1.25rem; }
  .wrap { margin: 14px auto; }
}
