/* Define variables per theme */
:root[data-theme="dark"] {
  --bg: #0f172a;
  --card: #111827;
  --fg: #e5e7eb;
  --muted: #9ca3af;
  --border: #1f2937;
  --primary: #3b82f6;
  --primary-contrast: #ffffff;
  --danger: #ef4444;
}
:root[data-theme="light"] {
  --bg: #f8fafc;
  --card: #ffffff;
  --fg: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-contrast: #ffffff;
  --danger: #dc2626;
}

/* Global layout */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

/* Navbar */
.navbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.navbar .brand {
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}
.navbar .links, .navbar .actions { display: inline-flex; align-items: center; }
.links.gap-16 { gap: 16px; }
.actions.gap-12 { gap: 12px; }
.navbar .links a, .navbar .actions a {
  margin: 0; color: var(--muted); text-decoration: none;
}
.navbar .links a.active, .navbar .links a:hover,
.navbar .actions a.active, .navbar .actions a:hover { color: var(--fg); }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  overflow: hidden;
}
.section { /* wrapper if needed */ }

/* Section header (title + action link) */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-header h2 { margin: 0; }

/* Quiet header link (no box) */
.link-quiet {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  line-height: 1;
  padding: 4px 0;
}
.link-quiet:hover { color: var(--fg); text-decoration: underline; }
/* Reset any accidental button styles on header anchors */
.section.card .section-header a {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 4px 0;
  border-radius: 0;
}

/* Grid: responsive card tiles */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1024px) { .grid.cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 768px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .grid, .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* Card tile */
.card-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.card-tile:hover {
  border-color: color-mix(in srgb, var(--border) 60%, var(--primary) 40%);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--fg) 12%, transparent);
}
.card-tile .tile-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-tile .tile-title {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-tile .tile-title .icon-btn {
  margin-left: auto;     /* push icon to the far right */
  flex-shrink: 0;
}
.card-tile .tile-subtitle { color: var(--muted); margin-top: 6px; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); font-size: 12px;
}

/* Buttons */
.btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-secondary { background: transparent; color: var(--fg); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: var(--primary-contrast); }

/* Icon buttons */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent; color: var(--fg);
  padding: 0; cursor: pointer;
}
.icon-btn:hover {
  border-color: color-mix(in srgb, var(--border) 70%, var(--fg) 30%);
}
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.lg { width: 60px; height: 30px; }
.icon { width: 18px; height: 18px; fill: var(--muted); }
:root[data-theme="dark"] .icon { fill: var(--fg); }
:root[data-theme="light"] .icon { fill: var(--muted); }

/* Links */
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Forms */
label { display: block; margin-top: 12px; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"] {
  display: block; width: 100%; max-width: 100%;
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  margin-top: 6px;
}

/* Spacing utils */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mr-8 { margin-right: 8px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.space-between { justify-content: space-between; }

/* Modal (kept minimal, already used) */
.modal.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 1000; }
.modal-backdrop { position: absolute; inset: 0; background: color-mix(in srgb, var(--fg) 15%, transparent); }
.modal-card {
  position: relative; margin: 10vh auto 0 auto; width: 90%; max-width: 520px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 40px color-mix(in srgb, var(--fg) 20%, transparent);
}
.modal-header, .modal-footer { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 16px; }
.modal-footer { border-bottom: none; display: flex; justify-content: flex-end; gap: 8px; }
.text-center { text-align: center; }

/* Fields */
.field {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.field:last-child { border-bottom: 0; }
.field .label { color: var(--muted); font-weight: 600; letter-spacing: 0.15px; }
.field .label::after { content: ": "; }  /* fallback if markup misses colon */
.field .value { color: var(--fg); }
.value .icon-btn.copy { margin-left: 6px; vertical-align: middle; }
.icon-btn.copy.sm .icon { width: 16px; height: 16px; }

/* NEW: secret text + eye icon */
.secret { font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
.secret.masked { letter-spacing: 1px; }
.value .icon-btn.toggle { margin-left: 6px; vertical-align: middle; }
.icon-btn.toggle.sm .icon { width: 16px; height: 16px; }

.p-5 { padding: 5px; }
.p-10 { padding: 10px; }
.p-16 { padding: 16px; }

.mr-10 { margin-right: 10px; }
.mb-10 { margin-bottom: 10px; }
.m-16 { margin: 16px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  margin-top: 8px;
}
.tabs .tab {
  appearance: none;
  background: transparent;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--muted, #6b7280);
  border-bottom: 2px solid transparent;
}
.tabs .tab.active {
  color: var(--fg, #111827);
  border-bottom-color: var(--accent, #3b82f6);
  font-weight: 600;
}
.tab-panels .tab-panel.hidden { display: none; }