:root {
  --bg: #0e0e10; --panel: #17171a; --panel-2: #1f1f23; --line: #2a2a30; --line-2: #36363d;
  --ink: #f3f3f4; --ink-2: #a0a0a8; --ink-3: #6c6c74;
  --gold: #c9a24a; --gold-soft: rgba(201, 162, 74, .14);
  --pos: #45b87a; --pos-soft: rgba(69, 184, 122, .14);
  --neg: #e8655d; --neg-soft: rgba(232, 101, 93, .14);
  --warn: #e3a64a; --warn-soft: rgba(227, 166, 74, .14);
  --info: #6f95e6; --info-soft: rgba(111, 149, 230, .15);
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.4; }
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; margin: 0; letter-spacing: -.01em; }
h3 { font-size: .78rem; margin: 0 0 .6rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .gold { color: var(--gold); }
.sp { flex: 1; }

/* ---------- Kabuk ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; background: #121214; border-right: 1px solid var(--line);
  padding: calc(18px + var(--safe-t)) 12px calc(14px + var(--safe-b)) calc(12px + var(--safe-l));
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand img { width: 38px; height: 38px; border-radius: 10px; }
.brand b { display: block; font-size: 1.02rem; letter-spacing: -.01em; }
.brand small { color: var(--ink-3); font-size: .75rem; }
.nav-a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  text-decoration: none; color: var(--ink-2); font-weight: 500;
}
.nav-a svg { width: 21px; height: 21px; flex: none; }
.nav-a .short { display: none; }
.nav-a.active { background: var(--panel-2); color: var(--ink); box-shadow: inset 3px 0 0 var(--gold); }
.nav-a.active svg { color: var(--gold); }
.side-foot { margin-top: auto; padding: 8px; font-size: .75rem; color: var(--ink-3); }
.main { min-width: 0; padding: calc(22px + var(--safe-t)) calc(28px + var(--safe-r)) calc(40px + var(--safe-b)) 28px; }

/* iPad dikey: dar kenar çubuğu */
@media (max-width: 1280px) {
  .shell { grid-template-columns: 84px 1fr; }
  .side { padding-left: calc(8px + var(--safe-l)); padding-right: 8px; }
  .brand { justify-content: center; padding: 0 0 16px; }
  .brand div, .side-foot { display: none; }
  .nav-a { flex-direction: column; gap: 4px; font-size: .68rem; padding: 10px 2px; text-align: center; }
  .nav-a .long { display: none; }
  .nav-a .short { display: inline; }
  .nav-a.active { box-shadow: inset 0 -2px 0 var(--gold); }
  .main { padding-left: 22px; padding-right: calc(22px + var(--safe-r)); }
}
/* Telefon: alt sekme çubuğu */
@media (max-width: 640px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20; flex-direction: row;
    padding: 6px 6px calc(6px + var(--safe-b)); border-right: 0; border-top: 1px solid var(--line); justify-content: space-around;
  }
  .brand { display: none; }
  .nav-a { flex: 1; }
  .main { padding: calc(16px + var(--safe-t)) 16px calc(96px + var(--safe-b)); }
}

/* ---------- Ortak ---------- */
.head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.head .sub { color: var(--ink-2); margin-top: 4px; }
.head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 11px; border: 1px solid var(--line-2); background: var(--panel-2); font-weight: 600; white-space: nowrap; text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #17140c; }
.btn.danger { color: var(--neg); background: transparent; border-color: rgba(232, 101, 93, .4); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .88rem; border-radius: 9px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--panel-2);
  display: inline-grid; place-items: center; flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
.btn:active, .icon-btn:active, .row:active, .day:active { opacity: .7; }

