:root {
  color-scheme: light;
  --ink: #102a22;
  --muted: #66736d;
  --paper: #f3f4ed;
  --card: rgba(255, 255, 252, 0.88);
  --line: rgba(16, 42, 34, 0.12);
  --green: #2c6b55;
  --lime: #d7f05b;
  --orange: #d27b39;
  --red: #b4473e;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
}

button, input { font: inherit; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 36rem;
  height: 36rem;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .18;
}
.ambient-one { background: #8fcab1; top: -18rem; right: -12rem; }
.ambient-two { background: #e5d964; bottom: -24rem; left: -16rem; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 32px 0 56px; }
.topbar, .section-heading, .card-head, .card-foot, .actions, .brand, .cell-heading { display: flex; align-items: center; }
.topbar { justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.brand { gap: 13px; }
.brand img { box-shadow: 0 10px 30px rgba(16, 42, 34, .18); border-radius: 14px; }
h1, h2, h3, p { margin: 0; }
h1 { font-family: Georgia, serif; font-size: clamp(1.65rem, 4vw, 2.35rem); font-weight: 500; letter-spacing: -.03em; }
h2 { font-family: Georgia, serif; font-size: clamp(1.45rem, 3vw, 2rem); font-weight: 500; }
h3 { font-size: 1.1rem; letter-spacing: -.01em; }
.eyebrow { color: var(--green); font-size: .66rem; font-weight: 800; letter-spacing: .16em; margin-bottom: 4px; }
.muted { color: var(--muted); font-size: .84rem; }
.actions { gap: 9px; }
.connection, .status-pill { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; font-size: .76rem; font-weight: 700; padding: 8px 11px; }
.connection { background: rgba(255,255,255,.68); border: 1px solid var(--line); }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); }
.connection.online i { background: #39a56e; box-shadow: 0 0 0 4px rgba(57,165,110,.12); }
.connection.error i { background: var(--red); }
.icon-button, .text-button { border: 1px solid var(--line); background: rgba(255,255,255,.68); color: var(--ink); cursor: pointer; }
.icon-button { width: 38px; height: 38px; border-radius: 50%; font-size: 1.3rem; }
.text-button { padding: 9px 13px; border-radius: 999px; }
.icon-button:hover, .text-button:hover { background: #fff; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 38px; }
.summary-item { background: rgba(255,255,255,.57); border: 1px solid var(--line); border-radius: 18px; padding: 17px 18px; }
.summary-item span { display: block; color: var(--muted); font-size: .73rem; margin-bottom: 7px; }
.summary-item strong { font-family: Georgia, serif; font-size: 1.48rem; font-weight: 500; }
.section-heading { justify-content: space-between; margin-bottom: 16px; }

.battery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.battery-card { background: var(--card); backdrop-filter: blur(18px); border: 1px solid rgba(255,255,255,.92); box-shadow: 0 16px 50px rgba(25,45,37,.08); border-radius: 25px; padding: 21px; }
.card-head { justify-content: space-between; gap: 12px; }
.battery-label { color: var(--muted); font-size: .68rem; margin-bottom: 4px; }
.status-pill.online { color: #1f6a4c; background: #e3f4e9; }
.status-pill.stale { color: #9b642d; background: #f8ead8; }
.status-pill.offline { color: #9c3933; background: #f8dfdc; }
.soc-row { display: grid; grid-template-columns: 112px 1fr; gap: 19px; align-items: center; margin: 24px 0 19px; }
.soc-ring { --soc: 0; width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--green) calc(var(--soc) * 1%), #e4e7df 0); position: relative; }
.soc-ring::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #fbfcf7; }
.soc-value { position: relative; z-index: 1; font-family: Georgia, serif; font-size: 1.85rem; }
.main-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.main-metrics strong { font-size: 1.08rem; }
.main-metrics span { color: var(--muted); font-size: .68rem; margin-bottom: 9px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 0; }
.metric { min-width: 0; }
.metric span { color: var(--muted); display: block; font-size: .65rem; margin-bottom: 4px; }
.metric strong { font-size: .81rem; white-space: nowrap; }
.cell-heading { justify-content: space-between; color: var(--muted); font-size: .7rem; font-weight: 700; margin: 16px 0 8px; }
.cells { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.cell { background: #edf0e9; border-radius: 6px; padding: 5px 2px; text-align: center; font-size: .57rem; color: #59655f; }
.cell.high { background: #f6ebd8; color: #8d5d26; }
.cell.low { background: #e2eef2; color: #27637a; }
.card-foot { justify-content: space-between; gap: 10px; margin-top: 14px; color: var(--muted); font-size: .62rem; }
.message { border: 1px solid #e1beb9; color: #8d352f; background: #f9e6e3; padding: 14px 16px; border-radius: 14px; margin-bottom: 16px; }

.login-dialog { width: min(430px, calc(100% - 28px)); border: 0; border-radius: 26px; padding: 0; color: var(--ink); box-shadow: 0 28px 90px rgba(6,26,20,.34); }
.login-dialog::backdrop { background: rgba(9,28,22,.63); backdrop-filter: blur(8px); }
.login-dialog form { display: grid; gap: 14px; padding: 30px; }
.login-dialog img { border-radius: 17px; margin-bottom: 4px; }
.login-dialog label { font-size: .76rem; font-weight: 700; margin-top: 5px; }
.login-dialog input { width: 100%; border: 1px solid #ccd3cc; background: #f7f8f3; border-radius: 13px; padding: 13px 14px; outline: none; }
.login-dialog input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(44,107,85,.12); }
.primary-button { border: 0; border-radius: 13px; padding: 13px; background: var(--ink); color: white; font-weight: 750; cursor: pointer; }
.form-error { color: var(--red); font-size: .75rem; }

@media (max-width: 940px) {
  .battery-grid { grid-template-columns: 1fr 1fr; }
  .summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .shell { width: min(100% - 22px, 520px); padding-top: 19px; }
  .topbar { align-items: flex-start; }
  .connection { position: fixed; bottom: 13px; left: 50%; transform: translateX(-50%); z-index: 3; box-shadow: 0 8px 30px rgba(16,42,34,.2); background: #fff; }
  .text-button { display: none; }
  .battery-grid { grid-template-columns: 1fr; }
  .summary { gap: 8px; margin-bottom: 30px; }
  .summary-item { padding: 14px; }
  .section-heading { align-items: flex-end; }
  .section-heading .muted { max-width: 130px; text-align: right; }
}
