/* Bahçe — sulama kontrol paneli.
   Yön: bahçe aleti / enstrüman paneli. Koyu ıslak-toprak zemin, su rengi tek vurgu,
   ortada gerçek zamanlı boşalan bir gösterge halkası. Güneş altında okunabilirlik önce gelir. */

:root {
  --soil-900: #0b100e;
  --soil-850: #0e1412;
  --soil-800: #121a17;
  --soil-750: #16201c;
  --line:     rgba(150, 195, 172, .13);
  --line-2:   rgba(150, 195, 172, .26);

  --water:    #3ad3cf;
  --water-hi: #7ff0e4;
  --leaf:     #86c46e;
  --amber:    #e6a340;
  --rose:     #ef5350;

  --text:     #e9f2ec;
  --text-dim: #9db0a6;
  --text-mut: #6c8378;

  --flow-a: var(--water);
  --flow-b: var(--water-hi);

  --font-ui: "Avenir Next", "Segoe UI Variable Text", "Noto Sans", "Helvetica Neue", system-ui, sans-serif;
  --font-mech: ui-monospace, "SF Mono", SFMono-Regular, "Roboto Mono", "DejaVu Sans Mono", Menlo, monospace;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --pad: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(120% 80% at 50% -10%, #16211d 0%, transparent 60%),
    radial-gradient(90% 60% at 50% 108%, #0f1a17 0%, transparent 55%),
    var(--soil-900);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

/* İnce kum dokusu — düz zemin yerine atmosfer */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .32;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.view { position: relative; z-index: 1; }
[hidden] { display: none !important; }

.page {
  max-width: 470px;
  margin: 0 auto;
  padding: 4px var(--pad) calc(40px + var(--safe-b));
}

/* ─────────── üst çubuk ─────────── */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  max-width: 470px; margin: 0 auto;
  padding: calc(12px + var(--safe-t)) var(--pad) 12px;
  background: linear-gradient(var(--soil-900) 62%, transparent);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__brand h1 {
  margin: 0;
  font-family: var(--font-mech);
  font-size: 15px; font-weight: 600; letter-spacing: .26em;
}
/* Marka noktası bağlantı durumunu yansıtır — sabit yeşil yanıltıcı olurdu. */
.topbar__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-mut);
  box-shadow: 0 0 0 3px rgba(150, 195, 172, .1);
  transition: background .3s, box-shadow .3s;
}
.topbar__dot--online  { background: var(--leaf);  box-shadow: 0 0 0 3px rgba(134, 196, 110, .16); }
.topbar__dot--offline { background: var(--amber); box-shadow: 0 0 0 3px rgba(230, 163, 64, .16); }
.topbar__nav { display: flex; gap: 6px; }

.iconbtn {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  color: var(--text-dim);
  text-decoration: none;
  transition: color .18s, background .18s, border-color .18s;
}
.iconbtn:hover { color: var(--text); }
.iconbtn[aria-current="page"] {
  color: var(--water);
  background: rgba(58, 211, 207, .08);
  border-color: rgba(58, 211, 207, .22);
}

/* ─────────── bağlantı şeridi ─────────── */
.conn {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soil-800);
  font-family: var(--font-mech);
  font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-dim);
  width: fit-content; margin: 0 auto 26px;
  animation: rise .5s .05s both;
}
.conn__led {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-mut);
  flex: none;
}
.conn__label { color: var(--text-mut); }
.conn--online  { border-color: rgba(134, 196, 110, .3); }
.conn--online  .conn__led { background: var(--leaf); box-shadow: 0 0 8px rgba(134, 196, 110, .8); animation: breathe 3.2s ease-in-out infinite; }
.conn--online  .conn__text { color: var(--leaf); }
.conn--offline { border-color: rgba(230, 163, 64, .32); }
.conn--offline .conn__led { background: var(--amber); box-shadow: 0 0 8px rgba(230, 163, 64, .7); }
.conn--offline .conn__text { color: var(--amber); }

