:root {
  --bg: #f3f6f6; --panel: #fff; --line: #e1e7e8; --text: #15211f; --muted: #6a7775;
  --accent: #0f8a7a; --accent-ink: #fff; --ok: #1f9d55; --ok-bg: #e6f5ec; --amber: #b86e00; --amber-bg: #fff4e0;
  --red: #d13438; --red-bg: #fdecec; --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1a1c; --panel: #172427; --line: #263639; --text: #e7efee; --muted: #8fa19e;
    --accent: #2bb5a2; --accent-ink: #062320; --ok: #46c37b; --ok-bg: #173327; --amber: #f0a73a; --amber-bg: #3a2a12;
    --red: #ff6b6b; --red-bg: #3c1b1d; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
body.bare { padding-bottom: 0; }
a { color: inherit; }
main { max-width: 720px; margin: 0 auto; padding: 0 16px 24px; }
h1 { font-size: 24px; margin: 0; line-height: 1.2; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.txt-red { color: var(--red); } .txt-amber { color: var(--amber); } .txt-ok { color: var(--ok); }

/* üst ve alt çubuk */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; }
.logout button { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding: 4px; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 0 7px; text-decoration: none;
  font-size: 12px; font-weight: 600; color: var(--muted); }
.tabs a span { font-size: 20px; line-height: 1.1; filter: grayscale(1); opacity: .7; }
.tabs a.on { color: var(--accent); }
.tabs a.on span { filter: none; opacity: 1; }

/* düğmeler ve formlar */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn:active { transform: scale(.97); }
.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }
.link.danger { color: var(--red); }
input, select, textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; font-size: 16px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14px; }
.form label .muted { font-weight: 400; }
label.inline, .form label.inline { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; font-weight: 500; }
label.inline input[type=number], label.inline input[name=miktar] { width: 90px; }
label.inline select { width: auto; }
.form label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
legend { font-weight: 600; font-size: 14px; padding: 0 6px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.actions { display: flex; gap: 10px; justify-content: flex-end; }
.seg-radio { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg-radio label, .days label { position: relative; flex-direction: row; }
.seg-radio input, .days input { position: absolute; opacity: 0; }
.seg-radio span, .days span { display: block; width: 100%; padding: 9px 8px; text-align: center; border: 1px solid var(--line);
  border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; }
.seg-radio input:checked + span, .days input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg-radio input:focus-visible + span, .days input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.days span { padding: 9px 0; }
.times { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 8px; }
.quick { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: -6px; font-size: 14px; }
.quick button { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.checks label { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
[hidden] { display: none !important; }

/* kartlar */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; box-shadow: var(--shadow); }
.card h2:last-child { margin: 0; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 18px 0 8px; }
.pagehead p { margin: 4px 0 0; }
.flash { margin: 14px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.flash.err { background: var(--red-bg); color: var(--red); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .btn { margin-top: 8px; }
.intro { margin-top: 28px; }
.intro p { color: var(--muted); }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin: 10px 0; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); text-decoration: none; font-size: 14px; }
.alert > span:first-child { font-size: 20px; line-height: 1.2; }
.alert.amber { background: var(--amber-bg); border-color: transparent; color: var(--amber); }
.alert.red { background: var(--red-bg); border-color: transparent; color: var(--red); }
.alert b { color: var(--text); }

/* bugün */
.daynav { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 6px; }
.daynav a { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; text-decoration: none;
  font-size: 26px; background: var(--panel); border: 1px solid var(--line); }
.daynav div { text-align: center; display: flex; flex-direction: column; }
.daynav b { font-size: 20px; } .daynav small { color: var(--muted); }
.progress-line { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; font-size: 13px; color: var(--muted); }
.progress-line i, .bar { flex: 1; display: block; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-line b, .bar b { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 99px; transition: width .3s; }
.bar.amber b { background: var(--amber); } .bar.red b { background: var(--red); }
.slot { font-size: 15px; margin: 18px 0 8px; color: var(--accent); font-variant-numeric: tabular-nums; }
.slot.past { color: var(--muted); }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.dose { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.dose:first-child { border-top: 0; }
.dose-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; }
.dose-main small { color: var(--muted); font-size: 13px; }
.dose-main em { font-style: normal; font-weight: 600; color: var(--text); }
.dose-btns { display: flex; gap: 6px; flex: none; }
.dose.alindi { background: color-mix(in srgb, var(--ok-bg) 60%, transparent); }
.dose.alindi b { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text) 35%, transparent); }
.dose.alindi .state { color: var(--ok); font-weight: 600; }
.dose.atlandi { opacity: .65; }
.dose.late { box-shadow: inset 3px 0 0 var(--red); }
.dose.late .state { color: var(--red); font-weight: 600; }

/* ilaç / rapor listesi */
.person { font-size: 15px; color: var(--muted); margin: 20px 0 8px; display: flex; justify-content: space-between; }
.person .add { font-weight: 600; color: var(--accent); text-decoration: none; }
.cards { display: grid; gap: 10px; }
.med { display: flex; flex-direction: column; gap: 6px; padding: 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; box-shadow: var(--shadow); }
.med.off { opacity: .55; }
.med-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.med-head b { font-size: 17px; }
.med small { font-size: 13px; }
.stock { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.stock b { font-size: 18px; }
.tag { flex: none; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--line); color: var(--muted); }
.tag.amber { background: var(--amber-bg); color: var(--amber); } .tag.red { background: var(--red-bg); color: var(--red); }

/* ilaç sayfası */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; padding: 14px 6px; }
.stats div { display: flex; flex-direction: column; }
.stats div + div { border-left: 1px solid var(--line); }
.stats small { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stats b { font-size: 26px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 0; font-size: 15px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.pre { white-space: pre-line; }
details.sub { margin-top: 12px; }
details.sub summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.log { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.log li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.log li:first-child { border-top: 0; }
.log li > span:first-child { flex: 1; }
.danger-zone { display: flex; gap: 10px; justify-content: space-between; margin: 20px 0; }
.people { list-style: none; padding: 0; margin: 0 0 12px; }
.people li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.people li form.row { flex: 1; min-width: 200px; }

/* giriş */
.login { max-width: 320px; margin: 18vh auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.login form { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.login .error { color: var(--red); margin: 0; }

@media (max-width: 420px) {
  .dose { flex-wrap: wrap; }
  .dose-btns { margin-left: auto; }
  .grid2 { grid-template-columns: 1fr; }
}

/* passkey */
.pk-login { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.pk-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.pk-or::before, .pk-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.pk-btn { width: 100%; }

/* ilaç arama ve okutma */
.lookup { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px dashed var(--accent); border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 6%, transparent); }
.lookup > label { font-weight: 600; font-size: 14px; }
.lookup .row input { flex: 1; }
.lookup-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; }
.lookup-list li { display: flex; flex-direction: column; padding: 9px 12px; border-top: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.lookup-list li:first-child { border-top: 0; }
.lookup-list li:hover, .lookup-list li:focus { background: color-mix(in srgb, var(--accent) 10%, transparent); outline: none; }
.lookup-list li small { color: var(--muted); font-size: 12px; }
.lookup-sel { margin: 0; font-size: 13px; color: var(--ok); }
.lookup-sel.warn { color: var(--amber); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.small { font-size: 13px; margin: 8px 0 0; }
.skt-in { width: auto !important; }
.scan-ov { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.92); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 20px; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.scan-box { position: relative; width: min(92vw, 480px); aspect-ratio: 3/4; border-radius: 16px; overflow: hidden; background: #000; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 22% 14%; border: 3px solid rgba(255,255,255,.85); border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scan-txt { color: #fff; text-align: center; margin: 0; font-size: 15px; }