.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button, .seg label { border: 0; background: none; padding: 0 14px; min-height: 36px; border-radius: 8px; color: var(--ink-2); font-weight: 500; display: inline-flex; align-items: center; cursor: pointer; }
.seg .on, .seg input:checked + span { color: var(--ink); }
.seg button.on { background: var(--line-2); }
.seg label { padding: 0; }
.seg label span { padding: 0 14px; min-height: 36px; display: inline-flex; align-items: center; border-radius: 8px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { background: var(--line-2); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search { flex: 1; min-width: 180px; max-width: 360px; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; border: 0; }
.pill.opsiyon { background: var(--warn-soft); color: var(--warn); }
.pill.kesin { background: var(--info-soft); color: var(--info); }
.pill.tamam { background: var(--pos-soft); color: var(--pos); }
.pill.iptal { background: var(--panel-2); color: var(--ink-3); }
.pill.paid { background: var(--pos-soft); color: var(--pos); }
.pill.wait { background: var(--warn-soft); color: var(--warn); }
.pill.late { background: var(--neg-soft); color: var(--neg); }
button.pill { min-height: 32px; padding: 0 12px; }

/* KPI kutuları */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis.k3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) { .kpis.k3, .kpis { grid-template-columns: 1fr 1fr; } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi span { display: block; color: var(--ink-2); font-size: .82rem; margin-bottom: 6px; }
.kpi b { font-size: 1.35rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi small { display: block; color: var(--ink-3); font-size: .76rem; margin-top: 4px; }

.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px;
  background: var(--gold-soft); border: 1px solid rgba(201, 162, 74, .35); color: var(--ink);
}
.banner svg { width: 22px; height: 22px; color: var(--gold); flex: none; }

/* Liste satırları */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line);
  background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; width: 100%;
}
.rows .row:last-child { border-bottom: 0; }
.row .main-t { flex: 1; min-width: 0; }
.row .main-t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .main-t small { display: block; color: var(--ink-2); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-chip {
  width: 50px; flex: none; text-align: center; border-radius: 10px; background: var(--panel-2); padding: 6px 0;
}
.date-chip b { display: block; font-size: 1.15rem; line-height: 1.1; }
.date-chip small { display: block; font-size: .68rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.empty { text-align: center; color: var(--ink-3); padding: 28px 12px; }

/* Tablo */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th { text-align: left; font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 0 10px 10px; white-space: nowrap; }
td { padding: 12px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:active { background: var(--panel-2); }
td.r, th.r { text-align: right; }
td .t { font-weight: 600; }
td small { display: block; color: var(--ink-2); font-size: .8rem; }
tfoot td { font-weight: 700; border-top: 1px solid var(--line-2); cursor: default; }

/* ---------- Takvim ---------- */
.cal-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .cal-layout { grid-template-columns: 1fr; } }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav h1 { margin-right: 6px; }
.cal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.cal-dow span { padding: 10px 8px; font-size: .75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.day {
  min-height: 108px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: none;
  padding: 6px; text-align: left; display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow: hidden;
}
.day:nth-child(7n) { border-right: 0; }
.day.out { background: rgba(0, 0, 0, .25); }
.day.out .dn { color: var(--ink-3); }
.day .dn { font-size: .85rem; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; color: var(--ink-2); }
.day.today .dn { background: var(--gold); color: #17140c; }
.day.sel { box-shadow: inset 0 0 0 2px var(--gold); }
.chip {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: .72rem; line-height: 1.25; padding: 3px 5px;
  border-radius: 6px; overflow: hidden; overflow-wrap: anywhere; font-weight: 600; border-left: 3px solid; flex: none; max-height: calc(2.5em + 6px);
}
.chip.opsiyon { background: var(--warn-soft); color: var(--warn); }
.chip.kesin { background: var(--info-soft); color: var(--info); }
.chip.tamam { background: var(--pos-soft); color: var(--pos); }
.chip.iptal { background: var(--panel-2); color: var(--ink-3); text-decoration: line-through; }
.more { font-size: .72rem; color: var(--ink-2); padding-left: 4px; }
.dots { display: flex; gap: 3px; margin-top: auto; padding-left: 4px; }
.dot { width: 7px; height: 7px; border-radius: 50%; }
.dot.in { background: var(--gold); } .dot.out { background: var(--neg); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--ink-2); margin-top: 10px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
@media (max-width: 1100px) { .day { min-height: 92px; } }
@media (max-width: 640px) {
  .day { min-height: 56px; padding: 4px 2px; align-items: center; }
  .day .chip { display: none; }
  .day .more { display: none; }
  .day .dots { margin-top: 2px; padding: 0; }
  .day.has-ev .dn { box-shadow: inset 0 -2px 0 var(--info); }
  .cal-nav h1 { font-size: 1.3rem; }
}
.ev-card {
  display: block; width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px; border-left: 4px solid var(--info);
}
.ev-card.opsiyon { border-left-color: var(--warn); } .ev-card.tamam { border-left-color: var(--pos); } .ev-card.iptal { border-left-color: var(--ink-3); opacity: .7; }
.ev-card b { display: block; }
.ev-card small { display: block; color: var(--ink-2); margin-top: 3px; }
.ev-card .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }

/* Grafik */
.bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: end; height: 170px; padding-top: 6px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bar-pair { flex: 1; width: 100%; display: flex; gap: 4px; align-items: flex-end; justify-content: center; }
.bar { width: 40%; max-width: 26px; border-radius: 5px 5px 2px 2px; min-height: 2px; }
.bar.in { background: var(--gold); } .bar.out { background: var(--neg); opacity: .8; }
.bar-col small { font-size: .72rem; color: var(--ink-3); }

.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin: 10px 0 4px; }
.progress i { display: block; height: 100%; background: var(--pos); border-radius: 99px; }

/* ---------- Pencere (sheet) ---------- */
.sheet-root { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.sheet-root[hidden] { display: none; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet {
  position: relative; width: min(640px, 100%); max-height: calc(100vh - 40px - var(--safe-t) - var(--safe-b)); overflow-y: auto;
  -webkit-overflow-scrolling: touch; background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5); animation: pop .18s ease-out;
}
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 6px; position: sticky; top: 0; background: var(--panel); z-index: 2; }
.sheet-head h2 { flex: 1; font-size: 1.2rem; }
.sheet-body { padding: 10px 20px 8px; }
.sheet-foot { display: flex; gap: 10px; padding: 14px 20px 18px; position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); }
@media (max-width: 640px) {
  .sheet-root { padding: 0; place-items: end stretch; }
  .sheet { width: 100%; border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: var(--safe-b); }
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span2 { grid-column: span 2; }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: auto; } }
.f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.f > span { font-size: .8rem; color: var(--ink-2); font-weight: 500; }
.f .pair { display: flex; gap: 8px; }
.f .seg { align-self: flex-start; flex-wrap: wrap; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin: 4px 0 16px; }
.info-grid div { min-width: 0; }
.info-grid small { display: block; color: var(--ink-3); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; }
.info-grid a { color: var(--gold); text-decoration: none; }
.fin { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.fin div { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.fin small { display: block; color: var(--ink-2); font-size: .75rem; }
.fin b { font-variant-numeric: tabular-nums; }
.notes { white-space: pre-wrap; background: var(--panel-2); border-radius: 10px; padding: 12px; color: var(--ink-2); }
.section-t { display: flex; align-items: center; gap: 8px; margin: 20px 0 6px; }
.section-t h3 { flex: 1; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: #f3f3f4; color: #111; padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 80; transition: .2s; max-width: 90vw;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
@media (max-width: 640px) { .toast { bottom: calc(96px + var(--safe-b)); } }

.settings .row { cursor: default; }
.settings .row:active { opacity: 1; }
