/* =====================================================================
   Özlem'in Defteri — app.css
   Sade, sakin, sıcak; iOS hissi. Mobil öncelikli (390px), açık + koyu mod.
   Sınıf sözlüğü: SPEC.md bölüm 4.
   ===================================================================== */

/* ---------- 1. Tasarım değişkenleri (açık mod) ---------- */
:root {
  color-scheme: light dark;

  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f1efeb;
  --text: #1b2422;
  --text-2: #3e4946;
  --muted: #7b8582;
  --border: #e6e3dd;
  --border-strong: #cfcbc4;

  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #e2f3f0;
  --primary-ring: rgba(15, 118, 110, 0.22);

  --warn: #b45309;
  --warn-soft: #fdf1dd;
  --warn-line: #f3d6a6;
  --danger: #c43d2b;
  --danger-soft: #fde9e5;
  --danger-line: #f5c4bb;
  --ok: #15803d;
  --ok-soft: #e3f4e8;
  --ok-line: #b9e2c6;

  /* aşama renkleri (ana) + çip için yumuşak zemin/koyu metin */
  --st-yatis: #2563eb;
  --st-yatis-soft: #e4edfd;
  --st-yatis-ink: #1d4ed8;
  --st-hazirlik: #d97706;
  --st-hazirlik-soft: #fdf0d9;
  --st-hazirlik-ink: #92400e;
  --st-opgunu: #6d4bd8;
  --st-opgunu-soft: #ede8fc;
  --st-opgunu-ink: #5b34c4;
  --st-postop: #16a34a;
  --st-postop-soft: #e2f5e8;
  --st-postop-ink: #166534;
  --st-taburcu: #6b7280;
  --st-taburcu-soft: #eeeff1;
  --st-taburcu-ink: #4b5563;

  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(27, 36, 34, 0.04), 0 2px 10px rgba(27, 36, 34, 0.04);
  --shadow-lg: 0 10px 30px rgba(27, 36, 34, 0.16), 0 2px 6px rgba(27, 36, 34, 0.08);

  --bar-bg: rgba(246, 245, 242, 0.82);
  --tabbar-bg: rgba(252, 251, 249, 0.86);
  --seg-bg: #ebe9e4;
  --seg-on: #ffffff;
  --switch-off: #e2e0db;
  --cond-bg: #f3f9f8;
  --press: rgba(27, 36, 34, 0.05);
  --toast-bg: rgba(30, 38, 36, 0.94);
  --toast-ink: #ffffff;
  --backdrop: rgba(18, 24, 22, 0.38);
  --fab-shadow: 0 8px 20px rgba(15, 118, 110, 0.32), 0 2px 5px rgba(0, 0, 0, 0.12);
  --select-chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%237b8582' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  --tabbar-h: 52px;
  --maxw: 560px;
  --gutter: 16px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;
}

/* ---------- 2. Koyu mod — gece nöbeti için koyu lacivert-gri ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d131a;
    --surface: #151d26;
    --surface-2: #1d2731;
    --text: #e7ecef;
    --text-2: #c3ccd3;
    --muted: #8794a0;
    --border: #243039;
    --border-strong: #3a4753;

    --primary: #3cbfae;
    --primary-ink: #04201c;
    --primary-soft: #12302d;
    --primary-ring: rgba(60, 191, 174, 0.3);

    --warn: #f0b35a;
    --warn-soft: #2e2416;
    --warn-line: #5a4320;
    --danger: #f2876f;
    --danger-soft: #34201c;
    --danger-line: #643128;
    --ok: #63d091;
    --ok-soft: #142c1f;
    --ok-line: #24563a;

    --st-yatis: #6ea2ff;
    --st-yatis-soft: #1a2944;
    --st-yatis-ink: #a9c6ff;
    --st-hazirlik: #f0b35a;
    --st-hazirlik-soft: #33281a;
    --st-hazirlik-ink: #f5ca86;
    --st-opgunu: #a18bf5;
    --st-opgunu-soft: #272246;
    --st-opgunu-ink: #c5b8fb;
    --st-postop: #63d091;
    --st-postop-soft: #16301f;
    --st-postop-ink: #9be3b6;
    --st-taburcu: #8b96a3;
    --st-taburcu-soft: #222b35;
    --st-taburcu-ink: #b3bcc6;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);

    --bar-bg: rgba(13, 19, 26, 0.8);
    --tabbar-bg: rgba(18, 25, 33, 0.84);
    --seg-bg: #1d2731;
    --seg-on: #34414d;
    --switch-off: #344150;
    --cond-bg: #142226;
    --press: rgba(255, 255, 255, 0.05);
    --toast-bg: rgba(231, 236, 239, 0.95);
    --toast-ink: #0d131a;
    --backdrop: rgba(0, 0, 0, 0.55);
    --fab-shadow: 0 8px 22px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.35);
    --select-chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238794a0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}

/* ---------- 3. Temel ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-x: none;
  overscroll-behavior-y: contain;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  overscroll-behavior-x: none;
}

h1, h2, h3, h4, p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
img, svg { display: block; }
svg.i { flex-shrink: 0; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button, a, label, summary, input, select, textarea, [role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button { cursor: pointer; }
button:disabled { cursor: default; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

::selection { background: var(--primary-soft); }

/* ---------- 4. İskelet ---------- */
.app {
  position: relative;
  width: 100%;
  max-width: var(--maxw);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
}