/* ─────────── gösterge ─────────── */
.gauge {
  position: relative;
  width: min(280px, 74vw);
  aspect-ratio: 1;
  margin: 0 auto 26px;
  animation: rise .55s .12s both;
}
.gauge__svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.gauge__track {
  fill: none; stroke: var(--line); stroke-width: 10;
}
.gauge__fill {
  fill: none;
  stroke: url(#flow);
  stroke-width: 10;
  stroke-linecap: round;
  --circ: 703.72;              /* 2πr, r=112 */
  --p: 0;                      /* 0..1 dolu oran */
  stroke-dasharray: var(--circ);
  stroke-dashoffset: calc(var(--circ) * (1 - var(--p)));
  transition: stroke-dashoffset .28s linear, opacity .3s;
  opacity: 0;
  filter: drop-shadow(0 0 10px rgba(58, 211, 207, .45));
}

.gauge__inner {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-align: center;
  pointer-events: none;
}
.gauge__eyebrow {
  font-family: var(--font-mech);
  font-size: 11px; letter-spacing: .3em; color: var(--text-mut);
}
.gauge__state {
  font-family: var(--font-mech);
  font-size: clamp(30px, 9.5vw, 40px);
  font-weight: 700; letter-spacing: .06em;
  line-height: 1.1;
  transition: color .25s;
}
.gauge__meta { display: flex; flex-direction: column; align-items: center; margin-top: 14px; }
.gauge__remaining {
  font-family: var(--font-mech);
  font-size: 46px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--water-hi);
}
.gauge__unit { font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-mut); margin-top: 4px; }
.gauge__total { font-size: 11.5px; color: var(--text-mut); margin-top: 7px; font-family: var(--font-mech); }

/* durum renkleri */
.gauge--closed  .gauge__state { color: var(--text); }
.gauge--open    .gauge__state { color: var(--water); }
.gauge--open    .gauge__fill  { opacity: 1; }
.gauge--unknown .gauge__state { color: var(--amber); font-size: clamp(20px, 6.2vw, 26px); }
.gauge--unknown .gauge__track { stroke: rgba(230, 163, 64, .22); stroke-dasharray: 5 9; }

/* su kabarcıkları — yalnız sulama sırasında, okumayı bozmayacak kadar silik ve metnin ARKASINDA */
.gauge__bubbles {
  position: absolute; inset: 14%; z-index: 1;
  overflow: hidden; border-radius: 50%;
  opacity: 0; transition: opacity .4s;
}
.gauge--open .gauge__bubbles { opacity: .4; }
.gauge__bubbles i {
  position: absolute; bottom: -10px;
  width: 5px; height: 5px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--water-hi), rgba(58, 211, 207, .1));
  animation: bubble 5.4s linear infinite;
}
.gauge__bubbles i:nth-child(1) { left: 18%; animation-delay: 0s;   transform: scale(.7); }
.gauge__bubbles i:nth-child(2) { left: 34%; animation-delay: .9s;  transform: scale(1.1); }
.gauge__bubbles i:nth-child(3) { left: 50%; animation-delay: 1.7s; transform: scale(.8); }
.gauge__bubbles i:nth-child(4) { left: 66%; animation-delay: 2.4s; transform: scale(1); }
.gauge__bubbles i:nth-child(5) { left: 80%; animation-delay: 3.2s; transform: scale(.65); }
.gauge__bubbles i:nth-child(6) { left: 26%; animation-delay: 3.8s; transform: scale(.9); }

