/* Potansiyel Santral Takip — mobil arayüz. Açık / koyu tema telefon ayarına göre. */
:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F0F2F5;
  --border: #E1E4E8;
  --text: #1C2026;
  --text-2: #5E6670;
  --text-3: #8A929C;
  --brand: #E3851D;
  --brand-ink: #B4620A;
  --brand-soft: #FDF0E1;
  --ok: #2E9E4F;
  --ok-soft: #E3F4E8;
  --bad: #C62828;
  --bad-soft: #FBE6E6;
  --warn: #B7791F;
  --warn-soft: #FDF3DC;
  --idle: #8A929C;
  --idle-soft: #EDEFF2;
  --water: #2F7FD1;
  --water-2: #6FB0F0;
  --t-blue: #2F7FD1;
  --t-yellow: #B7871A;
  --t-red: #C62828;
  --shadow: 0 1px 2px rgba(20, 24, 30, .06), 0 2px 8px rgba(20, 24, 30, .05);
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1A1E24;
    --surface-2: #222830;
    --border: #2C333C;
    --text: #E8EBEF;
    --text-2: #A9B1BB;
    --text-3: #7D8691;
    --brand: #F0973A;
    --brand-ink: #F6B26B;
    --brand-soft: #3A2A18;
    --ok: #4CC170;
    --ok-soft: #173322;
    --bad: #F0605A;
    --bad-soft: #3A1C1C;
    --warn: #E7B44C;
    --warn-soft: #3A2F16;
    --idle: #8D96A1;
    --idle-soft: #262C34;
    --water: #4E9BE8;
    --water-2: #7DBBF5;
    --t-blue: #64A9F0;
    --t-yellow: #E9C24A;
    --t-red: #F0605A;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ── Üst çubuk ── */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.logo { width: 30px; height: 30px; border-radius: 7px; }
