:root {
  --bg: var(--tg-theme-bg-color, #f4f4f5);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #6b7280);
  --accent: var(--tg-theme-button-color, #2aabee);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --secondary: var(--tg-theme-secondary-bg-color, #fff);
  --border: color-mix(in srgb, var(--text) 12%, transparent);
  --danger: #dc2626;
  --danger-bg: #fee2e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.hidden { display: none !important; }

.header {
  padding: 1rem 1rem 0.5rem;
}

.header h1 {
  margin: 0;
  font-size: 1.35rem;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--hint);
  font-size: 0.9rem;
}

.state {
  padding: 1rem;
  text-align: center;
  color: var(--hint);
}

.state-error { color: var(--danger); }

.card {
  margin: 0 1rem 1rem;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.status-label {
  font-size: 0.8rem;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-active { background: #dcfce7; color: #166534; }
.badge-pending { background: #fef9c3; color: #854d0e; }
.badge-cancelled { background: #e5e7eb; color: #374151; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-lapsed { background: #ede9fe; color: #5b21b6; }
.badge-unknown { background: #e5e7eb; color: #374151; }

.metric {
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}

.metric:first-of-type {
  border-top: none;
  padding-top: 0;
}

.metric .label {
  font-size: 0.82rem;
  color: var(--hint);
}

.metric .value {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.metric .value-sm {
  font-size: 1rem;
  font-weight: 600;
}

.note {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--hint);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0 1rem 1.5rem;
}

button {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--secondary);
  color: var(--text);
  border: 1px solid var(--border);
}

.empty {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--hint);
}

.empty .hint {
  font-size: 0.9rem;
  margin-top: 0.35rem;
}

@media (prefers-color-scheme: dark) {
  .badge-active { background: #14532d; color: #bbf7d0; }
  .badge-pending { background: #713f12; color: #fef08a; }
  .badge-cancelled { background: #374151; color: #e5e7eb; }
  .badge-failed { background: #7f1d1d; color: #fecaca; }
  .badge-lapsed { background: #4c1d95; color: #ddd6fe; }
  --danger-bg: #7f1d1d;
}
