@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root,
html[data-theme="dark"] {
  --ink: #0a0f1a;
  --panel: #101828;
  --panel-2: #16213a;
  --line: #223047;
  --paper: #e9edf5;
  --paper-dim: #8a96ad;
  --accent: #f2a93b;     /* amber - yenileme / uyarı */
  --accent-ink: #1a1102;
  --good: #34d399;       /* ödendi / aktif */
  --bad: #f0625f;        /* gecikmiş / iptal */
  --info: #5b8def;       /* nötr bilgi */
  --radius: 10px;
  --shadow: 0 12px 32px rgba(0,0,0,0.45);
}

/* ---------- Tema Seçenekleri ---------- */
html[data-theme="light"] {
  --ink: #f3f4f8;
  --panel: #ffffff;
  --panel-2: #f0f1f6;
  --line: #dde1ea;
  --paper: #171b26;
  --paper-dim: #667085;
  --accent: #d97706;
  --accent-ink: #ffffff;
  --good: #059669;
  --bad: #dc2626;
  --info: #2563eb;
  --shadow: 0 12px 32px rgba(30,41,59,0.10);
}

html[data-theme="emerald"] {
  --ink: #06120d;
  --panel: #0d1f17;
  --panel-2: #123023;
  --line: #1f4a36;
  --paper: #e6f5ee;
  --paper-dim: #7fa896;
  --accent: #34d399;
  --accent-ink: #04160f;
  --good: #6ee7b7;
  --bad: #f0625f;
  --info: #5b8def;
}

html[data-theme="purple"] {
  --ink: #100a1c;
  --panel: #1a1330;
  --panel-2: #241c3f;
  --line: #3a2d5c;
  --paper: #ede9f9;
  --paper-dim: #a293c9;
  --accent: #a78bfa;
  --accent-ink: #1a1102;
  --good: #34d399;
  --bad: #f78787;
  --info: #818cf8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'JetBrains Mono', monospace; }

.display {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.04em;
  font-weight: 400;
}

/* ---------- Layout shell ---------- */
#app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 10px 22px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.brand-q {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 30px;
  color: var(--accent);
  line-height: 1;
}
.brand-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  letter-spacing: 0.08em;
  color: var(--paper);
}
.brand-sub {
  font-size: 10.5px;
  color: var(--paper-dim);
  letter-spacing: 0.03em;
  margin-top: 4px;
  line-height: 1.3;
}

/* ---------- Tema Seçici ---------- */
.theme-picker {
  margin-top: 14px;
  padding: 12px 12px 4px 12px;
  border-top: 1px solid var(--line);
}
.theme-picker-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--paper-dim);
  margin-bottom: 9px;
}
.theme-swatches { display: flex; gap: 9px; }
.swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  padding: 0;
  transition: transform .12s, border-color .12s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { border-color: var(--paper); }
.swatch-dark { background: linear-gradient(135deg, #101828 50%, #f2a93b 50%); }
.swatch-light { background: linear-gradient(135deg, #ffffff 50%, #d97706 50%); border: 1px solid #d0d5dd; }
.swatch-emerald { background: linear-gradient(135deg, #0d1f17 50%, #34d399 50%); }
.swatch-purple { background: linear-gradient(135deg, #1a1330 50%, #a78bfa 50%); }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--paper-dim);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-btn:hover { background: var(--panel-2); color: var(--paper); }
.nav-btn.active {
  background: linear-gradient(90deg, rgba(242,169,59,0.16), transparent);
  color: var(--accent);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}
.nav-btn .badge {
  margin-left: auto;
  background: var(--bad);
  color: white;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
}
.nav-btn .badge.zero { display: none; }

#main {
  padding: 26px 34px 60px 34px;
  overflow-y: auto;
}

.page { display: none; animation: fadein .18s ease; }
.page.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity:1; transform:none; } }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 22px;
}
.page-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 30px;
  letter-spacing: 0.03em;
}
.page-desc { color: var(--paper-dim); font-size: 13px; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(0.97); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--panel-2); color: var(--paper); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-good { background: var(--good); color: #05261c; }
.btn-danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn-wa { background: #25d366; color: #04220f; }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }

/* ---------- Cards / KPI quattro grid ---------- */
.quattro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--accent);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
}
.kpi-cell {
  background: var(--panel);
  padding: 20px 22px;
  position: relative;
}
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--paper-dim);
  margin-bottom: 8px;
}
.kpi-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 34px;
  letter-spacing: 0.02em;
}
.kpi-value.warn { color: var(--accent); }
.kpi-value.bad { color: var(--bad); }
.kpi-value.good { color: var(--good); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.card-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* stamp-corner status badge — sigorta evrakı imasıyla */
.status-tag {
  position: relative;
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px 3px 8px;
  border-radius: 3px 8px 3px 8px;
  border: 1px solid;
}
.status-aktif { color: var(--good); border-color: var(--good); background: rgba(52,211,153,0.08); }
.status-iptal { color: var(--bad); border-color: var(--bad); background: rgba(240,98,95,0.08); }
.status-yenilendi { color: var(--info); border-color: var(--info); background: rgba(91,141,239,0.08); }
.status-sure-gecti { color: var(--accent); border-color: var(--accent); background: rgba(242,169,59,0.08); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  color: var(--paper-dim);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
tbody td { padding: 11px 10px; border-bottom: 1px solid rgba(34,48,71,0.6); vertical-align: middle; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
.table-empty { text-align: center; color: var(--paper-dim); padding: 30px; font-size: 13px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 11.5px; color: var(--paper-dim); font-weight: 600; }
input, select, textarea {
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--paper);
  border-radius: 7px;
  padding: 9px 11px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(5,8,14,0.72);
  backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
  z-index: 999;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  width: 560px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-family:'Bebas Neue',sans-serif; font-size: 20px; letter-spacing:.03em; }
.modal-close { background:none; border:none; color:var(--paper-dim); cursor:pointer; font-size: 18px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 22px; right: 22px;
  background: var(--panel-2); border: 1px solid var(--accent);
  padding: 12px 18px; border-radius: 9px; font-size: 13px;
  box-shadow: var(--shadow); display: none; z-index: 1200;
}

/* ---------- Login (temadan bağımsız, her zaman açık renk) ---------- */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef2f8 0%, #e7ecf5 45%, #dde4f0 100%);
}
.login-box {
  width: 400px; background: #ffffff; border: 1px solid #e3e7f0;
  border-radius: 16px; padding: 38px 34px; box-shadow: 0 20px 50px rgba(30,41,59,0.14);
}
.login-title { text-align: center; margin: 0 0 26px 0; }
.login-q {
  display: block;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 46px;
  color: #d97706;
  line-height: 1;
}
.login-company-line1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
  letter-spacing: 0.05em;
  color: #12151f;
  margin-top: 4px;
}
.login-company-line2 {
  font-size: 12px;
  color: #6b7280;
  letter-spacing: 0.02em;
  margin-top: 3px;
}
#login-screen .form-field label { color: #4b5563; }
#login-screen input {
  background: #f9fafb; border: 1px solid #e5e7eb; color: #12151f;
}
#login-screen input:focus { border-color: #d97706; }
#login-screen .hint { color: #9ca3af; }
#loginError { color: #dc2626; font-weight: 600; }
.btn-login-primary {
  width: 100%; justify-content: center; display: flex;
  background: #d97706; color: #ffffff; border: none; border-radius: 8px;
  font-family: 'Inter', sans-serif; font-weight: 700; font-size: 14px;
  padding: 11px 16px; cursor: pointer; transition: filter .15s;
}
.btn-login-primary:hover { filter: brightness(1.08); }