.title-block { flex: 1; min-width: 0; }
.top h1 { margin: 0; font-size: 17px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtitle { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; margin: -4px;
  border: 0; background: none; border-radius: 10px; color: var(--text-2); cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

/* ── Ana alan ── */
main { padding: 14px 16px calc(84px + var(--safe-b)); max-width: 720px; margin: 0 auto; }
.section-title { margin: 20px 4px 8px; font-size: 13px; font-weight: 650; letter-spacing: .02em; text-transform: uppercase; color: var(--text-3); }
.section-title:first-child { margin-top: 4px; }
.muted { color: var(--text-3); }
.empty { padding: 28px 12px; text-align: center; color: var(--text-3); }
.error-box { margin: 8px 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}
a.card { display: block; }
a.card:active { background: var(--surface-2); }

/* ── Santral kartı ── */
.plant-head { display: flex; align-items: center; gap: 8px; }
.plant-head h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 650; }
.chev { color: var(--text-3); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--idle); flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 8px; margin-top: 12px; }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.kpi .k { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v { font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v.brand { color: var(--brand); }
.kpi .v.bad { color: var(--bad); }
.kpi .v.ok { color: var(--ok); }
.unit-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ── Durum etiketleri ── */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--idle-soft); color: var(--idle); white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.brand { background: var(--brand-soft); color: var(--brand-ink); }
.pill .pw { font-weight: 500; opacity: .85; }

/* ── Ünite kartı ── */
.unit-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.unit-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.unit-head .right { margin-left: auto; font-size: 13px; color: var(--text-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.row .l { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r { font-weight: 600; white-space: nowrap; }
.big-power { font-size: 26px; font-weight: 700; color: var(--ok); }
.big-power.idle { color: var(--text-3); }
.t-blue { color: var(--t-blue); }
.t-yellow { color: var(--t-yellow); }
.t-red { color: var(--t-red); }
.alarm-list { margin: 10px 0 0; padding: 0; list-style: none; }
.alarm-list li { display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; border-radius: 9px; margin-top: 6px; background: var(--bad-soft); color: var(--bad); font-size: 13.5px; }
.alarm-list li.warn { background: var(--warn-soft); color: var(--warn); }
.alarm-list li small { display: block; color: var(--text-3); font-size: 12px; }

/* ── Seviye / basınç göstergesi ── */
.gauge { display: flex; gap: 14px; align-items: stretch; }
.tank { position: relative; width: 74px; flex: none; height: 170px; border-radius: 10px; background: var(--surface-2); border: 2px solid var(--border); overflow: hidden; }
.tank .water { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, var(--water-2), var(--water)); transition: height .6s ease; }
.tank .mark { position: absolute; left: -2px; right: -2px; border-top: 2px dashed; }
.tank .mark.start { border-color: var(--ok); }
.tank .mark.stop { border-color: var(--bad); }
.gauge-info { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.gauge-info .now { font-size: 30px; font-weight: 700; }
.gauge-info .row { border: 0; padding: 2px 0; }
.legend-ok { color: var(--ok); }
.legend-bad { color: var(--bad); }

/* ── Seçiciler ── */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.daybar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.daybar .day { flex: 1; text-align: center; font-weight: 650; }
.nav-btn {
  width: 40px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; display: grid; place-items: center;
}
.nav-btn:disabled { opacity: .35; }

/* ── Bölüm seçici (Günlük / Aylık, Genel / Trend / Kontrol) ── */
.seg { display: flex; gap: 4px; padding: 3px; margin-bottom: 12px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { flex: 1; padding: 8px 6px; border: 0; border-radius: 8px; background: none; color: var(--text-2); font-size: 14px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

.seg.links a { flex: 1; text-align: center; padding: 8px 6px; border-radius: 8px; color: var(--text-2); font-size: 14px; font-weight: 600; }
.seg.links a.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

/* ── Sahne ── */
.scene-card { padding: 10px 12px; }
.scene-unit + .scene-unit { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.scene-title { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 14px; }
.scene { width: 100%; height: auto; display: block; margin-top: 4px; }
.scene text { fill: var(--text-3); font-size: 9.5px; }
.scene .pipe { fill: var(--surface-2); stroke: var(--border); }
.scene .pipe.water { fill: var(--water-2); stroke: var(--water); }
.scene .flow { fill: var(--water); opacity: .55; animation: flow 1.4s linear infinite; }
.ytbs .row .l { white-space: normal; }
.ytbs .prob { margin-top: 8px; font-size: 12.5px; color: var(--bad); }
@keyframes flow { 0% { opacity: .35; } 50% { opacity: .75; } 100% { opacity: .35; } }
.scene .valve { stroke-width: 2.5; fill: var(--surface); }
.scene .valve.on { stroke: var(--ok); } .scene .valve.off { stroke: var(--bad); } .scene .valve.unk { stroke: var(--idle); }
.scene .valve-disc { stroke: var(--text-2); stroke-width: 3; stroke-linecap: round; }
.scene .turbine { fill: var(--surface-2); stroke-width: 2.5; }
.scene .turbine.on { stroke: var(--water); } .scene .turbine.off { stroke: var(--idle); }
.scene .blade { fill: var(--text-3); }
.scene .turbine.on ~ g .blade, .scene .spin .blade { fill: var(--water); }
.scene .hub { fill: var(--text-2); }
.scene .spin { animation: spin 1.2s linear infinite; transform-box: fill-box; transform-origin: center; }
.scene .shaft { stroke-width: 4; } .scene .shaft.on { stroke: var(--ok); } .scene .shaft.off { stroke: var(--idle); }
.scene .gen { fill: var(--surface-2); stroke-width: 3; }
.scene .gen.on { stroke: var(--ok); fill: var(--ok-soft); } .scene .gen.warm { stroke: var(--brand); } .scene .gen.off { stroke: var(--idle); }
.scene .g { fill: var(--text); font-size: 17px; font-weight: 700; }
.scene .bus { stroke-width: 3; } .scene .bus.on { stroke: var(--ok); } .scene .bus.off { stroke: var(--idle); }
.scene .cb { stroke-width: 2.5; }
.scene .cb.closed { fill: var(--bad); stroke: var(--bad); } .scene .cb.open { fill: var(--ok); stroke: var(--ok); } .scene .cb.unk { fill: var(--surface-2); stroke: var(--idle); }
.scene .grid-sym { fill: none; stroke-width: 3; stroke-linecap: round; } .scene .grid-sym.on { stroke: var(--ok); } .scene .grid-sym.off { stroke: var(--idle); }

/* ── Trend ── */
.chart .tline { fill: none; stroke-width: 1.8; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart .ref { stroke: var(--text-3); stroke-dasharray: 4 3; stroke-width: 1; }
.chart .ref-t { fill: var(--text-3); font-size: 9.5px; }
.chart-legend.wrap { flex-wrap: wrap; gap: 6px 14px; }

/* ── Kontrol ── */
.info-box { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-ink); font-size: 13.5px; }
.cmd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cmd-b, .cmd-sp { min-width: 0; }
.cmd-sub { display: flex; align-items: center; gap: 8px; margin: 12px 0 8px; font-weight: 650; font-size: 14px; color: var(--text-2); }
.cmd-sub:first-child { margin-top: 0; }
.cmd-sp { grid-column: 1 / -1; padding: 8px 0; border-top: 1px solid var(--border); }
.cmd-sp .l { font-size: 14px; font-weight: 600; }
.cmd-sp .l small { display: block; font-weight: 400; color: var(--text-3); font-size: 12px; }
.cmd-sp .r { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.cmd-sp .now { min-width: 64px; font-weight: 650; }
.cmd-sp input { flex: 1; min-width: 0; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); font-size: 16px; }
.btn { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 650; font-size: 14px; cursor: pointer; }
.btn:disabled { opacity: .45; }
.btn.cmd { width: 100%; min-height: 48px; }
.btn.cmd.go { border-color: var(--ok); color: var(--ok); }
.btn.cmd.danger { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.btn.cmd.active { background: var(--ok); border-color: var(--ok); color: #fff; }
.cmd-state { font-size: 12px; margin-top: 4px; color: var(--text-3); }
.cmd-state.ok { color: var(--ok); } .cmd-state.bad { color: var(--bad); }

/* ── Üretim ve taahhüt ── */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.kpi.tall { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 10px 12px; }
.kpi.tall .v { font-size: 17px; }
.kpi .s { font-size: 11.5px; color: var(--text-3); margin-top: 2px; line-height: 1.3; }
.tbl-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; -webkit-overflow-scrolling: touch; }
.tbl { border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.tbl th, .tbl td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--border); }
.tbl th { font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .02em; }
.tbl th:first-child, .tbl td.l { text-align: left; position: sticky; left: 0; background: var(--surface); }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.tbl td.ok { color: var(--ok); }
.tbl td.bad { color: var(--bad); }
.tbl td.warn { color: var(--warn); }
.note { font-size: 11.5px; margin-top: 10px; line-height: 1.4; }

/* ── Grafik ── */
.chart { width: 100%; height: 190px; display: block; }
.chart text { fill: var(--text-3); font-size: 10px; }
.chart .bar { fill: var(--brand); }
.chart .bar.partial { fill: var(--brand); opacity: .45; }
.chart .plan { stroke: var(--text); stroke-width: 2; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-3); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--brand); }
.chart-legend i.line { height: 2px; vertical-align: 3px; background: var(--text); }

/* ── Uyarı bandı (ESD / QSD / haberleşme / havuz) ── */
.banner { position: sticky; top: calc(59px + var(--safe-t)); z-index: 15; padding: 8px 16px 0; background: var(--bg); }
.trip {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; margin-bottom: 8px;
  background: var(--bad); color: #fff; box-shadow: var(--shadow);
}
.trip.cleared { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.trip .what { flex: 1; min-width: 0; font-size: 14px; }
.trip .what b { display: block; font-size: 14.5px; }
.trip .what span { opacity: .9; font-size: 12.5px; }
.trip button {
  flex: none; border: 0; border-radius: 9px; padding: 8px 12px; font-weight: 650; cursor: pointer;
  background: rgba(255, 255, 255, .22); color: inherit;
}
.trip.cleared button { background: var(--surface-2); }

/* ── Alt sekmeler ── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(6px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabs a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--text-3); font-size: 11.5px; font-weight: 600; }
.tabs a svg { width: 24px; height: 24px; }
.tabs a.on { color: var(--brand); }
.badge {
  position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

/* ── Giriş ── */
.login { max-width: 380px; margin: 8vh auto 0; }
.login .brand-head { text-align: center; margin-bottom: 22px; }
.login .brand-head img { width: 72px; height: 72px; border-radius: 16px; box-shadow: var(--shadow); }
.login .brand-head h2 { margin: 12px 0 2px; font-size: 22px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 12px 13px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); font-size: 16px; outline: none;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.primary {
  width: 100%; padding: 13px; border: 0; border-radius: 12px; background: var(--brand); color: #fff;
  font-size: 16px; font-weight: 650; cursor: pointer;
}
.primary:disabled { opacity: .6; }

/* ── Menü (alt sayfa) ── */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; }
.sheet .panel {
  width: 100%; max-width: 720px; margin: 0 auto; background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(16px + var(--safe-b));
}
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 12px; }
.sheet .item { display: block; width: 100%; text-align: left; padding: 14px 6px; border: 0; background: none; border-bottom: 1px solid var(--border); font-size: 15.5px; cursor: pointer; }
.sheet .item:last-child { border-bottom: 0; }
.sheet .item.danger { color: var(--bad); }
.sheet .who { padding: 4px 6px 10px; font-size: 13px; color: var(--text-3); }

.spinner { width: 26px; height: 26px; margin: 40px auto; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } .tank .water { transition: none; } }