/* ─────────── uyarı şeridi ─────────── */
.banner {
  margin: 0 0 20px;
  padding: 12px 14px;
  border: 1px solid rgba(230, 163, 64, .3);
  border-left-width: 3px;
  border-radius: var(--r-sm);
  background: rgba(230, 163, 64, .07);
  color: #f0c583;
  font-size: 14px;
  animation: rise .3s both;
}
.banner--error { border-color: rgba(239, 83, 80, .35); background: rgba(239, 83, 80, .08); color: #ffb3b0; }
.banner--ok { border-color: rgba(134, 196, 110, .35); background: rgba(134, 196, 110, .08); color: #bfe4a9; }

/* ─────────── süre bloğu ─────────── */
.block { animation: rise .55s .2s both; }
.block__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.block__title { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim); font-family: var(--font-mech); }
.block__hint { font-size: 13px; color: var(--water); font-family: var(--font-mech); }

.stepper {
  display: flex; align-items: center; gap: 4px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--soil-800);
  padding: 6px;
}
.stepper__btn {
  flex: none;
  width: 46px; height: 46px;
  border: 0; border-radius: var(--r-sm);
  background: var(--soil-750);
  color: var(--text);
  font-size: 23px; line-height: 1;
  cursor: pointer;
  transition: background .15s, transform .08s;
}
.stepper__btn:active { transform: scale(.93); background: #1d2a25; }
.stepper__input {
  flex: 1; min-width: 0;
  border: 0; background: transparent;
  color: var(--text);
  font-family: var(--font-mech);
  font-size: 30px; font-weight: 700; text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  padding: 0;
}
.stepper__input::-webkit-outer-spin-button,
.stepper__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper__input:focus { outline: none; }
.stepper:focus-within { border-color: rgba(58, 211, 207, .45); }
.stepper__unit { font-family: var(--font-mech); font-size: 13px; color: var(--text-mut); padding-right: 4px; }

.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  flex: 1 1 auto;
  min-width: 68px;
  padding: 11px 4px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mech);
  font-size: 13px;
  cursor: pointer;
  transition: all .16s;
}
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] {
  border-color: rgba(58, 211, 207, .5);
  background: rgba(58, 211, 207, .1);
  color: var(--water-hi);
}

/* ─────────── düğmeler ─────────── */
.actions { display: flex; flex-direction: column; gap: 11px; margin-top: 24px; animation: rise .55s .28s both; }
.actions--stack { margin-top: 20px; }

.btn {
  position: relative;
  width: 100%;
  padding: 15px 18px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--soil-800);
  color: var(--text);
  font-family: var(--font-mech);
  font-size: 14px; letter-spacing: .14em; font-weight: 600;
  cursor: pointer;
  transition: transform .09s, opacity .2s, background .2s, border-color .2s, box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: scale(.985); }
.btn:disabled { opacity: .34; cursor: not-allowed; }

.btn--lg { padding: 20px 18px; font-size: 17px; letter-spacing: .2em; }

.btn--primary {
  border-color: transparent;
  background: linear-gradient(168deg, var(--water) 0%, #1fa9ae 100%);
  color: #04211f;
  box-shadow: 0 8px 26px -12px rgba(58, 211, 207, .85), inset 0 1px 0 rgba(255,255,255,.28);
}
.btn--primary:disabled { box-shadow: none; }

.btn--stop {
  border-color: rgba(239, 83, 80, .38);
  background: rgba(239, 83, 80, .1);
  color: #ff9b98;
}
.btn--stop.btn--armed {
  border-color: transparent;
  background: linear-gradient(168deg, #f4635f 0%, #c2352f 100%);
  color: #fff;
  box-shadow: 0 8px 26px -12px rgba(239, 83, 80, .9), inset 0 1px 0 rgba(255,255,255,.22);
}

.btn--ghost { background: transparent; color: var(--text-mut); }
.btn.is-busy { pointer-events: none; opacity: .6; }

.foot {
  margin: 22px 0 0;
  font-size: 12.5px; line-height: 1.6;
  color: var(--text-mut);
  text-align: center;
}

/* ─────────── ayarlar ─────────── */
.page__title {
  margin: 6px 0 20px;
  font-family: var(--font-mech);
  font-size: 15px; letter-spacing: .24em; text-transform: uppercase; color: var(--text-dim);
}
.card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--soil-850);
  padding: 15px 16px;
  margin-bottom: 13px;
  animation: rise .45s both;
}
.card__title {
  margin: 0 0 12px;
  font-family: var(--font-mech);
  font-size: 11.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--text-mut);
  font-weight: 600;
}
.readout { margin: 0; display: grid; grid-template-columns: minmax(0,auto) minmax(0,1fr); gap: 9px 14px; }
.readout dt { font-size: 13px; color: var(--text-mut); }
.readout dd {
  margin: 0; text-align: right;
  font-family: var(--font-mech); font-size: 13px; color: var(--text);
  overflow-wrap: anywhere;
}
.readout dd.is-good { color: var(--leaf); }
.readout dd.is-warn { color: var(--amber); }

