:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --ink: #ffffff;
  --muted: #a8a8a8;
  --line: rgba(255,255,255,.12);
  --red: #c62828;
  --red2: #e53935;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
html, body { min-height: 100%; margin: 0; }
body {
  background:
    radial-gradient(ellipse 70% 45% at 0% 0%, rgba(198,40,40,.16), transparent 55%),
    linear-gradient(180deg, #050505, #0a0a0a 45%, #0f0f0f);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  padding-bottom: var(--safe-bottom);
}
a { color: inherit; text-decoration: none; }
button, .btn, a, input, select, textarea { touch-action: manipulation; }

.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.side {
  background: #000;
  border-right: 1px solid var(--line);
  padding: 1.25rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}

.brand { text-align: center; border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.brand img { width: 160px; height: auto; max-width: 100%; }
.brand small {
  display: block;
  margin-top: .5rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--red2);
  font-size: .7rem;
}

.nav a {
  display: block;
  padding: .75rem .85rem;
  color: rgba(255,255,255,.7);
  border-left: 3px solid transparent;
  min-height: 44px;
}
.nav a:hover { background: rgba(229,57,53,.12); color: #fff; }
.nav a.active {
  border-left-color: var(--red2);
  background: linear-gradient(90deg, rgba(198,40,40,.28), transparent);
  color: #fff;
}

.main { padding: 1.5rem; max-width: 100%; overflow-x: hidden; }
.page-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  align-items: end;
}
.page-head h1 {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: clamp(1.35rem, 5vw, 1.8rem);
  line-height: 1.15;
}
.page-head p { margin: .35rem 0 0; color: var(--muted); max-width: 40rem; }
.page-head .btn { min-height: 44px; display: inline-flex; align-items: center; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .8rem;
  margin-bottom: 1rem;
}
.stat { background: #1a1a1a; border: 1px solid var(--line); padding: 1rem; }
.stat .label { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat .value { font-size: clamp(1.25rem, 4vw, 1.6rem); margin-top: .35rem; word-break: break-word; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  min-width: 560px;
}
table.data th, table.data td {
  padding: .7rem .5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
table.data th {
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  border: 1px solid #fff;
  background: #fff;
  color: #000;
  padding: .55rem 1rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: .85rem;
  cursor: pointer;
  min-height: 44px;
}
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.btn-sm { padding: .4rem .7rem; font-size: .75rem; min-height: 36px; }

.badge {
  display: inline-block;
  border: 1px solid var(--line);
  padding: .15rem .45rem;
  font-size: .72rem;
  text-transform: uppercase;
}
.badge-red { color: var(--red2); border-color: rgba(198,40,40,.55); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.form-grid .full { grid-column: 1 / -1; }
label.field {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
input, select, textarea {
  width: 100%;
  background: #0d0d0d;
  border: 1px solid var(--line);
  color: #fff;
  padding: .7rem .75rem;
  font: inherit;
  font-size: 16px; /* iOS zoom önleme */
  text-transform: none;
  letter-spacing: normal;
  border-radius: 0;
  min-height: 44px;
}
textarea { min-height: 120px; resize: vertical; }
.muted { color: var(--muted); }
.split { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1rem; }
.triple {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1rem;
}
.triple > .panel {
  margin-bottom: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.triple > .panel h2 { margin-top: 0; }
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
  padding: .55rem 0;
  border-bottom: 1px solid var(--line);
}
.voter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .55rem;
}
.voter-item {
  display: flex;
  gap: .45rem;
  align-items: flex-start;
  text-transform: none;
  letter-spacing: normal;
  font-size: .9rem;
  color: #fff;
  border: 1px solid var(--line);
  padding: .6rem .7rem;
  min-height: 44px;
}
.voter-item input { width: auto; min-height: auto; margin-top: .2rem; flex: 0 0 auto; }
.form-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* Desktop: mobile chrome gizli */
.mobile-bar, .mobile-drawer, .mobile-backdrop { display: none; }

/* ---- Mobil ---- */
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }

  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: calc(.65rem + var(--safe-top)) .85rem .65rem;
    background: rgba(0,0,0,.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(8px);
  }
  .mobile-bar .brand-mini {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-width: 0;
  }
  .mobile-bar .brand-mini img {
    width: 36px;
    height: auto;
    flex: 0 0 auto;
  }
  .mobile-bar .brand-mini span {
    font-size: .72rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--red2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .menu-toggle {
    min-width: 44px;
    min-height: 44px;
    border: 1px solid rgba(255,255,255,.3);
    background: transparent;
    color: #fff;
    padding: 0 .7rem;
    font-size: .75rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    cursor: pointer;
  }

  .mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 50;
  }
  .mobile-backdrop.open { display: block; }

  .mobile-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    width: min(86vw, 320px);
    height: 100%;
    height: 100dvh;
    background: #050505;
    border-left: 1px solid var(--line);
    z-index: 60;
    padding: calc(1rem + var(--safe-top)) .85rem calc(1.25rem + var(--safe-bottom));
    transform: translateX(105%);
    transition: transform .22s ease;
    overflow-y: auto;
  }
  .mobile-drawer.open { transform: translateX(0); }
  .mobile-drawer .drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--line);
  }
  .mobile-drawer .drawer-head strong {
    letter-spacing: .1em;
    text-transform: uppercase;
    font-size: .8rem;
  }
  .mobile-drawer .nav a {
    border-left: 0;
    border-bottom: 1px solid rgba(255,255,255,.06);
    padding: .9rem .5rem;
    font-size: .95rem;
  }
  .mobile-drawer .nav a.active {
    background: rgba(198,40,40,.18);
    color: #fff;
    border-left: 0;
  }
  .mobile-drawer .drawer-user {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
  }

  .main {
    padding: 1rem .85rem 2rem;
  }
  .page-head {
    align-items: stretch;
    flex-direction: column;
  }
  .page-head .btn,
  .page-head a.btn {
    width: 100%;
  }

  .stats { grid-template-columns: 1fr 1fr; gap: .65rem; }
  .split, .form-grid, .triple { grid-template-columns: 1fr; }
  .panel { padding: .85rem; }

  .voter-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .stats { grid-template-columns: 1fr; }

  /* Tablolar → kart listesi (yatay kaydırma yok) */
  table.data {
    min-width: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }
  table.data thead { display: none; }
  table.data tbody { display: block; }
  table.data tr {
    display: block;
    background: #121212;
    border: 1px solid var(--line);
    margin-bottom: .75rem;
    padding: .35rem .65rem .55rem;
  }
  table.data td {
    display: grid;
    grid-template-columns: minmax(5.5rem, 34%) 1fr;
    gap: .45rem .75rem;
    align-items: start;
    border-bottom: 1px solid rgba(255,255,255,.06);
    padding: .55rem 0;
    font-size: .9rem;
    word-break: break-word;
  }
  table.data td:last-child { border-bottom: 0; }
  table.data td::before {
    content: attr(data-label);
    font-size: .68rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    padding-top: .15rem;
  }
  table.data td.actions {
    grid-template-columns: 1fr;
  }
  table.data td.actions::before {
    display: none;
  }
  table.data .btn,
  table.data a.btn {
    width: 100%;
    margin: .2rem 0;
    justify-content: center;
  }

  .page-head h1 { font-size: 1.25rem; }
  .main { padding: .85rem .7rem 1.75rem; }
  .panel { padding: .7rem; margin-bottom: .75rem; }
  .stat { padding: .85rem; }
  .form-grid { gap: .7rem; }
  label.field { font-size: .7rem; }

  .list-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .form-actions { flex-direction: column; }
  .form-actions .btn,
  .form-actions a.btn { width: 100%; }
  .page-head > a.btn,
  .page-head > .btn { width: 100%; }
}

/* Login mobil */
.login-wrap {
  width: min(420px, 100%);
  margin: 2rem auto;
  padding: 0 .85rem 2rem;
}
@media (max-width: 560px) {
  .login-wrap { margin: 1rem auto; }
  .login-wrap .panel { padding: 1.1rem .95rem; }
}

body.nav-open { overflow: hidden; }