/* Üst çubuk — yapışkan, buzlu cam, iOS "large title" */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) max(var(--gutter), env(safe-area-inset-right)) 10px max(var(--gutter), env(safe-area-inset-left));
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
}

.topbar-title {
  grid-column: 1;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-sub {
  grid-column: 1;
  margin-top: 2px;
  font-size: 13.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: -8px;
}

/* Kaydırılan içerik — altta tabbar + FAB için yer */
.view {
  padding: 12px max(var(--gutter), env(safe-area-inset-right)) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 56px + 40px) max(var(--gutter), env(safe-area-inset-left));
}

/* Alt sekme çubuğu */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: max(env(safe-area-inset-left), calc((100% - var(--maxw)) / 2));
  padding-right: max(env(safe-area-inset-right), calc((100% - var(--maxw)) / 2));
  background: var(--tabbar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--border);
}

.tabbar a.tab-link,
.tabbar .tab-link {
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 0 4px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: color 0.15s ease;
}

.tabbar .tab-link svg { width: 24px; height: 24px; }
.tabbar .tab-link.active { color: var(--primary); }
.tabbar .tab-link.active svg { stroke-width: 2.3; }
.tabbar .tab-link:active svg { transform: scale(0.9); }
.tabbar .tab-link svg { transition: transform 0.12s ease; }

/* Yüzen ekle butonu */
.fab {
  position: fixed;
  z-index: 45;
  right: max(var(--gutter), env(safe-area-inset-right), calc((100% - var(--maxw)) / 2 + var(--gutter)));
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: var(--fab-shadow);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.fab svg { width: 26px; height: 26px; stroke-width: 2.4; }
.fab:active { transform: scale(0.93); }

/* ---------- 5. Bölümler ve kartlar ---------- */
.date-strip {
  padding: 4px 4px 14px;
  color: var(--muted);
  font-size: 14.5px;
}
.date-strip strong,
.date-strip h2 {
  display: block;
  margin-bottom: 2px;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

.section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  margin-top: 26px;
}
.section > * { grid-column: 1 / -1; }
.section:first-child { margin-top: 6px; }

.section-title {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}
.section-title svg { width: 16px; height: 16px; }

.section > .section-action { grid-column: 2; }
.section-action {
  margin-left: auto;
  align-self: end;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  margin-bottom: 4px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
}
.section-action svg { width: 16px; height: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 12px; }
.card-pad { padding: 16px; }

.card-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 12px 16px;
  color: inherit;
}
.card-row > svg:first-child { color: var(--primary); }

/* iOS grouped list ayraçları — ardışık satırlar arasında içeriden başlayan ince çizgi */
:is(.card-row, .check-item, .reminder, .switch-row, .add-row) + :is(.card-row, .check-item, .reminder, .switch-row, .add-row)::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 1px;
  background: var(--border);
  pointer-events: none;
}
:is(.check-item, .reminder) + :is(.check-item, .reminder, .add-row)::before { left: 54px; }

/* ---------- 6. Hasta kartı ---------- */
.patient-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.12s ease, background-color 0.12s ease;
}
.patient-card + .patient-card { margin-top: 10px; }
.patient-card:active { transform: scale(0.985); background: var(--surface-2); }
.patient-card > svg:last-child { align-self: center; color: var(--border-strong); width: 18px; height: 18px; }

.bed-badge {
  flex-shrink: 0;
  min-width: 52px;
  height: 52px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}

