/* Gas -- app shell.
   Dark only: this gets opened in a kitchen at night more than anywhere else. */

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface-2: #1f2630;
  --line:      #2a3038;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --good:      #3fb950;
  --warn:      #d29922;
  --bad:       #f85149;
  --accent:    #58a6ff;
  --radius:    16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* Respect the notch and the home indicator when launched full screen. */
  padding:
    calc(env(safe-area-inset-top) + 16px)
    calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + 24px)
    calc(env(safe-area-inset-left) + 16px);
  max-width: 560px;
  margin: 0 auto;
  overscroll-behavior-y: contain;
}

.hidden { display: none !important; }
.muted  { color: var(--muted); }
.small  { font-size: 13px; }
.centre { text-align: center; }
.error  { color: var(--bad); font-size: 14px; margin-top: 12px; }

.row      { display: flex; align-items: center; gap: 12px; }
.between  { justify-content: space-between; }

h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
h2 { font-size: 15px; font-weight: 600; color: var(--muted);
     text-transform: uppercase; letter-spacing: 0.06em; }

/* --- top bar ------------------------------------------------------------ */
.top { display: flex; justify-content: space-between; align-items: flex-start;
       margin-bottom: 18px; }

.icon-btn {
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  cursor: pointer; transition: transform .15s, color .15s;
}
.icon-btn:active { transform: scale(.92); color: var(--text); }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- banner ------------------------------------------------------------- */
.banner {
  background: rgba(210,153,34,.12);
  border: 1px solid rgba(210,153,34,.35);
  color: var(--warn);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px;
}
.banner strong { display: block; color: var(--warn); }

/* --- critical alarm ----------------------------------------------------- */
.alarm {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: rgba(248,81,73,.15); border: 1px solid var(--bad);
  border-radius: 12px; padding: 14px; margin-bottom: 16px;
  animation: pulse 1.4s ease-in-out infinite;
}
.alarm strong { display: block; color: var(--bad); }
@keyframes pulse {
  0%, 100% { border-color: var(--bad);          background: rgba(248,81,73,.15); }
  50%      { border-color: rgba(248,81,73,.4);  background: rgba(248,81,73,.06); }
}
button.danger {
  flex: none; padding: 10px 16px; font: inherit; font-weight: 650;
  background: var(--bad); color: #1a0605; border: 0; border-radius: 10px;
  cursor: pointer;
}
button.danger:active { transform: scale(.96); }

/* --- spec list ---------------------------------------------------------- */
.spec { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px;
        font-size: 14px; }
.spec dt { color: var(--muted); }
.spec dd { text-align: right; font-variant-numeric: tabular-nums;
           overflow-wrap: anywhere; }

/* --- orientation -------------------------------------------------------- */
.tilt { display: flex; align-items: center; gap: 14px; margin-top: 16px;
        padding-top: 14px; border-top: 1px solid var(--line); }
.tilt svg { flex: none; }
.tilt-text { font-size: 13px; }
.tilt-text .v { font-size: 15px; font-weight: 600; }

/* --- cards -------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.card-head { display: flex; justify-content: space-between; align-items: center;
             margin-bottom: 14px; }

/* --- gauge -------------------------------------------------------------- */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gauge { position: relative; width: 200px; height: 200px; }
.gauge svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.gauge-track { stroke: var(--surface-2); }
.gauge-fill  { stroke-linecap: round; transition: stroke-dashoffset .7s cubic-bezier(.4,0,.2,1), stroke .4s; }

.gauge-centre {
  position: absolute; inset: 0; display: grid; place-content: center;
  text-align: center; gap: 2px;
}
.gauge-pct { font-size: 46px; font-weight: 680; letter-spacing: -0.03em;
             font-variant-numeric: tabular-nums; line-height: 1; }
.gauge-kg  { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

.cyl-label { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

.prediction { font-size: 15px; margin-top: 10px; text-align: center; }
.prediction .big { font-size: 20px; font-weight: 640; }

/* --- metrics grid ------------------------------------------------------- */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
           margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.metric { text-align: center; }
.metric .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric .k { font-size: 11px; color: var(--muted); text-transform: uppercase;
             letter-spacing: 0.05em; margin-top: 2px; }

/* --- chart -------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; background: var(--surface-2);
        padding: 3px; border-radius: 10px; }
.tabs button {
  background: none; border: 0; color: var(--muted); font-size: 13px;
  font-weight: 600; padding: 5px 12px; border-radius: 8px; cursor: pointer;
}
.tabs button.active { background: var(--surface); color: var(--text); }

#chart { width: 100%; display: block; }

/* --- buttons ------------------------------------------------------------ */
button.primary, button.secondary, button.ghost {
  font: inherit; font-weight: 600; border-radius: 12px; cursor: pointer;
  transition: transform .12s, opacity .12s;
}
button.primary:active, button.secondary:active, button.ghost:active { transform: scale(.97); }

button.primary {
  width: 100%; padding: 14px; margin-top: 12px;
  background: var(--accent); color: #06101f; border: 0; font-size: 16px;
}
button.secondary {
  padding: 10px 18px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); font-size: 14px;
}
button.secondary:disabled { opacity: .45; cursor: default; }
button.ghost {
  width: 100%; padding: 12px; margin-top: 12px; background: none;
  color: var(--muted); border: 1px solid var(--line); font-size: 14px;
}

/* --- login -------------------------------------------------------------- */
.screen { animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.login-box { min-height: 78vh; display: flex; flex-direction: column;
             justify-content: center; text-align: center; }
.login-box h1 { font-size: 30px; margin-bottom: 6px; }
.login-box form { margin-top: 24px; }

.flame {
  width: 56px; height: 56px; margin: 0 auto 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 62%, #f85149, #d29922 62%, transparent 72%);
  filter: blur(1px);
}

input[type=password] {
  width: 100%; padding: 14px 16px; font: inherit;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
}
input[type=password]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
