:root {
  color-scheme: light dark;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --line: #d8dce4;
  --text: #171a21;
  --muted: #5d6573;
  --primary: #2459d6;
  --on-primary: #ffffff;
  --ok: #17794f;
  --ok-bg: #dff3e8;
  --warn: #8a5a00;
  --warn-bg: #fff1d2;
  --bad: #b3261e;
  --bad-bg: #fde4e1;
  --radius: 14px;
  --tabbar: 58px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a;
    --surface: #1c2027;
    --surface-2: #2a2f38;
    --line: #363c47;
    --text: #eef0f4;
    --muted: #a4adba;
    --primary: #7ba2ff;
    --on-primary: #0c1322;
    --ok: #55d39a;
    --ok-bg: #173a2b;
    --warn: #ffd27d;
    --warn-bg: #3d2f12;
    --bad: #ff8a80;
    --bad-bg: #44201d;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .4; cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.topbar {
  flex: none; min-height: 52px; display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 14px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; min-width: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.icon-btn { flex: none; min-width: 40px; height: 40px; border-radius: 10px; font-size: 20px; line-height: 1; display: grid; place-items: center; padding: 0 8px; }
.icon-btn:active { background: var(--surface-2); }
.banner { flex: none; padding: 8px 14px; font-size: 13px; text-align: center; background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner button { text-decoration: underline; font-weight: 700; color: inherit; margin-left: 6px; }

#main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page { max-width: 760px; margin: 0 auto; padding: 12px 14px 28px; }
.page.wide { max-width: 1100px; }
.tabbar {
  flex: none; display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; min-width: 0; height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--muted);
}
.tabbar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.on { color: var(--primary); font-weight: 650; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 12px; }
.card > h2, .card > h3 { font-size: 15px; margin-bottom: 8px; }
.card.flat { border: 0; background: transparent; padding: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 650; }
.right { text-align: right; }
.gap-s { margin-top: 6px; }
.gap { margin-top: 12px; }
.section-title { margin: 18px 2px 8px; font-size: 13px; font-weight: 650; letter-spacing: .02em; color: var(--muted); text-transform: uppercase; }
.empty { padding: 26px 12px; text-align: center; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.primary { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--primary)); flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px;
  border-radius: 10px; background: var(--surface-2); font-weight: 600; text-align: center;
}
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.sm { min-height: 32px; padding: 0 11px; font-size: 13px; }
.btn.block { display: flex; width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn-row .btn { flex: 1; }
.link-btn { color: var(--primary); font-weight: 600; padding: 4px 0; }

.field { display: block; margin: 10px 0; }
.field > span { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
}
textarea.input { min-height: 70px; resize: vertical; }
.input.num { width: 78px; text-align: center; padding: 6px; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 34px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.check input { width: 20px; height: 20px; }

.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: var(--w, 0%); background: var(--c, var(--primary)); border-radius: 999px; }
.bar.thin { height: 5px; }

/* Plan blokları */
.item { position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px 10px 14px; margin: 0 0 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; border-left: 5px solid var(--c, var(--line)); }
.item.done { opacity: .62; }
.item.done .title { text-decoration: line-through; }
.item.skipped { opacity: .5; }
.item.break { background: transparent; border-style: dashed; border-left-width: 1px; color: var(--muted); padding: 6px 12px; }
.item .title { font-weight: 650; }
.item .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.item .acts { display: flex; gap: 6px; flex: none; align-items: center; }
.tick { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 17px; color: transparent; }
.tick.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.tick.half { border-color: var(--warn); color: var(--warn); }

/* Hafta */
.week-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.week-nav .title { flex: 1; text-align: center; font-weight: 650; }
.day { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.day.today { border-color: var(--primary); }
.day .d { flex: none; width: 52px; text-align: center; }
.day .d b { display: block; font-size: 18px; }
.day .d span { font-size: 11px; color: var(--muted); }
.day.past { opacity: .78; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }

/* Sayı kutuları, tablolar */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 6px 4px; text-align: center; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.net-box { text-align: center; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.net-box b { font-size: 24px; display: block; }

/* Sayfa altı sayfalar */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-back { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 18px 18px 0 0; overflow: hidden; padding-bottom: env(safe-area-inset-bottom);
}
.sheet-wrap.full .sheet { height: 92vh; }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-head { flex: none; display: flex; align-items: center; padding: 8px 8px 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; font-size: 16px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 12px 14px 18px; -webkit-overflow-scrolling: touch; }
.msg { margin: 0 0 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 18px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 80;
  max-width: 92vw; padding: 10px 16px; border-radius: 12px; background: #20242c; color: #fff; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; display: flex; gap: 12px; align-items: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.error { background: #8f1d16; }
.toast button { color: #9fc0ff; font-weight: 700; }

/* Grafik */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ln { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Giriş */
.login { max-width: 420px; margin: 8vh auto 0; padding: 0 18px; }
.login h1 { font-size: 26px; margin-bottom: 4px; }
.login .code { font-size: 22px; letter-spacing: .12em; text-align: center; text-transform: uppercase; }
.err { color: var(--bad); font-weight: 600; margin-top: 8px; }

/* Öğretmen */
.students { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.students .card { margin: 0; text-align: left; width: 100%; display: block; }
.stat { display: flex; gap: 14px; margin-top: 8px; }
.stat > div { flex: 1; }
.stat b { display: block; font-size: 17px; }
.stat span { font-size: 11.5px; color: var(--muted); }
.code-box { padding: 14px; border-radius: 12px; background: var(--surface-2); text-align: center; font-size: 26px; font-weight: 700; letter-spacing: .12em; user-select: all; }
.scale { display: flex; gap: 6px; }
.scale button { flex: 1; min-height: 40px; border-radius: 10px; background: var(--surface-2); font-weight: 700; }
.scale button.on { background: var(--primary); color: var(--on-primary); }

/* Odak sayacı */
.timer { text-align: center; padding: 18px 0 6px; }
.timer .time { font-size: 64px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.timer .phase { color: var(--muted); font-weight: 600; margin-bottom: 4px; }

/* Rapor ve yazdırma */
.report h1 { font-size: 22px; }
.report h2 { font-size: 15px; margin: 16px 0 6px; }
@media print {
  body { background: #fff; color: #000; }
  #app, .sheet-back, .sheet-head, .toast, .btn-row, .no-print { display: none !important; }
  .sheet-wrap { position: static; display: block; }
  .sheet { max-height: none; max-width: none; background: #fff; border-radius: 0; overflow: visible; }
  .sheet-body { overflow: visible; padding: 0; }
}
@media (min-width: 900px) {
  .topbar h1 { font-size: 18px; }
}
