:root {
  --ink: #14211c;
  --muted: #66736d;
  --paper: #f3f5f1;
  --card: #ffffff;
  --line: #dfe5df;
  --green: #177a55;
  --green-dark: #0f5139;
  --mint: #dcefe5;
  --lime: #d9ee63;
  --amber: #d38328;
  --red: #c94f47;
  --shadow: 0 18px 50px rgba(27, 50, 39, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  height: 76px; padding: 0 clamp(20px, 4vw, 64px); display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; background: #101815; color: white; position: sticky; top: 0; z-index: 20;
}
.brand { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 11px; width: max-content; }
.brand > span:last-child { display: grid; line-height: 1.05; }
.brand strong { font-size: 18px; letter-spacing: -.02em; }
.brand small { font-size: 10px; opacity: .65; letter-spacing: .12em; text-transform: uppercase; margin-top: 4px; }
.brand-mark { display: flex; gap: 3px; align-items: end; width: 26px; height: 28px; padding: 4px; background: var(--lime); border-radius: 8px; }
.brand-mark i { display: block; width: 4px; border-radius: 3px; background: var(--green-dark); }
.brand-mark i:nth-child(1) { height: 8px; }.brand-mark i:nth-child(2) { height: 16px; }.brand-mark i:nth-child(3) { height: 12px; }
.tabs { display: flex; gap: 4px; background: rgba(255,255,255,.07); border-radius: 12px; padding: 4px; }
.tab { border: 0; background: transparent; color: rgba(255,255,255,.62); padding: 9px 15px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.tab:hover { color: white; }.tab.active { background: white; color: var(--ink); }
.topbar form { justify-self: end; }
.logout { color: rgba(255,255,255,.7); background: transparent; border: 0; cursor: pointer; padding: 10px; }
.logout:hover { color: white; }

.app-shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 80px; }
.view { display: none; }.view.active { display: block; animation: reveal .22s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(4px); } }
.page-heading, .section-heading, .chart-heading { display: flex; justify-content: space-between; align-items: end; gap: 28px; }
.page-heading { margin-bottom: 30px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(32px, 4vw, 54px); line-height: 1; letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 22px; letter-spacing: -.025em; }
.eyebrow { margin-bottom: 9px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.subtitle { margin: 0; color: var(--muted); font-size: 15px; }
.muted { color: var(--muted); font-size: 13px; }
.toolbar, .chart-controls { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.field { display: grid; gap: 6px; }
.field span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
input, select { color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,122,85,.12); }
.button { display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid transparent; padding: 10px 14px; text-decoration: none; cursor: pointer; font-weight: 700; font-size: 13px; }
.button-primary { background: var(--green); color: white; }.button-primary:hover { background: var(--green-dark); }
.button-secondary { background: white; border-color: var(--line); color: var(--ink); }.button-secondary:hover { border-color: #b9c4bd; }
.button-wide { width: 100%; padding: 13px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 44px; }
.kpi { min-height: 146px; display: flex; flex-direction: column; padding: 22px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 7px 30px rgba(27,50,39,.035); }
.kpi-accent { background: var(--green-dark); color: white; border-color: var(--green-dark); position: relative; overflow: hidden; }
.kpi-accent::after { content: ""; position: absolute; width: 110px; height: 110px; right: -35px; bottom: -45px; border: 18px solid rgba(217,238,99,.16); border-radius: 50%; }
.kpi > span { color: var(--muted); font-size: 12px; font-weight: 700; }.kpi-accent > span, .kpi-accent small { color: rgba(255,255,255,.65); }
.kpi strong { font-size: 34px; letter-spacing: -.045em; margin: 9px 0 auto; }
.kpi small { color: var(--muted); font-size: 11px; }
.section-block { margin-bottom: 44px; }.section-heading { margin-bottom: 16px; }
.sensor-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.sensor-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; min-height: 192px; box-shadow: 0 7px 30px rgba(27,50,39,.035); transition: transform .15s, box-shadow .15s; cursor: pointer; }
.sensor-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.sensor-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sensor-name { font-size: 15px; font-weight: 800; }.sensor-id { color: var(--muted); font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; margin-top: 4px; }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; background: #f0f2f0; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #98a39d; }.status.online { color: var(--green-dark); background: var(--mint); }.status.online::before { background: var(--green); box-shadow: 0 0 0 3px rgba(23,122,85,.12); }
.sensor-reading { display: flex; align-items: baseline; gap: 5px; margin: 24px 0 20px; }.sensor-reading strong { font-size: 39px; letter-spacing: -.055em; }.sensor-reading span { color: var(--muted); font-weight: 600; }
.sensor-bottom { display: flex; justify-content: space-between; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }.sensor-bottom strong { color: var(--ink); font-weight: 750; }
.sensor-empty { color: var(--muted); margin: 30px 0; }

.chart-card, .table-card, .settings-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: 0 7px 30px rgba(27,50,39,.035); }
.chart-card { margin-bottom: 20px; }.chart-heading { align-items: center; margin-bottom: 18px; }
.segmented { display: flex; border: 1px solid var(--line); background: var(--paper); padding: 3px; border-radius: 10px; }
.segmented button { border: 0; color: var(--muted); background: transparent; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 700; }.segmented button.active { color: var(--ink); background: white; box-shadow: 0 2px 8px rgba(27,50,39,.08); }
.chart-wrap { position: relative; min-height: 330px; }canvas { display: block; width: 100%; height: 330px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: repeating-linear-gradient(-45deg,#fff,#fff 10px,#fafbfa 10px,#fafbfa 20px); border-radius: 12px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; min-height: 18px; margin-top: 12px; }.legend span, .history-key span { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.legend i, .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }.dot.max { background: var(--amber); }.dot.avg { background: var(--green); }
.history-key { display: flex; gap: 16px; }
.table-card { margin-top: 20px; }.table-scroll { overflow-x: auto; }table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }th, td { padding: 13px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }th:first-child, td:first-child { text-align: left; }th { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }tbody tr:last-child td { border-bottom: 0; }.empty-row td { color: var(--muted); text-align: center; padding: 30px; }
.settings-list { display: grid; }.setting-row { display: grid; grid-template-columns: minmax(210px, .8fr) 1fr auto; align-items: center; gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--line); }.setting-row:last-child { border: 0; }.setting-meta { display: grid; gap: 4px; }.setting-meta strong { font-size: 14px; }.setting-meta span { color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Consolas, monospace; }.setting-row input { width: 100%; }

