:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0e100d;
  color: #f5f6f2;
  --accent: #b2ff59;
  --surface: #1b1f18;
  --surface-2: #242a20;
  --muted: #aeb5a8;
  --line: #343b30;
  --danger: #ff7c72;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  padding: 20px;
  background: radial-gradient(circle at 15% 0, rgba(178, 255, 89, 0.1), transparent 32%), #0e100d;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-header, main {
  width: min(100%, 680px);
  margin-inline: auto;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 38px; }
h2, h3 { margin-bottom: 8px; }

.eyebrow {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.offline-badge, .live-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

.offline-badge::before, .live-dot::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.empty-state, .hero-card, .section-card, .stats-section, .history-section, .data-section {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(27, 31, 24, 0.96);
}

.empty-state {
  padding: 42px 24px;
  text-align: center;
}

.empty-state p, .muted, .empty-list { color: var(--muted); }
.empty-icon { margin-bottom: 12px; color: var(--accent); font-size: 44px; }

.primary, .secondary, .danger-button, .text-button, .close-button {
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 800;
}

.primary { background: var(--accent); color: #11150e; }
.secondary { background: #343b30; color: #fff; }
.large { width: min(100%, 320px); font-size: 17px; }

.hero-card { padding: 22px; border-color: rgba(178, 255, 89, 0.5); }
.hero-topline, .section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.text-button, .close-button { padding: 7px 9px; background: transparent; color: var(--muted); }
.duration { margin: 12px 0 4px; color: var(--accent); font-size: 34px; font-weight: 850; }

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0;
}

.action-button { min-height: 92px; font-size: 16px; }
.action-icon { display: block; margin-bottom: 5px; font-size: 25px; }

.section-card, .stats-section, .history-section, .data-section { margin-top: 14px; padding: 20px; }
.section-heading span { color: var(--muted); font-size: 12px; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.summary-grid div { padding: 14px; border-radius: 14px; background: var(--surface-2); }
.summary-grid span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.summary-grid strong { font-size: 20px; }
.accent-summary { background: var(--accent) !important; color: #11150e; }
.accent-summary span { color: #344726; }

.period-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: #121510;
}
.period-button {
  border: 0;
  border-radius: 9px;
  padding: 8px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.period-button.active { background: var(--accent); color: #11150e; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stats-grid div { padding: 14px; border-radius: 14px; background: var(--surface-2); }
.stats-grid span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.stats-grid strong { font-size: 20px; }

.event-list, .history-list { display: grid; gap: 9px; margin-top: 14px; }
.event-row, .history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border-radius: 13px;
  background: var(--surface-2);
}
.event-row p, .history-row p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.event-row strong { white-space: nowrap; }
.history-row button { flex: 0 0 auto; padding: 9px 12px; }
.empty-list { margin: 14px 0 0; text-align: center; font-size: 14px; }

.data-section .muted { margin: 4px 0 14px; font-size: 14px; line-height: 1.45; }
.data-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cloud-code-actions { margin: 10px 0; }
.cloud-status { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
button:disabled { cursor: wait; opacity: 0.55; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.danger-button {
  width: 100%;
  margin-top: 14px;
  border: 1px solid rgba(255, 124, 114, 0.45);
  background: rgba(255, 124, 114, 0.08);
  color: var(--danger);
}

dialog {
  width: min(calc(100% - 24px), 520px);
  max-height: calc(100vh - 24px);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 0;
  background: var(--surface);
  color: #fff;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(4px); }
.dialog-form { display: grid; gap: 14px; padding: 22px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.close-button { font-size: 24px; line-height: 1; }

label { display: grid; gap: 7px; color: #dce1d8; font-size: 13px; font-weight: 700; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px 14px;
  background: #121510;
  color: #fff;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(178, 255, 89, 0.1); }

pre {
  max-height: 55vh;
  overflow: auto;
  margin: 0;
  padding: 16px;
  border-radius: 14px;
  background: #11140f;
  color: #eef2ea;
  font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 10;
  max-width: calc(100% - 24px);
  transform: translate(-50%, 20px);
  border-radius: 12px;
  padding: 12px 16px;
  background: #f5f6f2;
  color: #11150e;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}
.toast.visible { transform: translate(-50%, 0); opacity: 1; }

[hidden] { display: none !important; }

@media (max-width: 560px) {
  body { padding: 12px; }
  .app-header { align-items: flex-end; }
  .offline-badge { max-width: 120px; text-align: right; }
  .quick-actions, .summary-grid, .data-actions { grid-template-columns: 1fr; }
  .action-button { min-height: 76px; }
  .hero-card, .section-card, .stats-section, .history-section, .data-section { padding: 16px; }
  .stats-section .section-heading { align-items: flex-start; }
}