.wa-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px;
  margin-bottom: 9px; background: var(--panel-2);
}
.wa-meta { font-size: 12.5px; color: var(--paper-dim); }
.wa-meta b { color: var(--paper); }

.pill {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  background: rgba(242,169,59,0.14); color: var(--accent); margin-left: 8px;
}
.pill.bad { background: rgba(240,98,95,0.14); color: var(--bad); }

.muted { color: var(--paper-dim); font-size: 12.5px; }
.right { text-align: right; }
.flex-between { display:flex; align-items:center; justify-content:space-between; }
.hint { font-size: 11.5px; color: var(--paper-dim); margin-top: 4px; }

/* ============================================================
   MOBİL UYUM
   ============================================================ */

/* Mobil üst çubuk (sadece <900px'de görünür) */
#mobileTopBar {
  display: none;
  position: sticky; top: 0; z-index: 60;
  align-items: center; gap: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}
#mobileTopBar .hamburger-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--paper);
  width: 38px; height: 38px; border-radius: 8px; font-size: 18px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
#mobileTopBar .mb-brand-q { font-family:'Bebas Neue',sans-serif; color: var(--accent); font-size: 22px; }
#mobileTopBar .mb-brand-name { font-family:'Bebas Neue',sans-serif; font-size: 16px; letter-spacing:.05em; }

#sidebarOverlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  z-index: 70;
}
#sidebarOverlay.open { display: block; }

@media (max-width: 900px) {
  #mobileTopBar { display: flex; }

  #app-shell { grid-template-columns: 1fr; }

  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 80;
    width: 260px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    overflow-y: auto;
    box-shadow: var(--shadow);
  }
  #sidebar.open { transform: translateX(0); }
  .brand { display: flex !important; }

  #main { padding: 18px 16px 50px 16px; }

  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-header > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
  .page-header input, .page-header select { width: 100% !important; }

  .quattro-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 28px; }

  .form-grid { grid-template-columns: 1fr; }

  .modal-box { width: 100%; max-width: 100vw; border-radius: 0; max-height: 100vh; height: 100vh; }
  .modal-overlay.active { align-items: stretch; }

  .login-box { width: 92vw; padding: 30px 22px; }

  /* --- Tabloları kart görünümüne çevir --- */
  table thead { display: none; }
  table, table tbody, table tr, table td { display: block; width: 100%; }
  table tbody tr {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 4px 14px;
    margin-bottom: 10px;
  }
  table tbody tr:hover { background: var(--panel-2); }
  table tbody td {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    text-align: right;
  }
  table tbody td:last-child { border-bottom: none; }
  table tbody td::before {
    content: attr(data-label);
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--paper-dim); font-weight: 700; text-align: left;
  }
  table tbody td:empty,
  table tbody td[data-label=""]::before { display: none; }
  table tbody td.table-empty { text-align:center; display:block; }
  table tbody td.table-empty::before { display:none; }
  .card { padding: 16px; }
  .card table { margin-top: 4px; }
}

@media (max-width: 480px) {
  .kpi-value { font-size: 24px; }
  .page-title { font-size: 24px; }
  .wa-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .wa-row a.btn { text-align: center; justify-content: center; }
}
