:root {
  --bg: #0f1220;
  --panel: #1a1e33;
  --card: #232849;
  --accent: #e63946;
  --text: #f0f0f5;
  --muted: #9a9db8;
  --border: #2f3560;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

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

nav { display: flex; gap: 0.5rem; }

.nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
}

.nav-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* .nav-btn is also used on the report page's "Dashboard" link and the
   dashboard's "Report" link, both plain <a> tags rather than <button>s. */
a.nav-btn {
  text-decoration: none;
  display: inline-block;
}

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

.view { display: none; }
.view.active { display: block; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

/* !important is deliberate: .hidden is a utility class meant to always win
   regardless of what other display rules exist for an element (e.g.
   .auth-screen sets display: flex later in this file — without !important,
   equal specificity means the later rule wins on source order alone, and
   .hidden silently loses even though the class is correctly applied). */
.hidden { display: none !important; }

.panel h2 { margin-top: 0; font-size: 1.05rem; }

form { display: flex; gap: 0.5rem; flex-wrap: wrap; }

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
  flex: 1;
  min-width: 200px;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
}

/* Date inputs render a browser-native calendar icon that ignores `color`;
   invert it so it's visible against the dark background. */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
}

textarea { resize: vertical; }

.stacked-form {
  flex-direction: column;
  align-items: stretch;
}

.stacked-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.stacked-form .form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stacked-form .form-row label { flex: 1; min-width: 160px; }
.stacked-form .form-row.three label { min-width: 100px; }

.stacked-form button[type="submit"] { align-self: flex-start; }

.hint { font-size: 0.8rem; color: var(--muted); font-weight: 400; }

.round-delete {
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
}

.round-delete:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button[type="submit"] {
  padding: 0.55rem 1.25rem;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
}

.status { color: var(--muted); min-height: 1.2em; }

.btn-remove {
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
}
.btn-remove:hover { border-color: var(--accent); color: var(--accent); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.card:hover { border-color: var(--accent); }

.card h3 { margin: 0 0 0.3rem 0; font-size: 1rem; }
.card p { margin: 0.15rem 0; color: var(--muted); font-size: 0.85rem; }

.stat-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.stat-row span { color: var(--muted); font-size: 0.9rem; }
.stat-row strong { color: var(--text); font-size: 1.1rem; }

.detail-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 750px) {
  .detail-columns { grid-template-columns: 1fr; }
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

table th, table td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

table th { color: var(--muted); font-weight: 600; }

.table-scroll { overflow-x: auto; }

.import-table input[type="text"],
.import-table input[type="number"],
.import-table select {
  width: 100%;
  min-width: 70px;
  padding: 0.3rem 0.4rem;
  font-size: 0.85rem;
}

.import-table td { vertical-align: top; }

.import-table .row-remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
}

.import-table .row-remove-btn:hover { color: var(--accent); }

/* Auth screens (login / 2FA challenge / 2FA enrollment) */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}

.auth-card h1 {
  font-size: 1.2rem;
  margin: 0 0 0.5rem 0;
}

.auth-card h2 {
  font-size: 1rem;
  margin: 1.25rem 0 0.4rem 0;
}

.auth-card .stacked-form {
  margin-top: 1rem;
}

.auth-card button[type="submit"] {
  width: 100%;
  margin-top: 0.25rem;
}

.link-btn {
  display: block;
  width: 100%;
  text-align: center;
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.85rem;
  margin-top: 0.75rem;
  padding: 0.25rem;
}

.link-btn:hover { color: var(--accent); }

.qr-container {
  display: flex;
  justify-content: center;
  padding: 1rem;
  background: #ffffff;
  border-radius: 8px;
  margin: 1rem 0;
  min-height: 130px;
  align-items: center;
}

.qr-container:empty::before {
  content: "Generating QR code…";
  color: #333;
  font-size: 0.8rem;
}

code {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.85rem;
  word-break: break-all;
}

.recovery-codes {
  list-style: none;
  margin: 0.5rem 0 1rem 0;
  padding: 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
}

#enroll-continue-btn {
  padding: 0.55rem 1.25rem;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
  width: 100%;
}

/* App shell header additions */

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#current-user-label {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Team account management */

.team-accounts-list {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
}

.team-accounts-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.team-accounts-list li:last-child { border-bottom: none; }

.role-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: 0.5rem;
}
