:root {
  color-scheme: light;
  --bg: #f5f0f1; --surface: #fdfbfc; --surface-2: #f6f1f2; --border: #e7dde0;
  --text: #140d10; --text-2: #5a5053; --muted: #837a7d;
  --series: #c2366b; --accent: #b02a5e; --on-accent: #ffffff;
  --good: #1a7a48; --warn: #9a6200; --crit: #c0392b;
  --good-bg: #e3f3ea; --warn-bg: #fbf0d9; --crit-bg: #fbe6e3;
  --grid: #eae0e3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #161113; --surface: #1f181b; --surface-2: #282024; --border: #372c31;
    --text: #ffffff; --text-2: #cdbfc5; --muted: #968a8f;
    --series: #e05585; --accent: #e05585; --on-accent: #ffffff;
    --good: #4cc38a; --warn: #e2a336; --crit: #f07b6e;
    --good-bg: #12301f; --warn-bg: #33270e; --crit-bg: #3a1a16;
    --grid: #2f262a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161113; --surface: #1f181b; --surface-2: #282024; --border: #372c31;
  --text: #ffffff; --text-2: #cdbfc5; --muted: #968a8f;
  --series: #e05585; --accent: #e05585; --on-accent: #ffffff;
  --good: #4cc38a; --warn: #e2a336; --crit: #f07b6e;
  --good-bg: #12301f; --warn-bg: #33270e; --crit-bg: #3a1a16;
  --grid: #2f262a;
}

* { 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", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
html, body { max-width: 100%; overflow-x: clip; }
h1, h2, h3, p { margin: 0; overflow-wrap: anywhere; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 48px 16px; color: var(--muted); text-align: center; }

.shell { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 92px); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.top > div:first-child { min-width: 0; flex: 1 1 auto; }
.top h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.top .sub { color: var(--text-2); font-size: 14px; }
.datenav { display: flex; align-items: center; gap: 4px; flex: none; }
.datenav button { min-height: 40px; border-radius: 12px; padding: 0 10px; white-space: nowrap; }
.datenav button.icon { width: 40px; padding: 0; font-size: 20px; }

.card { min-width: 0; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.card h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); margin-bottom: 10px; }
.card h3 { font-size: 17px; font-weight: 650; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.sec { color: var(--text-2); }

button { border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 0 14px; min-height: 44px; cursor: pointer; font-weight: 550; white-space: nowrap; }
button:active { transform: scale(0.98); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.ghost { background: transparent; }
button.danger { color: var(--crit); }
button.block { width: 100%; }
button:disabled { opacity: 0.55; }
button.icon { width: 44px; padding: 0; }
button.small { min-height: 34px; font-size: 13.5px; padding: 0 10px; }

input, select, textarea { width: 100%; min-width: 0; max-width: 100%; min-height: 44px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); padding: 8px 12px; font-size: 16px; }
/* iOS Safari tarih/saat alanlarına kendi genişliğini dayatır; sıfırlamazsak ızgaradan taşar. */
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; display: block; text-align: left; padding: 8px 10px; }
input[type="date"]::-webkit-date-and-time-value, input[type="time"]::-webkit-date-and-time-value { text-align: left; }
textarea { min-height: 72px; resize: vertical; }
input[type="range"] { padding: 0; min-height: 32px; accent-color: var(--accent); border: 0; background: transparent; }
input:focus-visible, button:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: grid; gap: 4px; font-size: 13.5px; color: var(--text-2); }
label .lv { display: flex; justify-content: space-between; }
.grid2 > *, .grid3 > *, .grid4 > *, .tiles > *, .estnums > *, .setrow > *, .row > *, .stack > *, .chips > * { min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }

.banner { border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; font-weight: 550; border: 1px solid transparent; }
.banner.good { background: var(--good-bg); color: var(--good); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.crit { background: var(--crit-bg); color: var(--crit); }
.banner small { display: block; font-weight: 400; color: var(--text-2); margin-top: 2px; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.tile .k { font-size: 12.5px; color: var(--text-2); }
.tile .v { overflow-wrap: normal; white-space: nowrap; font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tile .d { font-size: 12.5px; color: var(--muted); }

.meter { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; position: relative; }
.meter > i { display: block; height: 100%; background: var(--series); border-radius: 6px; }
.meter > b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-2); }

.chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 6px; }
.chip { min-height: 40px; border-radius: 20px; padding: 0 2px; background: var(--surface); font-size: 14.5px; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-left: 6px; vertical-align: middle; opacity: 0.7; }