.patient-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.patient-name {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.patient-meta {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.patient-main .progress { margin-top: 6px; }

/* Aşama çipi */
.stage-chip {
  --c-soft: var(--surface-2);
  --c-ink: var(--text-2);
  --c: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  align-self: flex-start;
  padding: 3px 9px 3px 8px;
  border-radius: 999px;
  background: var(--c-soft);
  color: var(--c-ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}
.stage-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c);
}
.stage-chip[data-stage="yatis"]    { --c: var(--st-yatis);    --c-soft: var(--st-yatis-soft);    --c-ink: var(--st-yatis-ink); }
.stage-chip[data-stage="hazirlik"] { --c: var(--st-hazirlik); --c-soft: var(--st-hazirlik-soft); --c-ink: var(--st-hazirlik-ink); }
.stage-chip[data-stage="opgunu"]   { --c: var(--st-opgunu);   --c-soft: var(--st-opgunu-soft);   --c-ink: var(--st-opgunu-ink); }
.stage-chip[data-stage="postop"]   { --c: var(--st-postop);   --c-soft: var(--st-postop-soft);   --c-ink: var(--st-postop-ink); }
.stage-chip[data-stage="taburcu"]  { --c: var(--st-taburcu);  --c-soft: var(--st-taburcu-soft);  --c-ink: var(--st-taburcu-ink); }

/* İlerleme çubuğu */
.progress {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: var(--p, 0%);
  max-width: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.35s var(--ease);
}

/* İşaret etiketleri */
.flag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
}
.flag svg { width: 12px; height: 12px; }
.flag.warn { background: var(--warn-soft); color: var(--warn); }
.flag.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- 7. Kontrol listesi ---------- */
.checklist {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card > .checklist,
.card-pad > .checklist {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.check-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 12px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: transform 0.12s ease, background-color 0.12s ease;
}
.check-item:active { background: var(--press); transform: scale(0.985); }
.check-item:active .check-box { transform: scale(0.9); }

.check-box {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  color: var(--primary-ink);
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
}
.check-box svg {
  width: 15px;
  height: 15px;
  stroke-width: 3.2;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.2s var(--ease);
}
:is(.check-item, .reminder).done .check-box {
  background: var(--primary);
  border-color: var(--primary);
}
:is(.check-item, .reminder).done .check-box svg {
  opacity: 1;
  transform: scale(1);
}

.check-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.check-text {
  font-size: 16px;
  line-height: 1.35;
  color: var(--text);
  overflow-wrap: anywhere;
  transition: color 0.15s ease;
}
.check-hint {
  font-size: 13px;
  overflow-wrap: anywhere;
  line-height: 1.35;
  color: var(--muted);
}
.check-meta {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.check-item > .check-meta { margin-left: auto; }

.check-item.done .check-text { color: var(--muted); }
.check-item.done .check-meta { color: var(--primary); }

/* uyarı maddesi: amber sol şerit */
.check-item.warn { box-shadow: inset 3px 0 0 var(--warn); }
.check-item.warn .check-hint { color: var(--warn); }
.check-item.warn:not(.done) .check-box { border-color: var(--warn); }

/* koşullu madde: hafif vurgulu */
.check-item.cond { background: var(--cond-bg); }
.check-item.cond .check-hint { color: var(--primary); font-weight: 500; }
.check-item.cond.warn .check-hint { color: var(--warn); }
.check-item.cond:active { background: var(--press); }

.check-del {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin: -6px -8px -6px auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.check-del svg { width: 16px; height: 16px; }
.check-del:active { background: var(--danger-soft); color: var(--danger); }

/* "+ madde ekle" satırı */
.add-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 6px 8px 6px 16px;
}
.add-row > svg:first-child { color: var(--primary); }
.add-row input,
.add-row .input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 8px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  font-size: 16px;
  color: var(--text);
}
.add-row input:focus,
.add-row .input:focus { box-shadow: none; border: 0; }
.add-row input::placeholder { color: var(--muted); }
.checklist > .add-row { background: var(--surface); }

/* ---------- 8. Butonlar ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background-color 0.15s ease;
}
.btn svg { width: 19px; height: 19px; }
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; transform: none; }

.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:active { background: var(--primary-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { min-height: 36px; padding: 0 13px; font-size: 14.5px; border-radius: 10px; gap: 6px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-block { display: flex; width: 100%; }

.icon-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.12s ease, transform 0.12s ease;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { background: var(--primary-soft); transform: scale(0.94); }

/* ---------- 9. Form ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field > label {
  padding-left: 2px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
}
:is(.field, .field-row, .switch-row, .seg) + :is(.field, .field-row) { margin-top: 14px; }

.input, .textarea, .select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px; /* iOS zoom engeli */
  line-height: 1.35;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.45;
}
.select {
  padding-right: 40px;
  background-image: var(--select-chev);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px 20px;
}