/* ─────────── geçmiş: özet kutuları ─────────── */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 13px; }
.stat {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--soil-850); padding: 12px 13px;
  display: flex; flex-direction: column; gap: 4px;
  animation: rise .45s both;
}
.stat__k { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-mut); }
.stat__v { font-family: var(--font-mech); font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ─────────── takvim ─────────── */
.calhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.calhead__title {
  font-family: var(--font-mech); font-size: 14px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text);
}
.calnav {
  width: 34px; height: 34px; flex: none;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: transparent; color: var(--text-dim);
  font-size: 19px; line-height: 1; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.calnav:hover:not(:disabled) { color: var(--water); border-color: rgba(58,211,207,.4); }
.calnav:disabled { opacity: .3; cursor: not-allowed; }

.caldow, .calgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.caldow {
  margin-bottom: 6px;
  font-family: var(--font-mech); font-size: 10.5px; letter-spacing: .06em;
  color: var(--text-mut); text-align: center;
}

.calday {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--soil-800);
  color: var(--text-mut);
  font-family: var(--font-mech); font-size: 12px;
  display: grid; place-items: center;
  cursor: pointer; padding: 0;
  transition: transform .1s, border-color .15s, background .2s, color .2s;
}
.calday:active { transform: scale(.93); }
.calday--empty { visibility: hidden; }
.calday--future { opacity: .3; cursor: default; }
.calday--today { border-color: rgba(150,195,172,.5); }
.calday--today::after {
  content: ''; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 3px; height: 3px; border-radius: 50%; background: var(--text-dim);
}
/* su miktarı yoğunluğu */
.calday[data-lvl="1"] { background: rgba(58,211,207,.13); color: var(--text-dim); border-color: rgba(58,211,207,.18); }
.calday[data-lvl="2"] { background: rgba(58,211,207,.28); color: #cdece9; border-color: rgba(58,211,207,.3); }
.calday[data-lvl="3"] { background: rgba(58,211,207,.48); color: #062a2a; border-color: rgba(58,211,207,.45); }
.calday[data-lvl="4"] { background: rgba(58,211,207,.78); color: #042221; border-color: rgba(58,211,207,.7); font-weight: 700; }
.calday[aria-selected="true"] { outline: 2px solid var(--water); outline-offset: 2px; }

.callegend {
  display: flex; align-items: center; justify-content: flex-end; gap: 5px;
  margin-top: 12px;
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-mut);
}
.callegend i { width: 13px; height: 13px; border-radius: 4px; border: 1px solid var(--line); }
.callegend i[data-lvl="1"] { background: rgba(58,211,207,.13); }
.callegend i[data-lvl="2"] { background: rgba(58,211,207,.28); }
.callegend i[data-lvl="3"] { background: rgba(58,211,207,.48); }
.callegend i[data-lvl="4"] { background: rgba(58,211,207,.78); }

/* gün ayrıntısı */
.sess {
  display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: baseline;
  font-family: var(--font-mech); font-size: 12.5px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.sess:last-child { border-bottom: 0; }
.sess__t { color: var(--text-mut); }
.sess__d { color: var(--water); font-variant-numeric: tabular-nums; }
.sess__m { color: var(--text-mut); font-size: 11px; text-align: right; }
.sess__m.warn { color: var(--amber); }

/* ─────────── sensörler ─────────── */
.sensorgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 13px; }
.scard {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--soil-850); padding: 14px 13px;
  display: flex; flex-direction: column; gap: 3px;
  animation: rise .45s both;
}
.scard__k { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-mut); }
.scard__v { font-family: var(--font-mech); font-size: 26px; color: var(--text-mut); font-variant-numeric: tabular-nums; }
.scard--live .scard__v { color: var(--water); }
.scard__u { font-size: 11px; color: var(--text-mut); }
.leak__state {
  display: block; font-family: var(--font-mech); font-size: 20px; letter-spacing: .08em;
  color: var(--text-mut); margin-bottom: 4px;
}
.leak--ok .leak__state { color: var(--leaf); }
.leak--alarm { border-color: rgba(239,83,80,.5); background: rgba(239,83,80,.09); }
.leak--alarm .leak__state { color: var(--rose); }
.code {
  margin: 0; padding: 12px; overflow-x: auto;
  background: var(--soil-900); border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font-mech); font-size: 11.5px; line-height: 1.6; color: var(--text-dim);
}
.foot--left { text-align: left; margin-top: 12px; }