.ex { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.ex:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.ex .target { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ex .last { font-size: 13.5px; color: var(--text-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.ex .hint { font-size: 13.5px; color: var(--good); margin-top: 2px; font-weight: 550; }
.sets { display: grid; gap: 8px; margin-top: 10px; }
.setrow { display: grid; grid-template-columns: 22px minmax(0, 1fr) 12px minmax(0, 1fr) 36px; align-items: center; gap: 8px; }
.setrow.nokg { grid-template-columns: 22px minmax(0, 1fr) 36px; }
.setrow .n { color: var(--muted); font-size: 13.5px; text-align: center; }
.setrow input { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.setrow .x { color: var(--muted); text-align: center; }
.setrow input.sug { color: var(--muted); font-weight: 500; border-style: dashed; }
.setrow .ok { width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 50%; border: 1.5px solid var(--border); background: transparent; color: var(--muted); font-weight: 700; }
.setrow .ok[aria-pressed="true"] { border-color: var(--good); background: var(--good-bg); color: var(--good); }
.unit { position: relative; }
.unit input { padding-right: 36px; }
.unit::after { content: attr(data-u); position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12.5px; pointer-events: none; }
details { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 8px; }
details summary { cursor: pointer; color: var(--text-2); font-size: 14px; min-height: 32px; display: flex; align-items: center; }
details p, details li { font-size: 14.5px; color: var(--text-2); }
details ul { margin: 6px 0 0; padding-left: 20px; }
details.plain { border: 0; margin: 0; padding: 0; }

.list { display: grid; gap: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .name { overflow-wrap: anywhere; }
.item .nums { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13.5px; }
.item .ok { width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 50%; border: 1.5px solid var(--border); background: transparent; color: var(--muted); font-weight: 700; flex: none; }
.item .ok[aria-pressed="true"] { border-color: var(--good); background: var(--good-bg); color: var(--good); }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.when { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; margin-bottom: 12px; }
input.mtime { width: 92px; flex: none; padding: 0 6px; text-align: center; font-variant-numeric: tabular-nums; }
.thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.preview { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12.5px; padding: 6px 4px; border-bottom: 1px solid var(--border); }
td { padding: 8px 4px; border-bottom: 1px solid var(--border); }
td.r, th.r { text-align: right; }
.scroll { overflow-x: auto; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart .tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); border-radius: 8px; padding: 4px 8px; font-size: 12.5px; white-space: nowrap; transform: translate(-50%, -130%); font-variant-numeric: tabular-nums; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .axis { stroke: var(--grid); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.alt { stroke: var(--warn); }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .bar { fill: var(--series); }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .target { stroke: var(--text-2); stroke-width: 1; }

nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); z-index: 10; }
nav.tabs .in { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; }
nav.tabs button { border: 0; background: transparent; min-height: 52px; padding: 4px 0; border-radius: 12px; font-size: 11.5px; font-weight: 550; color: var(--muted); display: grid; justify-items: center; gap: 2px; }
nav.tabs button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav.tabs button[aria-current="page"] { color: var(--accent); }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14.5px; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 30; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; }

.auth { max-width: 380px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 72px) 20px 40px; }
.auth h1 { font-size: 28px; margin-bottom: 4px; }
.auth form { display: grid; gap: 12px; margin-top: 24px; }
.err { color: var(--crit); font-size: 14.5px; }
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: sp 0.8s linear infinite; vertical-align: -3px; margin-right: 8px; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } button:active { transform: none; } }

.est { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.est:last-child { border-bottom: 0; padding-bottom: 0; }
.estnums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 44px; gap: 8px; align-items: end; }
.estnums input { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Dar telefonlar: daha sıkı boşluk */
@media (max-width: 380px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .card { padding: 14px 12px; }
  .top h1 { font-size: 20px; }
  .tile { padding: 8px 8px; }
  .tile .v { font-size: 18px; }
  .chip { font-size: 13.5px; }
  nav.tabs button { font-size: 10.5px; }
}

/* sohbet */
.chatlog { display: grid; gap: 8px; margin-top: 12px; }
.msg { max-width: 86%; padding: 10px 12px; border-radius: 16px; line-height: 1.45; overflow-wrap: anywhere; }
.msg span { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.msg.user { justify-self: end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; }
.msg.user span { color: color-mix(in srgb, var(--on-accent) 75%, transparent); }
.msg.assistant { justify-self: start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.msg.typing { color: var(--muted); }
.msg .acts { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--good); font-weight: 550; display: grid; gap: 2px; }
.chatbox { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; margin-top: 12px; }
.chatbox textarea { min-height: 48px; max-height: 160px; resize: vertical; }
.chatbox.att { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 6px; }
[data-attach] svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.thumbs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.thumbs:empty { display: none; }
.thumbs .th { position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs .icon { position: absolute; top: 4px; right: 4px; width: 28px; min-height: 28px; height: 28px; border-radius: 50%; font-size: 13px; background: color-mix(in srgb, var(--surface) 85%, transparent); }
.mimgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 4px; margin: -2px -4px 8px; }
.mimgs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; }
.evdate { width: 44px; flex: none; text-align: center; font-size: 12px; color: var(--text-2); text-transform: uppercase; line-height: 1.15; }
.evdate b { display: block; font-size: 20px; color: var(--text); text-transform: none; }
.big { font-size: 28px; font-variant-numeric: tabular-nums; margin-top: 2px; }