/* iOS tarih / saat girişleri */
input.input[type="date"],
input.input[type="time"],
input.input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 48px;
  height: 48px;
  text-align: left;
}
input.input[type="date"]::-webkit-date-and-time-value,
input.input[type="time"]::-webkit-date-and-time-value {
  text-align: left;
  margin: 0;
  min-height: 1.35em;
}
input.input[type="date"]::-webkit-calendar-picker-indicator,
input.input[type="time"]::-webkit-calendar-picker-indicator { opacity: 0.55; }

.field-hint {
  padding-left: 2px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}
.field-row > .field + .field { margin-top: 0; }

/* iOS anahtar satırı */
.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px;
  cursor: pointer;
}
.switch-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.switch-text strong { font-size: 16px; font-weight: 500; color: var(--text); }
.switch-text small { font-size: 13px; color: var(--muted); line-height: 1.35; }

input.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 51px;
  height: 31px;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: var(--switch-off);
  cursor: pointer;
  transition: background-color 0.2s ease;
}
input.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.22s var(--ease);
}
input.switch:checked { background: var(--primary); }
input.switch:checked::before { transform: translateX(20px); }
input.switch:active::before { width: 31px; }
input.switch:checked:active::before { transform: translateX(16px); }
input.switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input.switch:disabled { opacity: 0.5; }

/* Segment kontrol */
.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--seg-bg);
}
.seg > button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 38px;
  padding: 6px 4px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.seg > button[aria-pressed="true"] {
  background: var(--seg-on);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(0, 0, 0, 0.05);
}
.seg > button:active:not([aria-pressed="true"]) { background: var(--press); }

/* Sayfa içi sekmeler (yatay kaydırılır) */
.tabs {
  display: flex;
  gap: 8px;
  margin: 0 calc(-1 * var(--gutter));
  padding: 2px var(--gutter) 4px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: var(--gutter);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs > .tab,
.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  scroll-snap-align: start;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.tab svg { width: 16px; height: 16px; }
.tab[aria-selected="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}
.tab .count {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.tab[aria-selected="true"] .count {
  background: rgba(255, 255, 255, 0.22);
  color: inherit;
}

/* ---------- 10. Bilgi kutuları ---------- */
.callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.42;
}
.callout > svg { flex-shrink: 0; width: 20px; height: 20px; margin-top: 0; color: var(--muted); }
.callout strong { font-weight: 650; }
.callout + .callout { margin-top: 8px; }
.callout.info { background: var(--primary-soft); border-color: transparent; }
.callout.info > svg { color: var(--primary); }
.callout.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.callout.warn > svg { color: var(--warn); }
.callout.danger { background: var(--danger-soft); border-color: var(--danger-line); }
.callout.danger > svg { color: var(--danger); }
.callout.danger strong { color: var(--danger); }

/* NPO (yeme-içme yasağı) bandı */
.npo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: var(--text);
}
.npo + .npo { margin-top: 10px; }
.npo > svg { flex-shrink: 0; width: 26px; height: 26px; color: var(--warn); }
.npo-time {
  display: block;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--warn);
}
.npo-label {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--text-2);
}
.npo .btn, .npo .icon-btn { margin-left: auto; }
.npo.over { background: var(--ok-soft); border-color: var(--ok-line); }
.npo.over > svg, .npo.over .npo-time { color: var(--ok); }