.toast { position: fixed; right: 24px; bottom: 24px; background: var(--ink); color: white; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s; font-size: 13px; z-index: 50; }.toast.show { opacity: 1; transform: translateY(0); }
.login-page { background: #101815; color: white; display: grid; place-items: center; padding: 26px; }
.login-page::before { content: ""; position: fixed; inset: 0; opacity: .17; background: radial-gradient(circle at 75% 15%, var(--lime), transparent 24%), radial-gradient(circle at 15% 85%, #52b98c, transparent 22%); }
.login-shell { width: min(440px, 100%); position: relative; }.login-card { background: var(--card); color: var(--ink); border-radius: 24px; padding: 34px; box-shadow: 0 30px 90px rgba(0,0,0,.25); }.brand-login { margin-bottom: 42px; }.brand-login small { color: var(--muted); }.login-copy h1 { font-size: 39px; line-height: 1.05; }.login-copy > p:last-child { color: var(--muted); line-height: 1.55; font-size: 14px; }.login-form { display: grid; gap: 16px; margin-top: 27px; }.login-form label { display: grid; gap: 7px; font-size: 12px; font-weight: 750; }.alert { color: #7b2721; background: #fae8e5; border-radius: 10px; padding: 11px 13px; margin-top: 18px; font-size: 12px; }.login-foot { text-align: center; color: rgba(255,255,255,.45); font-size: 11px; margin: 16px 0 0; }

@media (max-width: 1050px) { .sensor-grid { grid-template-columns: repeat(2, 1fr); }.kpis { grid-template-columns: repeat(2, 1fr); }.topbar { grid-template-columns: 1fr auto; }.tabs { order: 3; grid-column: 1 / -1; position: fixed; left: 12px; right: 12px; bottom: 12px; justify-content: stretch; background: #101815; box-shadow: 0 10px 40px rgba(0,0,0,.3); }.tab { flex: 1; }.app-shell { padding-bottom: 110px; } }
@media (max-width: 680px) { .topbar { padding: 0 18px; height: 68px; }.app-shell { width: min(100% - 24px, 1440px); padding-top: 30px; }.page-heading, .section-heading, .chart-heading { align-items: stretch; flex-direction: column; }.page-heading { gap: 18px; }.toolbar, .chart-controls { width: 100%; }.toolbar .field, .chart-controls .field { flex: 1; }.toolbar input, .chart-controls select { width: 100%; }.kpis { grid-template-columns: 1fr 1fr; gap: 9px; }.kpi { min-height: 128px; padding: 17px; }.kpi strong { font-size: 28px; }.sensor-grid { grid-template-columns: 1fr; }.sensor-card { min-height: 178px; }.chart-card, .table-card, .settings-card { padding: 17px; border-radius: 15px; }.chart-wrap, canvas { min-height: 280px; height: 280px; }.setting-row { grid-template-columns: 1fr; gap: 9px; }.setting-row .button { width: 100%; }.login-card { padding: 26px; }.login-copy h1 { font-size: 34px; } }
@media (max-width: 410px) { .kpis { grid-template-columns: 1fr; }.kpi { min-height: 118px; }.brand small { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

