:root {
  --bg: #f6f4f1;
  --panel: #ffffff;
  --panel-2: #faf8f5;
  --text: #22201d;
  --muted: #6b665f;
  --line: #e4ded6;
  --accent: #b4540f;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9dc;
  --ok: #1f7a4d;
  --ok-soft: #dcf2e6;
  --warn: #9a6400;
  --warn-soft: #fbefd2;
  --danger: #b42318;
  --danger-soft: #fde4e1;
  --heat: 180, 84, 15;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171513; --panel: #211e1b; --panel-2: #1b1917; --text: #eeeae4; --muted: #a39d94; --line: #37322d;
    --accent: #ee8a43; --accent-ink: #1a1208; --accent-soft: #3a2616; --ok: #5ccf94; --ok-soft: #173326;
    --warn: #f0b64a; --warn-soft: #3a2d12; --danger: #ff8a7a; --danger-soft: #3d1c18; --heat: 238, 138, 67;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171513; --panel: #211e1b; --panel-2: #1b1917; --text: #eeeae4; --muted: #a39d94; --line: #37322d;
  --accent: #ee8a43; --accent-ink: #1a1208; --accent-soft: #3a2616; --ok: #5ccf94; --ok-soft: #173326;
  --warn: #f0b64a; --warn-soft: #3a2d12; --danger: #ff8a7a; --danger-soft: #3d1c18; --heat: 238, 138, 67;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ---- üst bar ---- */
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 14px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .9rem; color: var(--muted); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }

/* ---- paneller ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat { padding: 16px; }
.stat .label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .85rem; color: var(--muted); }

/* ---- form elemanları ---- */
label { display: block; font-size: .85rem; font-weight: 600; margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input:not([type]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); color: var(--text); font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 160px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.bos { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.badge.taslak { background: var(--warn-soft); color: var(--warn); }
.badge.gonderildi { background: var(--ok-soft); color: var(--ok); }
.badge.risk { background: var(--accent-soft); color: var(--accent); }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .92rem; }
.alert.info { background: var(--accent-soft); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.danger { background: var(--danger-soft); color: var(--danger); }

/* ---- tablolar ---- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: var(--panel-2); font-weight: 600; font-size: .82rem; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
tr.satir-tik { cursor: pointer; }
tr.satir-tik:hover td { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* risk matrisi */
.matrix th.v { height: 180px; min-width: 30px; max-width: 30px; padding: 6px 2px; vertical-align: bottom; white-space: nowrap; }
.matrix th.v span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; font-size: .78rem; }
.matrix th.v.click { cursor: pointer; }
.matrix th.v.click:hover { color: var(--accent); }
.matrix td { text-align: center; padding: 4px; border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.matrix td.name, .matrix th.name { text-align: left; white-space: nowrap; position: sticky; left: 0; background: var(--panel); z-index: 1; }
.matrix thead th { position: sticky; top: 0; z-index: 2; }
.matrix thead th.name { z-index: 3; background: var(--panel-2); }
.matrix tfoot td { font-weight: 700; background: var(--panel-2); }
.matrix tr.ara-toplam td { font-weight: 700; background: var(--panel-2); border-bottom: 2px solid var(--line); }
.matrix input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ---- bar listesi ---- */
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: minmax(140px, 260px) 1fr 40px; gap: 10px; align-items: center; font-size: .88rem; }
.bar .track { height: 12px; background: var(--panel-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar .fill { height: 100%; background: var(--accent); border-radius: 99px; }
.bar .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar.click { cursor: pointer; } .bar.click:hover .lbl { color: var(--accent); }

/* ---- öğrenci formu ---- */
.editor { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) {
  .editor { grid-template-columns: 1fr; }
  .editor .student-list { max-height: 260px; }
  .editor .detail { position: static; }
}
.student-list { max-height: calc(100vh - 220px); overflow: auto; padding: 6px; }
.stu { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.stu:hover { background: var(--panel-2); }
.stu.active { background: var(--accent-soft); border-color: var(--accent); }
.stu .no { font-size: .8rem; color: var(--muted); min-width: 38px; font-variant-numeric: tabular-nums; }
.stu .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail { position: sticky; top: 70px; }
.grup { margin-top: 14px; }
.grup h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px; }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: .9rem; font-weight: 400; margin: 0; background: var(--panel-2); }
.check:hover { border-color: var(--accent); }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex-shrink: 0; }
.check.on { background: var(--accent-soft); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { padding: 3px 10px; border-radius: 99px; border: 1px dashed var(--line); background: none; color: var(--text); font: inherit; font-size: .82rem; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.save-state { font-size: .85rem; color: var(--muted); }

/* ---- modal & toast ---- */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); padding: 20px; width: min(640px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; font-size: .92rem; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }

/* ---- giriş sayfası ---- */
.auth { max-width: 460px; margin: 40px auto; }
.hero { text-align: center; margin: 40px 16px 10px; }
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto; }
.code-box { font: 700 1.6rem/1 ui-monospace, Consolas, monospace; letter-spacing: .2em; padding: 12px 16px; border: 2px dashed var(--accent); border-radius: 10px; display: inline-block; color: var(--accent); }

@media print {
  .topbar, .tabs, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}
