:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --brand: #1f4e79; --ok: #15803d; --ok-bg: #e8f6ec; --err: #b91c1c; --err-bg: #fdecec;
  --warn: #b45309; --warn-bg: #fdf3e2; --fuel: #d97706;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

header { background: var(--brand); color: #fff; }
header .wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
header .brand { font-weight: 700; font-size: 17px; color: #fff; }
header nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
header nav a { color: #dbe7f3; padding: 6px 10px; border-radius: 6px; }
header nav a.on, header nav a:hover { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
header .user { font-size: 13px; color: #dbe7f3; }
header .user a { color: #fff; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 40px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 18px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.inactive td { color: var(--muted); }
.table-scroll { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.mute { background: #eef0f3; color: var(--muted); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.hw-errors { border: 1px solid #f3b4b4; }
.hw-errors ul { margin: 6px 0; padding-left: 20px; }

form.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select { width: 100%; padding: 8px 10px; border: 1px solid #cdd2d9; border-radius: 6px; font: inherit; background: #fff; color: var(--text); }
input[type=checkbox] { width: auto; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
button, .btn { display: inline-block; padding: 8px 14px; border: 0; border-radius: 6px; background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
button:hover, .btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn.light, button.light { background: #e8ecf2; color: var(--text); }
.btn.danger, button.danger { background: var(--err); }
.btn.small, button.small { padding: 4px 10px; font-size: 13px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; }

/* canlı pompa durumu */
.live { display: grid; grid-template-columns: 1fr 260px; gap: 18px; }
.pump-state { display: flex; align-items: center; gap: 18px; }
.pump-dot { width: 18px; height: 18px; border-radius: 50%; background: #9aa3af; flex: none; }
.pump-dot.on { background: var(--fuel); box-shadow: 0 0 0 6px rgba(217,119,6,.18); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(217,119,6,.05); } }
.pump-title { font-size: 20px; font-weight: 700; }
.pump-liters { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--fuel); }
.event { margin-top: 12px; padding: 8px 12px; border-radius: 8px; background: #eef0f3; }
.event.ok { background: var(--ok-bg); color: var(--ok); }
.event.error { background: var(--err-bg); color: var(--err); }
.event.warn { background: var(--warn-bg); color: var(--warn); }

/* araç fotoğrafları */
.live-main { display: flex; gap: 20px; align-items: flex-start; }
.live-photo { width: 240px; height: 160px; border-radius: 10px; object-fit: cover; background: #eef1f5; flex: none; border: 1px solid var(--line); transition: opacity .3s; }
.live-photo.idle { opacity: .45; }
.live-info { flex: 1; min-width: 0; }
.thumb { width: 52px; height: 36px; border-radius: 6px; object-fit: cover; background: #eef1f5; display: block; border: 1px solid var(--line); }
.photo-field { display: flex; gap: 12px; align-items: center; }
.photo-preview { width: 120px; height: 80px; border-radius: 8px; object-fit: cover; background: #eef1f5; border: 1px solid var(--line); flex: none; }

.tank { display: flex; gap: 16px; align-items: stretch; }
.tank-body { width: 80px; height: 150px; border: 3px solid #4b5563; border-radius: 8px; position: relative; overflow: hidden; background: #f8fafc; flex: none; }
.tank-fill { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(#f59e0b, #d97706); transition: height .6s; }
.tank-fill.low { background: linear-gradient(#ef4444, #b91c1c); }
.tank-info .big { font-size: 28px; font-weight: 800; }

.login-box { max-width: 360px; margin: 80px auto; }
.sim-banner { background: #7c3aed; color: #fff; text-align: center; padding: 4px; font-size: 13px; }
.sim-banner a { color: #fff; text-decoration: underline; }
canvas { width: 100%; height: 320px; display: block; }

@media (max-width: 760px) {
  .live { grid-template-columns: 1fr; }
  .live-main { flex-direction: column; }
  .live-photo { width: 100%; height: 200px; }
  .g2 { grid-template-columns: 1fr; }
}

/* telefon */
@media (max-width: 600px) {
  body { font-size: 16px; }
  header .wrap { gap: 6px; padding-top: 8px; padding-bottom: 0; }
  header .brand { font-size: 16px; }
  header .user { font-size: 12px; order: 2; width: 100%; }
  /* menü tek satırda yana kayar */
  header nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
               padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
  header nav::-webkit-scrollbar { display: none; }
  header nav a { white-space: nowrap; padding: 8px 12px; }
  main.wrap { padding-top: 12px; }
  .wrap { padding: 0 10px; }
  .card { padding: 14px; margin-bottom: 12px; }
  .grid { gap: 12px; }
  .g4 { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 20px; }
  .pump-liters { font-size: 40px; }
  .pump-title { font-size: 18px; }
  .tank-body { width: 64px; height: 120px; }
  th, td { padding: 7px 6px; }
  input, select { font-size: 16px; padding: 10px; } /* iPhone'da yakınlaştırmayı önler */
  button, .btn { padding: 10px 14px; }
  .login-box { margin: 24px auto; }
  canvas { height: 240px; }
}
/* ana ekrandan açılınca (uygulama modu) çentik payı */
@media (display-mode: standalone) {
  header { padding-top: env(safe-area-inset-top); }
}

/* ---------------- merkezi portal ---------------- */
.small { font-size: 13px; }
h1 .site-filter { display: inline-block; vertical-align: middle; margin-left: 10px; }
.site-filter select { width: auto; font-size: 14px; padding: 6px 8px; }
.site-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin-bottom: 18px; }
.site-card { display: flex; flex-direction: column; gap: 6px; color: var(--text); margin: 0; border-top: 4px solid var(--ok); transition: box-shadow .2s; }
.site-card:hover { text-decoration: none; box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.site-card.offline { border-top-color: var(--err); background: #fffafa; }
.site-card.inactive { opacity: .55; }
.site-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.site-name { font-weight: 700; font-size: 17px; flex: 1; }
.pump-line { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.pump-line .pump-dot { width: 12px; height: 12px; }
.pump-dot.off { background: var(--err); }
.site-liters { font-size: 30px; font-weight: 800; color: var(--fuel); font-variant-numeric: tabular-nums; }
.mini-tank { height: 10px; border-radius: 99px; background: #eef0f3; overflow: hidden; margin-top: 6px; }
.mini-fill { height: 100%; background: linear-gradient(90deg, #f59e0b, #d97706); }
.mini-fill.low { background: linear-gradient(90deg, #ef4444, #b91c1c); }
.site-err { background: var(--err-bg); color: var(--err); border-radius: 8px; padding: 6px 10px; font-size: 13px; margin-top: 6px; }
.site-stats { display: flex; gap: 24px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.site-stats div { display: flex; flex-direction: column; }
.site-stats b { font-size: 18px; }
.token-box { border: 2px solid var(--fuel); background: #fffbf3; }
pre.code { background: #1d2330; color: #e5e7eb; padding: 12px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; font-size: 13px; }
.danger-zone { border-color: #f3b4b4; }
.user-sites { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.site-list { display: flex; flex-direction: column; gap: 4px; padding-left: 4px; }
@media (max-width: 600px) {
  .site-grid { grid-template-columns: 1fr; gap: 12px; }
  h1 .site-filter { display: block; margin: 8px 0 0; }
}
