/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inconsolata:wght@200..900&display=swap');

/* ---------- CSS variables ---------- */
:root {
  --font: 'Inconsolata', monospace;
  --radius: 2px;
  --max-w: 700px;
  --gap: 1.25rem;
}

/* Light theme (default) */
[data-theme='light'],
:root:not([data-theme='dark']) {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #666666;
  --accent: #0066cc;
  --label-bg: #f0f4ff;
  --label-text: #003d99;
  --group-header: #e8ecf5;
}

/* Dark theme */
[data-theme='dark'] {
  --bg: #121212;
  --surface: #1e1e1e;
  --border: #333333;
  --text: #e8e8e8;
  --text-muted: #999999;
  --accent: #5599ff;
  --label-bg: #1a2540;
  --label-text: #99bbff;
  --group-header: #252535;
}

/* System theme: auto based on prefers-color-scheme */
@media (prefers-color-scheme: dark) {
  :root[data-theme='system'] {
    --bg: #121212;
    --surface: #1e1e1e;
    --border: #333333;
    --text: #e8e8e8;
    --text-muted: #999999;
    --accent: #5599ff;
    --label-bg: #1a2540;
    --label-text: #99bbff;
    --group-header: #252535;
  }
}

@media (prefers-color-scheme: light) {
  :root[data-theme='system'] {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --border: #e0e0e0;
    --text: #1a1a1a;
    --text-muted: #666666;
    --accent: #0066cc;
    --label-bg: #f0f4ff;
    --label-text: #003d99;
    --group-header: #e8ecf5;
  }
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 1rem;
  transition: background 0.2s, color 0.2s;
}

/* ---------- Layout ---------- */
.page {
  max-width: var(--max-w);
  margin: 0 auto;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap);
  gap: 0.5rem;
  flex-wrap: wrap;
}

h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

/* ---------- Theme toggle ---------- */
#theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
#theme-toggle:hover { border-color: var(--accent); }

#refresh {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
#refresh:hover:not(:disabled) { border-color: var(--accent); }
#refresh:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: var(--gap);
}

.card-header {
  background: var(--group-header);
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

/* ---------- Field table ---------- */
.fields {
  width: 100%;
  border-collapse: collapse;
}

.fields tr + tr td,
.fields tr + tr th { border-top: 1px solid var(--border); }

.fields td, .fields th {
  padding: 0.55rem 1rem;
  vertical-align: top;
  text-align: left;
  font-size: 0.9rem;
}

.fields th {
  width: 38%;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.fields td {
  color: var(--text);
  word-break: break-all;
}

.fields .highlight td,
.fields .highlight th {
  font-weight: 700;
}

.fields .highlight td {
  font-size: 1rem;
}

.badge {
  display: inline-block;
  background: var(--label-bg);
  color: var(--label-text);
  padding: 0.15em 0.5em;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: 600;
}

/* ---------- Status / error ---------- */
#status {
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.error {
  color: #cc3300;
  background: #fff0ed;
  border: 1px solid #ffccbb;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}

[data-theme='dark'] .error {
  color: #ff8866;
  background: #2a1a14;
  border-color: #5a2a1a;
}

/* ---------- Footer ---------- */
footer {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--gap);
  padding-bottom: 1rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  body { padding: 0.5rem; }
  h1 { font-size: 1.1rem; }

  .fields th, .fields td { padding: 0.45rem 0.75rem; }

  .fields th {
    width: 40%;
    font-size: 0.8rem;
  }

  .fields td { font-size: 0.85rem; }
}
