/* Visual system aligned with the Digi Dashboard: zinc surfaces and RapidSOS green. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #09090b;
  --panel: #18181b;
  --panel-soft: rgba(24, 24, 27, 0.68);
  --line: #27272a;
  --line-light: #3f3f46;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --muted-dark: #71717a;
  --primary: #13ef93;
  --primary-soft: rgba(19, 239, 147, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

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

.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 9, 11, 0.92);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand:hover { text-decoration: none; }
.brand-logo { height: 26px; width: auto; object-fit: contain; }
.brand-divider { width: 1px; height: 20px; background: var(--line-light); }
.brand-name { color: var(--text); }

.user-account-menu { position: relative; }

.user-account-menu summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  max-width: min(280px, 55vw);
  padding: 0.3rem 0.55rem 0.3rem 0.3rem;
  border: 1px solid var(--line-light);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
  list-style: none;
}

.user-account-menu summary::-webkit-details-marker { display: none; }
.user-account-menu summary:hover { border-color: var(--muted); }

.user-account-menu summary img,
.user-avatar-fallback {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #27272a;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
}

.user-avatar-fallback[hidden] { display: none; }

.user-summary-name {
  overflow: hidden;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chevron {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.user-account-menu[open] .user-chevron { transform: rotate(180deg); }

.user-account-panel {
  position: absolute;
  right: 0;
  z-index: 20;
  width: 240px;
  margin-top: 0.5rem;
  padding: 0.75rem 0 0.5rem;
  overflow: hidden;
  border: 1px solid var(--line-light);
  border-radius: 0.75rem;
  background: #111113;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.user-account-name,
.user-account-email,
.user-account-role {
  margin: 0;
  padding: 0 0.9rem;
}

.user-account-name {
  overflow: hidden;
  font-size: 0.85rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-account-email {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-account-role {
  margin-top: 0.25rem;
  color: var(--primary);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.user-account-nav {
  display: flex;
  flex-direction: column;
  margin: 0.65rem 0;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.user-account-nav a {
  padding: 0.45rem 0.9rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.user-account-nav a:hover {
  background: var(--panel);
  color: var(--primary);
  text-decoration: none;
}

.user-logout {
  display: block;
  margin: 0.25rem 0.5rem 0.15rem;
  padding: 0.5rem 0.4rem;
  border-radius: 0.45rem;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.user-logout:hover { background: var(--danger-soft); text-decoration: none; }

.login-page {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
}

.login-logo { height: 64px; width: auto; margin-bottom: 2rem; object-fit: contain; }

.google-signin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  width: min(320px, 100%);
  min-height: 44px;
  padding: 0.7rem 1rem;
  border-radius: 0.55rem;
  background: #fff;
  color: #1f1f1f;
  font-weight: 700;
}

.google-signin:hover { background: #f4f4f5; text-decoration: none; }
.google-signin svg { width: 20px; height: 20px; }

.login-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 1rem;
  margin-top: 1.5rem;
  color: var(--muted-dark);
  font-size: 0.8rem;
}

.login-links a { color: var(--muted); }

.notice-card {
  width: min(420px, 100%);
  padding: 1.35rem 1.3rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel-soft);
  text-align: left;
}

.notice-card h1 { font-size: 1.35rem; }
.notice-detail { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.notice-actions { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 1.25rem; }
.notice-actions .btn { width: 100%; }

main {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 { margin: 0 0 0.2rem; font-size: 1.65rem; line-height: 1.2; }
h2 { margin: 0; font-size: 1rem; font-weight: 600; }
h3 { margin: 0; font-size: 1rem; }
p { margin: 0.15rem 0 0; }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.82rem; }
.ok { color: var(--primary); }
.bad { color: var(--danger); }
.warn { color: var(--warning); }

.banner {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--panel);
}

.banner.ok { border-color: rgba(19, 239, 147, 0.4); }
.banner.warn { border-color: rgba(251, 191, 36, 0.45); color: #fde68a; }
.banner-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.banner h2 { margin-bottom: 0.45rem; }
.banner p { margin: 0.35rem 0 0; color: var(--muted); }
.banner-note {
  margin-top: 0.75rem !important;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(19, 239, 147, 0.25);
  border-radius: 0.45rem;
  background: var(--primary-soft);
  color: var(--text) !important;
}
.banner-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.banner-close:hover { color: var(--text); }

code {
  padding: 0.12rem 0.45rem;
  border-radius: 0.35rem;
  background: var(--bg);
  color: var(--primary);
  font-family: var(--mono);
}

.panel,
.search-panel,
.empty-panel {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel-soft);
}

.panel { padding: 1.1rem 1.2rem; }
.center-actions { justify-content: center; }

.search-panel { padding: 1.25rem 1.3rem 1.3rem; }

.search-grid {
  display: grid;
  grid-template-columns: 160px 150px 130px minmax(0, 1fr);
  gap: 0.9rem;
}

.search-grid.open-search {
  grid-template-columns: 160px minmax(0, 1fr);
}

.field label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.field .hint { margin: 0.35rem 0 0; color: var(--muted-dark); font-size: 0.72rem; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 2.6rem; }

.char-count {
  position: absolute;
  top: 50%;
  right: 0.7rem;
  color: var(--muted-dark);
  font-size: 0.75rem;
  transform: translateY(-50%);
}

.char-count.complete { color: var(--primary); font-weight: 600; }

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line-light);
  border-radius: 0.4rem;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

textarea { min-height: 120px; padding: 0.55rem 0.7rem; }
.mono-input { font-family: var(--mono); font-size: 1rem; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input::placeholder { color: var(--muted-dark); }

.form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.loading-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
  color: var(--primary);
  font-weight: 600;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 36px;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--primary);
  border-radius: 0.4rem;
  background: var(--primary);
  color: #09090b;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover { background: #6ee7b7; text-decoration: none; }
.btn.secondary { border-color: var(--line-light); background: transparent; color: var(--text); }
.btn.secondary:hover { border-color: var(--primary); background: transparent; color: var(--primary); }
.btn.danger { border-color: var(--danger); background: transparent; color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn svg { width: 16px; height: 16px; }

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.cards article {
  min-height: 108px;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel-soft);
}

.cards span { display: block; color: var(--muted); font-size: 0.78rem; }
.cards strong { display: block; margin-top: 0.25rem; font-size: 1.75rem; line-height: 1.15; }

.table-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel-soft);
}

.access-list { margin-top: 1.25rem; }

.table-scroll { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; }

.grid th,
.grid td {
  padding: 0.75rem 0.8rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.grid th {
  background: rgba(24, 24, 27, 0.9);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.grid tbody tr:hover { background: rgba(39, 39, 42, 0.45); }
.grid tbody tr:last-child td { border-bottom: 0; }
.time-cell { white-space: nowrap; font-size: 0.76rem; }
.subline { display: block; margin-top: 0.15rem; color: var(--muted-dark); font-size: 0.72rem; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-badge span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.healthy { background: var(--primary-soft); color: var(--primary); }
.status-badge.error { background: var(--danger-soft); color: var(--danger); }

.pill {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border: 1px solid rgba(19, 239, 147, 0.45);
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
}

.phone-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.phone-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.phone-card:hover { border-color: var(--primary); background: var(--panel); }

.phone-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.phone-icon svg { width: 18px; height: 18px; }
.phone-card strong { display: block; font-size: 1.05rem; }
.phone-card .muted { display: block; margin-top: 0.15rem; font-size: 0.8rem; }

.empty-panel { padding: 3rem 1.5rem; text-align: center; }
.empty-panel h2 { margin-bottom: 0.35rem; font-size: 1.15rem; }

.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.empty-icon svg { width: 28px; height: 28px; }

.results-block { margin-top: 1.5rem; }
.results-block .page-heading { margin-bottom: 0.9rem; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.62);
}

.modal-card {
  width: min(440px, 100%);
  padding: 1.25rem 1.3rem 1.2rem;
  border: 1px solid var(--line-light);
  border-radius: 0.75rem;
  background: var(--panel);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

.modal-card p { margin-top: 0.7rem; color: var(--muted); }
.accent { color: var(--primary); font-weight: 700; }
.modal-actions { display: flex; gap: 0.6rem; margin-top: 1.25rem; }
.modal-actions .btn { flex: 1; }

.toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  max-width: min(420px, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  border: 1px solid var(--line-light);
  border-radius: 0.6rem;
  background: #111113;
  color: var(--text);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.toast-success { border-color: rgba(19, 239, 147, 0.45); color: var(--primary); }
.toast-error { border-color: rgba(248, 113, 113, 0.5); color: var(--danger); }
.toast-info { color: var(--text); }
.toast-row { display: flex; align-items: flex-start; gap: 0.75rem; }
.toast-row p { margin: 0; font-weight: 600; }
.toast-row button {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
}

.help-list { margin: 0.6rem 0 0; padding-left: 1.2rem; color: var(--muted); }
.help-list code { color: var(--muted); }
.help-list .ok code { color: var(--primary); }
.help-list li { margin: 0.45rem 0; }
.help-list strong { color: var(--text); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.help-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.25rem; }
.copy-row { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.55rem; }
.copy-row code { flex: 1; padding: 0.55rem 0.7rem; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .search-grid { grid-template-columns: 1fr 1fr; }
  .field-authority { grid-column: 1 / -1; }
  .cards { grid-template-columns: 1fr; }
  .page-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 600px) {
  main { padding: 1.25rem 0.75rem 2rem; }
  .topbar { padding: 0 0.75rem; }
  .brand { gap: 0.5rem; font-size: 0.72rem; }
  .brand-logo { height: 20px; }
  .user-summary-name { display: none; }
  .search-grid, .phone-grid { grid-template-columns: 1fr; }
  .form-actions, .modal-actions { flex-direction: column; }
  .help-actions .btn { width: 100%; }
}
