:root {
  --bg: #f4f4ef;
  --surface: #ffffff;
  --surface-2: #f7f7f2;
  --line: rgba(0, 0, 0, 0.10);
  --line-2: rgba(0, 0, 0, 0.18);
  --text: #1c1c1a;
  --text-2: #5f5e5a;
  --text-3: #9a988f;
  --brand: #004c71;
  --brand-weak: #e3eef4;
  --ok: #3b6d11;
  --ok-bg: #eaf3de;
  --warn: #854f0b;
  --warn-bg: #faeeda;
  --danger: #a32d2d;
  --danger-bg: #fcebeb;
  --bar: #378add;
  --bar-weak: #b5d4f4;
  --radius: 12px;
  --radius-sm: 8px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 560px; margin: 0 auto; padding: 12px 12px 40px; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---- Login ---- */
.login-wrap {
  min-height: 100svh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border: 0.5px solid var(--line); border-radius: var(--radius);
  padding: 26px 22px; text-align: center;
}
.login-logo { width: 56px; height: 56px; margin: 0 auto 10px; display: block; }
.login-card h1 { font-size: 18px; font-weight: 600; margin: 0 0 2px; }
.login-card p.sub { font-size: 13px; color: var(--text-2); margin: 0 0 20px; }
.field { text-align: left; margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
input[type="email"], input[type="password"] {
  width: 100%; height: 42px; padding: 0 12px; font-size: 15px;
  border: 0.5px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); outline: none;
}
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 16px; font-size: 14px; font-weight: 500;
  border-radius: var(--radius-sm); border: 0.5px solid var(--line-2);
  background: var(--surface); color: var(--text); cursor: pointer; width: 100%;
}
.btn:active { transform: scale(0.99); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:disabled { opacity: 0.55; cursor: default; }
.btn-sm { height: 34px; width: auto; padding: 0 12px; font-size: 13px; }
.msg { font-size: 13px; margin-top: 12px; min-height: 18px; }
.msg.error { color: var(--danger); }

/* ---- Header ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 0.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 12px;
}
.topbar .title { font-size: 15px; font-weight: 600; }
.topbar .meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ---- View toggle ---- */
.toggle {
  display: flex; border: 0.5px solid var(--line-2);
  border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 14px;
}
.toggle button {
  flex: 1; border: 0; background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 500; padding: 9px 0; cursor: pointer;
}
.toggle button.active { background: var(--brand-weak); color: var(--brand); }

/* ---- Range pickers ---- */
.range { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.range select {
  flex: 1; height: 38px; padding: 0 10px; font-size: 14px;
  border: 0.5px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.range span { font-size: 12px; color: var(--text-2); }

/* ---- Service card ---- */
.card {
  background: var(--surface); border: 0.5px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.card-head .icon { font-size: 18px; color: var(--text-2); }
.card-head .name { font-size: 14px; font-weight: 600; }
.card-head .sub { font-size: 11px; color: var(--text-3); }
.card-head .spacer { flex: 1; }

.pill {
  font-size: 11px; padding: 2px 9px; border-radius: 999px; font-weight: 500;
  white-space: nowrap;
}
.pill.on { background: var(--ok-bg); color: var(--ok); }
.pill.off { background: var(--danger-bg); color: var(--danger); }

.killnote { font-size: 11px; color: var(--danger); margin: 2px 0 8px; }

/* toggle switch */
.switch { position: relative; width: 40px; height: 23px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; background: #cfcdc4; border-radius: 999px; transition: background .15s;
}
.switch .thumb {
  position: absolute; top: 2px; left: 2px; width: 19px; height: 19px;
  background: #fff; border-radius: 50%; transition: transform .15s;
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track + .thumb { transform: translateX(17px); }
.switch input:disabled { cursor: default; }

/* metric block */
.metric { margin-top: 12px; }
.metric:first-of-type { margin-top: 8px; }
.metric .mrow { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 5px; }
.metric .mlabel { font-size: 12px; color: var(--text-2); }
.metric .mval { font-size: 13px; }
.metric .mval b { font-weight: 600; }
.metric .mpct { font-size: 11px; color: var(--text-3); }

/* horizontal usage bar with markers */
.hbar-wrap { margin: 6px 0 30px; }
.hbar {
  position: relative; height: 16px; background: var(--surface-2);
  border: 0.5px solid var(--line); border-radius: 5px;
}
.hbar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px 0 0 4px; }
.hbar .fill.ok { background: var(--ok); }
.hbar .fill.warn { background: var(--warn); }
.hbar .fill.danger { background: var(--danger); }
.hbar .marker { position: absolute; top: -4px; bottom: -4px; }
.hbar .marker.kill { border-left: 2px dashed var(--danger); }
.hbar .marker.tech { border-left: 2px solid var(--text-2); }
.hbar .marker .tag {
  position: absolute; top: 22px; transform: translateX(-50%);
  font-size: 10px; white-space: nowrap;
}
.hbar .marker.kill .tag { color: var(--danger); }
.hbar .marker.tech .tag { color: var(--text-2); }

.chart-box { position: relative; height: 150px; margin-top: 6px; }
.chart-cap { font-size: 10px; color: var(--text-3); text-align: right; margin-top: 4px; }

.legend { font-size: 11px; color: var(--text-2); margin: 8px 2px 0; line-height: 1.7; }
.legend .sw { display: inline-block; width: 11px; height: 9px; vertical-align: 0; margin-right: 4px; border-radius: 2px; }
.legend .ln-kill { display: inline-block; width: 14px; border-top: 2px dashed var(--danger); vertical-align: 4px; margin: 0 4px; }
.legend .ln-tech { display: inline-block; width: 14px; border-top: 2px solid var(--text-2); vertical-align: 4px; margin: 0 4px; }

.empty { font-size: 13px; color: var(--text-3); text-align: center; padding: 24px 0; }
.spinner-line { font-size: 13px; color: var(--text-2); text-align: center; padding: 30px 0; }
