:root {
  --ink: #17231e;
  --muted: #5b6861;
  --soft: #87948d;
  --line: rgba(23, 35, 30, 0.1);
  --ok: #0e8a4c;
  --bad: #c0392b;
  --warn: #b56a14;
  --accent: #0c6f58;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #fff;
  --shadow: 0 16px 36px rgba(20, 36, 28, 0.08);
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'DM Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: #e6ece8;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(780px 380px at 0% 0%, rgba(12, 111, 88, 0.16), transparent 60%),
    radial-gradient(560px 320px at 100% 0%, rgba(181, 106, 20, 0.1), transparent 55%),
    linear-gradient(165deg, #eaf2ed, #e7ecf2 50%, #efe9e0);
}

.shell {
  width: min(920px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(40px, 7vw, 56px);
  font-weight: 400;
  line-height: 0.95;
}

.lede {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 36ch;
  line-height: 1.5;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: end;
}

.clock {
  width: 100%;
  margin: 0;
  text-align: right;
  color: var(--soft);
  font-size: 12px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--ink);
  color: #f4f7f5;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #243028;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

button.ghost {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  border: 1px solid var(--line);
}

button.ghost:hover {
  background: #fff;
}

.quota-board {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 14px;
  margin-bottom: 16px;
}

.quota-main,
.quota-timer,
.panel,
.site {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 18px;
}

.quota-main,
.quota-timer {
  padding: 20px;
}

.quota-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.quota-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.quota-numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 16px;
}

.quota-numbers div {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
}

.quota-numbers span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.quota-numbers strong {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
}

.quota-numbers .q-used {
  background: rgba(192, 57, 43, 0.14);
  border-color: rgba(192, 57, 43, 0.3);
}

.quota-numbers .q-used span {
  color: #9b2f24;
}

.quota-numbers .q-used strong {
  color: #8e281e;
}

.quota-numbers .q-remain {
  background: rgba(14, 138, 76, 0.14);
  border-color: rgba(14, 138, 76, 0.3);
}

.quota-numbers .q-remain span {
  color: #0b6f3d;
}

.quota-numbers .q-remain strong {
  color: #0a6437;
}

.quota-numbers .q-pct {
  background: rgba(212, 168, 45, 0.2);
  border-color: rgba(184, 140, 20, 0.35);
}

.quota-numbers .q-pct span {
  color: #8a6a0a;
}

.quota-numbers .q-pct strong {
  color: #7a5c08;
}

.meter-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(23, 35, 30, 0.08);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #1f9a74 60%, var(--warn));
  transition: width 0.45s ease;
}

.quota-timer {
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  background:
    linear-gradient(145deg, rgba(12, 111, 88, 0.1), rgba(181, 106, 20, 0.08)),
    var(--surface);
}

.timer-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.countdown-row {
  display: flex;
  align-items: end;
  gap: 6px;
}

.countdown-row .unit {
  display: grid;
  justify-items: center;
  min-width: 48px;
}

.countdown-row b {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 400;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.countdown-row small {
  color: var(--soft);
  font-size: 12px;
}

.countdown-row .sep {
  padding-bottom: 16px;
  color: var(--soft);
  font-size: 22px;
}

.timer-note {
  display: block;
  margin-top: 10px;
  color: var(--soft);
  font-size: 12px;
  line-height: 1.4;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 10px;
}

.panel-head h2 {
  margin: 0;
  font-size: 20px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.summary-inline {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.summary-inline b {
  color: var(--ink);
  font-size: 16px;
}

.sites {
  display: grid;
  gap: 10px;
}

.site {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid transparent;
  border-left-width: 4px;
  background: var(--surface-strong);
}

.site.is-ok {
  background: rgba(14, 138, 76, 0.12);
  border-color: rgba(14, 138, 76, 0.28);
  border-left-color: var(--ok);
}

.site.is-bad {
  background: rgba(192, 57, 43, 0.12);
  border-color: rgba(192, 57, 43, 0.28);
  border-left-color: var(--bad);
}

.site-name {
  font-weight: 700;
  font-size: 16px;
}

.site-url {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  word-break: break-all;
}

.site-url:hover {
  color: var(--accent);
}

.site-tag {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.site.is-bad .site-tag {
  color: #9b2f24;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

.status-pill::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-pill.ok {
  color: var(--ok);
}

.status-pill.bad {
  color: var(--bad);
}

.latency {
  text-align: right;
  min-width: 72px;
}

.latency strong {
  display: block;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.latency span {
  color: var(--soft);
  font-size: 11px;
}

.site-actions .ghost {
  padding: 8px 10px;
  font-size: 12px;
}

.details-box {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.details-box summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.script-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.script-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  font-size: 13px;
}

.script-row small {
  display: block;
  margin-top: 2px;
  color: var(--soft);
  font-size: 12px;
}

.script-row .nums {
  text-align: right;
  color: var(--muted);
}

.script-row .nums b {
  display: block;
  color: var(--ink);
}

.empty,
.error,
.login-error,
.login-ok,
.modal-tip {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.login-error {
  color: var(--bad);
}

.login-ok {
  color: var(--ok);
}

.setup-steps {
  margin: 0;
  padding-left: 1.1em;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.setup-steps a {
  color: var(--accent);
  font-weight: 600;
}

.login-body {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: min(400px, 100%);
  padding: 28px 24px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 48px;
}

.login-card .eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.login-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  font-size: 15px;
}

.login-form button {
  width: 100%;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 28, 24, 0.4);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(400px, 100%);
  padding: 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-head h2 {
  margin: 0;
  font-size: 22px;
}

@media (max-width: 760px) {
  .topbar,
  .quota-board,
  .panel-head,
  .site {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .clock,
  .latency {
    justify-content: start;
    text-align: left;
  }

  .quota-numbers {
    grid-template-columns: 1fr;
  }
}
