/* ================================
   Apple-inspired Clean Theme
   Light, minimal, premium aesthetic
   ================================ */

:root {
  --bg: #ffffff;
  --bg-2: #f5f5f7;
  --bg-3: #eaeaea;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --line: #d2d2d7;
  --line-2: #b8b8bf;
  --text: #1d1d1f;
  --text-2: #424245;
  --muted: #86868b;
  --primary: #0071e3;
  --primary-2: #0077ed;
  --success: #34c759;
  --warning: #ff9f0a;
  --danger: #ff3b30;
  --radius: 12px;
  --radius-lg: 20px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 0 3px rgba(0,113,227,0.15);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  line-height: 1.5;
}

body::before {
  content: none;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

.page-title {
  margin: 0 0 4px;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.small, .muted, .hint { color: var(--muted); font-size: 12px; }
.small { font-size: 12px; }

/* ===== iOS/Apple Cards ===== */
.card {
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.card:hover {
  box-shadow: var(--shadow);
}

.card h3, .card h4 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* ===== KPI ===== */
.kpi-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.kpi-value {
  margin-top: 4px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* ===== Grids ===== */
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.main-grid { display: grid; gap: 14px; }

/* ===== Pills ===== */
.status-pill, .pill {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
}

.running { color: var(--success); }
.stopped { color: var(--danger); }

.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
}

/* ===== Inputs ===== */
input, select, textarea {
  width: 100%;
  min-height: 44px;
  font-size: 15px;
  font-family: var(--font);
  padding: 11px 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

input::placeholder { color: var(--muted); }

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  display: block;
  margin-bottom: 6px;
  letter-spacing: 0;
}

/* ===== Buttons ===== */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  letter-spacing: 0;
}

.btn-pri {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,113,227,0.2);
}

.btn-pri:hover {
  background: var(--primary-2);
  box-shadow: 0 6px 20px rgba(0,113,227,0.28);
  transform: translateY(-0.5px);
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-ghost:hover {
  background: rgba(0,113,227,0.06);
}

button[type="submit"], button[type="button"] {
  background: var(--primary);
  color: #fff;
  min-height: 44px;
  padding: 0 22px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,113,227,0.2);
  font-size: 14px;
}

button[type="submit"]:hover {
  transform: translateY(-0.5px);
  box-shadow: 0 6px 20px rgba(0,113,227,0.28);
}

button.danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255,59,48,0.2);
}

/* ===== Score Cards ===== */
.score-cards { display: grid; gap: 10px; }

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ===== Mobile Nav ===== */
.mobile-quick-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.mobile-quick-nav a {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.mobile-quick-nav a.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== Topbar ===== */
.topbar {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar select, .toolbar input {
  min-height: 38px;
  font-size: 13px;
  padding: 8px 12px;
}

/* ===== Section gap ===== */
.section-gap-sm { margin-top: 8px; }
.section-gap-md { margin-top: 18px; }

/* ===== Field desc ===== */
.field-desc {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  line-height: 1.4;
}

/* ===== Badge ===== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
}

/* ===== Footer ===== */
.footer {
  color: var(--muted);
  font-size: 12px;
  margin-top: 32px;
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ===== API card ===== */
.api-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

/* ===== Toggle ===== */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: auto;
  accent-color: var(--primary);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

/* ===== Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card { animation: fadeInUp 0.35s cubic-bezier(0.25, 0.1, 0.25, 1); }
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }

/* ===== Table scroll ===== */
.table-scroll { overflow-x: auto; }
.mobile-table-cards { -webkit-overflow-scrolling: touch; }

/* ===== Actions bar ===== */
.actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ===== Events pager ===== */
.events-pager { justify-content: center; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .kpi-value { font-size: 24px; }
  .wrap { padding: 16px 14px 40px; }
  .page-title { font-size: 1.3rem; }
}

@media (min-width: 641px) {
  .mobile-only { display: none; }
}

/* ===== Row grid ===== */
.row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.row-3 { grid-template-columns: repeat(3, 1fr); }

/* ===== Details/Summary ===== */
details { margin-bottom: 8px; }
summary { cursor: pointer; font-weight: 500; padding: 8px 0; }
details[open] summary { border-bottom: 1px solid var(--line); }
ul.small { padding-left: 18px; }
ul.small li { margin-bottom: 4px; color: var(--text-2); font-size: 13px; }
ul.small li b { color: var(--text); }

/* ===== Help widget ===== */
.help-widget-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,113,227,0.25);
}

/* ===== Nav pills ===== */
.nav-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.nav-pills a {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: all 0.2s;
}

.nav-pills a:hover {
  background: var(--bg-3);
}

.nav-pills a.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ===== Status indicators ===== */
.ok { color: var(--success); font-weight: 600; }
.warn { color: var(--warning); font-weight: 600; }
.err { color: var(--danger); font-weight: 600; }
/* KPI dashboard — 5 column grid */
.dashboard-kpis { margin-bottom: 2px; }
.dashboard-kpis .card {
  padding: 14px 12px 12px;
  text-align: center;
}
.dashboard-kpis .kpi-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-top: 2px;
}
.dashboard-kpis .kpi-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 500;
}

/* ===== Dark Theme ===== */
body.dark {
  --bg: #0a0a0f;
  --bg-2: #111118;
  --bg-3: #1a1a24;
  --surface: rgba(255,255,255,0.05);
  --surface-2: rgba(255,255,255,0.08);
  --line: rgba(255,255,255,0.08);
  --line-2: rgba(255,255,255,0.14);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --muted: #8e8e93;
}

body.dark {
  background: var(--bg);
}

body.dark .card {
  background: var(--surface);
  border-color: var(--line);
}

body.dark input, body.dark select, body.dark textarea {
  background: rgba(255,255,255,0.04);
  border-color: var(--line-2);
  color: var(--text);
}

body.dark tr:hover td {
  background: var(--surface);
}

body.dark .topbar .status {
  color: var(--success);
}

body.dark .toolbar select, body.dark .toolbar input {
  background: rgba(255,255,255,0.04);
  border-color: var(--line);
}