.logrows { display: flex; flex-direction: column; gap: 7px; max-height: 320px; overflow-y: auto; }
.logrow {
  display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; align-items: baseline;
  font-family: var(--font-mech); font-size: 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}
.logrow:last-child { border-bottom: 0; padding-bottom: 0; }
.logrow__time { color: var(--text-mut); }
.logrow__what { color: var(--text-dim); overflow-wrap: anywhere; }
.logrow__res { font-size: 11px; letter-spacing: .08em; }
.logrow__res.ok { color: var(--leaf); }
.logrow__res.bad { color: var(--rose); }
.logrow__res.rej { color: var(--amber); }
.muted { color: var(--text-mut); font-size: 13px; margin: 0; }

/* ─────────── giriş ─────────── */
.view--login { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login {
  width: 100%; max-width: 330px;
  display: flex; flex-direction: column; align-items: center;
  animation: rise .5s both;
}
.login__mark { color: var(--water); margin-bottom: 20px; filter: drop-shadow(0 0 22px rgba(58,211,207,.35)); }
.login__title { margin: 0; font-family: var(--font-mech); font-size: 21px; letter-spacing: .34em; font-weight: 600; }
.login__sub { margin: 5px 0 30px; font-size: 13.5px; color: var(--text-mut); }
.field { width: 100%; margin-bottom: 14px; }
.field__label {
  display: block; margin-bottom: 7px;
  font-family: var(--font-mech); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--text-mut);
}
.field__input {
  width: 100%;
  padding: 14px 15px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--soil-800);
  color: var(--text);
  font-family: var(--font-mech); font-size: 16px;
}
.field__input:focus { outline: none; border-color: rgba(58, 211, 207, .5); }
.login__error { width: 100%; margin: 0 0 14px; color: #ff9b98; font-size: 13.5px; text-align: center; }

/* ─────────── hareket ─────────── */
@keyframes rise { from { opacity: 0; transform: translateY(11px); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes bubble {
  0%   { transform: translateY(0) scale(var(--s, 1)); opacity: 0; }
  12%  { opacity: .85; }
  85%  { opacity: .5; }
  100% { transform: translateY(-190px) scale(var(--s, 1)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .gauge__bubbles { display: none; }
}

/* geniş ekran: daha rahat nefes */
@media (min-width: 560px) {
  .page { padding-top: 10px; }
  .gauge { width: 300px; }
}

:focus-visible { outline: 2px solid var(--water); outline-offset: 3px; border-radius: 6px; }