/* ---------- 11. Saatli işler ---------- */
.reminder {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.12s ease, opacity 0.2s ease;
}
.reminder:active { background: var(--press); }
.reminder-time {
  flex-shrink: 0;
  min-width: 50px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.reminder-text {
  display: block;
  overflow-wrap: anywhere;
  font-size: 15.5px;
  line-height: 1.35;
  color: var(--text);
}
.reminder-sub {
  display: block;
  margin-top: 1px;
  overflow-wrap: anywhere;
  font-size: 12.5px;
  color: var(--muted);
}
.reminder > .check-box { margin-left: auto; }
.reminder.past .reminder-time { color: var(--warn); }
.reminder.done { opacity: 0.55; }
.reminder.done .reminder-time { color: var(--muted); }

/* ---------- 12. Özet sayıları ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 12px 11px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
}
.stat-num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-label {
  font-size: 12.5px;
  line-height: 1.25;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat:first-child .stat-num { color: var(--primary); }

/* ---------- 13. Boş durum ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px 36px;
  text-align: center;
}
.empty > svg {
  width: 64px;
  height: 64px;
  padding: 16px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  stroke-width: 1.8;
}
.empty h3 {
  font-size: 17px;
  font-weight: 650;
  color: var(--text);
}
.empty p {
  max-width: 300px;
  margin-top: 6px;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--muted);
}
.empty .btn { margin-top: 18px; }

/* ---------- 14. Alt panel (sheet) ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--backdrop);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.sheet-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.25s ease, visibility 0s;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  width: 100%;
  max-width: var(--maxw);
  max-height: 88vh;
  max-height: 88dvh;
  margin: 0 auto;
  padding: 6px var(--gutter) calc(env(safe-area-inset-bottom) + 18px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(105%);
  visibility: hidden;
  transition: transform 0.32s var(--ease), visibility 0s linear 0.32s;
}
.sheet.open,
.sheet-backdrop.open .sheet,
.sheet-backdrop.open + .sheet {
  transform: translateY(0);
  visibility: visible;
  transition: transform 0.32s var(--ease), visibility 0s;
}
.sheet-handle {
  width: 38px;
  height: 5px;
  margin: 4px auto 12px;
  border-radius: 999px;
  background: var(--border-strong);
}
.sheet-title {
  margin-bottom: 14px;
  font-size: 17px;
  font-weight: 650;
  text-align: center;
  color: var(--text);
}

/* ---------- 15. Bildirim ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 86px);
  z-index: 70;
  max-width: calc(100% - 2 * var(--gutter));
  width: max-content;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  box-shadow: var(--shadow-lg);
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.3;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 12px) scale(0.97);
  transition: opacity 0.22s ease, transform 0.28s var(--ease), visibility 0s linear 0.28s;
}
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) scale(1);
  transition: opacity 0.22s ease, transform 0.28s var(--ease), visibility 0s;
}

/* ---------- 16. Rehber akordeonu ---------- */
details.guide-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
details.guide-card + details.guide-card { margin-top: 10px; }

details.guide-card > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 12px 14px 12px 14px;
  list-style: none;
  font-size: 16.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color 0.12s ease;
}
details.guide-card > summary::-webkit-details-marker { display: none; }
details.guide-card > summary::marker { content: ""; }
details.guide-card > summary:active { background: var(--press); }
details.guide-card > summary > svg:not(.chev) {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 7px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}
details.guide-card .chev {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.25s var(--ease);
}
details.guide-card[open] .chev { transform: rotate(180deg); }
details.guide-card[open] > summary { border-bottom: 1px solid var(--border); }

.guide-body {
  padding: 14px 16px 16px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-2);
}
.guide-body > * + * { margin-top: 10px; }
.guide-body p { margin: 0; }
.guide-body > * + p, .guide-body > p + * { margin-top: 10px; }
.guide-body ul, .guide-body ol { margin: 0; padding-left: 20px; }
.guide-body li + li { margin-top: 4px; }
.guide-body li::marker { color: var(--primary); }
.guide-body strong { color: var(--text); }

/* Anahtar-değer satırları */
.kv {
  display: flex;
  flex-direction: column;
}
.kv > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}
.kv > div + div { border-top: 1px solid var(--border); }
.kv > div > span { color: var(--muted); font-size: 14.5px; }
.kv > div > strong {
  color: var(--text);
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.card-pad > .kv > div:first-child { padding-top: 0; }
.card-pad > .kv > div:last-child { padding-bottom: 0; }

/* ---------- 17. Yardımcılar ---------- */
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.4; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > :is(.field, .field-row, .card, .patient-card, .npo, .callout, details.guide-card) { margin-top: 0; }
.row { display: flex; flex-direction: row; align-items: center; gap: 8px; min-width: 0; }
.spacer { flex: 1 1 auto; min-width: 0; }
/* Hasta detayı üst kartında tam ad görünsün (kartlarda tek satır + … kalır) */
.spacer > .patient-name { white-space: normal; overflow-wrap: anywhere; }
.mt { margin-top: 16px; }
.hidden { display: none !important; }

/* ---------- 18. Geniş ekran ---------- */
@media (min-width: 600px) {
  .view { padding-top: 16px; }
}

/* ---------- 19. Hareket azaltma ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
  .check-item:active, .patient-card:active, .btn:active, .fab:active,
  .icon-btn:active, .check-item:active .check-box { transform: none; }
}
