:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sidebar: #0f172a;
  --sidebar-2: #1e293b;
  --sidebar-text: #cbd5e1;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { min-height: 100vh; overflow-x: hidden; background: var(--bg); color: var(--text); font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; }
button, input, select, textarea { font: inherit; }

.top-header { position: fixed; inset: 0 0 auto 0; height: 64px; z-index: 1000; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; color: white; background: linear-gradient(90deg, #111827, #1e293b); box-shadow: 0 2px 12px rgba(15,23,42,.24); }
.header-left, .header-right { display: flex; align-items: center; gap: 14px; }
.header-left h2 { line-height: 1; font-size: 20px; }
.header-left small { color: #cbd5e1; font-size: 12px; }
.toggle-btn, .search-btn { width: 42px; height: 42px; border: 0; border-radius: 12px; color: white; background: rgba(255,255,255,.08); cursor: pointer; }
.toggle-btn:hover, .search-btn:hover { background: rgba(255,255,255,.14); }
.user-menu-container { position: relative; }
.user-profile-btn { display: flex; align-items: center; gap: 8px; border: 0; color: white; background: rgba(255,255,255,.08); padding: 7px 10px; border-radius: 999px; cursor: pointer; }
.user-profile { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: #334155; }
.user-dropdown { position: absolute; top: calc(100% + 12px); right: 0; min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); visibility: hidden; opacity: 0; transform: translateY(-6px); transition: .18s ease; overflow: hidden; }
.user-dropdown.show { visibility: visible; opacity: 1; transform: translateY(0); }
.user-dropdown a { display: flex; gap: 10px; align-items: center; padding: 12px 14px; color: var(--text); text-decoration: none; }
.user-dropdown a:hover { background: var(--surface-soft); color: var(--primary); }
.divider { height: 1px; background: var(--border); }

.app-container { display: flex; height: 100vh; padding-top: 64px; }
.sidebar { width: 260px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; padding: 14px 10px; color: var(--sidebar-text); background: linear-gradient(180deg, var(--sidebar-2), var(--sidebar)); transition: width .25s ease, left .25s ease; overflow-y: auto; }
.sidebar.collapsed { width: 76px; }
.menu-item { width: 100%; border: 0; background: transparent; color: inherit; text-decoration: none; }
.menu-link { display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 0 14px; border-radius: 14px; cursor: pointer; text-align: left; color: var(--sidebar-text); }
.menu-link:hover, .menu-link.active { color: white; background: rgba(255,255,255,.1); }
.menu-link.active { box-shadow: inset 3px 0 0 #60a5fa; }
.icon { width: 24px; text-align: center; font-size: 18px; }
.menu-text { white-space: nowrap; overflow: hidden; transition: opacity .16s ease; }
.sidebar.collapsed .menu-text, .sidebar.collapsed .arrow { opacity: 0; width: 0; display: none; }
.sidebar.collapsed .menu-link { justify-content: center; padding: 0; }
.arrow { margin-left: auto; transition: transform .2s ease; }
.has-dropdown.active .arrow { transform: rotate(90deg); }
.dropdown-menu { max-height: 0; overflow: hidden; transition: max-height .22s ease; }
.has-dropdown.active .dropdown-menu { max-height: 320px; }
.dropdown-item { display: block; margin: 4px 0 4px 52px; padding: 9px 10px; border-radius: 10px; color: #cbd5e1; text-decoration: none; }
.dropdown-item:hover { color: white; background: rgba(255,255,255,.08); }
.sidebar.collapsed .dropdown-menu { display: block; }
.sidebar-overlay { display: none; }
.sidebar-drawer-head { display: none; }

.main-content { flex: 1; min-width: 0; overflow-y: auto; padding: 24px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.page-hero { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 26px; margin-bottom: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(135deg, #ffffff, #eef5ff); box-shadow: var(--shadow); }
.page-hero h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.05; margin: 4px 0 8px; }
.page-hero p { color: var(--muted); max-width: 720px; }
.eyebrow { font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--primary) !important; font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card, .content-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card { padding: 18px; }
.stat-card p { color: var(--muted); font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.stat-card strong { display: block; font-size: 24px; }
.stat-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; margin-bottom: 10px; border-radius: 12px; color: var(--primary); background: #eff6ff; }
.content-card { padding: 20px; margin-bottom: 20px; }
.content-card h2 { display: flex; align-items: center; gap: 10px; font-size: 20px; margin-bottom: 16px; }
.card-title-row { display: flex; justify-content: space-between; gap: 14px; align-items: center; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 16px; }
.form-grid.two-col { grid-template-columns: repeat(2, minmax(200px, 1fr)); }
label { display: flex; flex-direction: column; gap: 7px; color: #334155; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; background: white; outline: none; font-family: inherit; }
input:focus, select:focus, textarea:focus { border-color: #93c5fd; box-shadow: 0 0 0 4px rgba(37,99,235,.10); }
textarea { resize: vertical; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.button-row.compact { margin-top: 0; }
.primary-btn, .secondary-btn, .file-load-btn, .action-btn { border: 0; border-radius: 12px; padding: 11px 14px; cursor: pointer; font-weight: 800; }
.icon-btn {
  border: 0;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0f172a;
  background: #e2e8f0;
  cursor: pointer;
  font-size: 15px;
}
.icon-btn:hover { background: #cbd5e1; }
.primary-btn { color: white; background: var(--primary); }
.primary-btn:hover { background: var(--primary-dark); }
.secondary-btn, .file-load-btn { color: #0f172a; background: #e2e8f0; }
.secondary-btn:hover, .file-load-btn:hover { background: #cbd5e1; }

/* ============================================================
   Chores tab
   ============================================================ */
.chores-kid-card { cursor: pointer; text-align: left; transition: box-shadow .15s ease, transform .15s ease; }
.chores-kid-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.08); transform: translateY(-1px); }
.chores-kid-pending { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

.chores-item-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 20px; }
.chores-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  flex-wrap: wrap;
}
.chores-item-selectable { cursor: pointer; }
.chores-item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chores-item-text strong { font-size: 15px; }
.chores-item-sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.chores-item-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chores-rate-input { width: 90px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }

.danger-btn { border: 0; border-radius: 12px; padding: 11px 14px; cursor: pointer; font-weight: 800; color: white; background: #dc2626; }
.danger-btn:hover { background: #b91c1c; }
.file-load-btn input { display: none; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: #f8fafc; color: #334155; font-size: 13px; }
.action-btn { padding: 8px 10px; margin-right: 6px; }
.edit-btn { color: #92400e; background: #fef3c7; }
.delete-btn { color: #991b1b; background: #fee2e2; }
.summary-box { line-height: 1.7; padding: 16px; border-radius: 14px; background: #f8fafc; color: #334155; }
.schedule-wrap { max-height: 460px; overflow: auto; }

@media (max-width: 1000px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } .form-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
  .top-header { padding: 0 12px; }
  .header-left small { display: none; }
  .header-left h2 { font-size: 17px; }
  .sidebar { position: fixed; top: 64px; bottom: 0; left: -280px; width: 260px; z-index: 999; padding-bottom: 24px; }
  .sidebar.mobile-open { left: 0; box-shadow: 12px 0 32px rgba(15,23,42,.28); }
  .sidebar.collapsed { width: 260px; }
  .sidebar.collapsed .menu-text, .sidebar.collapsed .arrow { display: inline; opacity: 1; width: auto; }
  .sidebar.collapsed .menu-link { justify-content: flex-start; padding: 0 14px; }
  .sidebar-overlay.active { display: block; position: fixed; inset: 64px 0 0 0; background: rgba(15,23,42,.48); z-index: 998; }
  .menu-link { min-height: 50px; }
  .sidebar-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px 14px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,.1);
  }
  .sidebar-drawer-title { opacity: 1 !important; width: auto !important; display: inline !important; color: white; font-weight: 800; font-size: 15px; }
  .sidebar-drawer-close { width: 36px; height: 36px; border: 0; border-radius: 10px; background: rgba(255,255,255,.08); color: white; cursor: pointer; }

  .main-content { padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }
  .page-hero { flex-direction: column; align-items: flex-start; padding: 18px; gap: 14px; }
  .page-hero .primary-btn { width: 100%; justify-content: center; display: inline-flex; align-items: center; gap: 8px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card strong { font-size: 19px; }
  .form-grid, .form-grid.two-col { grid-template-columns: 1fr; }
  .content-card { padding: 16px; }

  /* Bigger, easier tap targets */
  .primary-btn, .secondary-btn, .file-load-btn, .action-btn, input, select {
    min-height: 44px;
  }
  .action-btn { margin-right: 0; }
  .button-row { gap: 8px; }
  .button-row .action-btn { flex: 1 1 auto; }
  .card-title-row { align-items: flex-start; }
  .card-title-row .button-row.compact { width: 100%; }
  .card-title-row .button-row.compact .secondary-btn,
  .card-title-row .button-row.compact .file-load-btn { flex: 1 1 auto; text-align: center; }

  .table-wrap { -webkit-overflow-scrolling: touch; }
}

/* ---------- Bottom tab bar (mobile only) ---------- */
.bottom-nav { display: none; }

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 997;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px rgba(15,23,42,.10);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 54px;
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 12px;
    cursor: pointer;
  }
  .bottom-nav-item i { font-size: 17px; }
  .bottom-nav-item span { font-size: 11px; font-weight: 700; }
  .bottom-nav-item:active { background: var(--surface-soft); }
  .bottom-nav-item.active { color: var(--primary); }
}

/* ---------- Responsive "card" tables ---------- */
@media (max-width: 768px) {
  table.responsive-table { min-width: 0; }
  table.responsive-table thead { display: none; }
  table.responsive-table tbody { display: block; }
  table.responsive-table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 12px;
    padding: 4px 12px;
    background: var(--surface);
  }
  table.responsive-table tbody tr td[colspan] { border: 0; padding: 12px 4px; }
  table.responsive-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: right;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  table.responsive-table tbody td:last-child { border-bottom: 0; }
  table.responsive-table tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--muted);
    text-align: left;
    margin-right: auto;
  }
  table.responsive-table tbody td.action-cell {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  table.responsive-table tbody td.action-cell::before { margin-bottom: 2px; }
  table.responsive-table tbody td.action-cell .action-btn { width: 100%; margin: 0; }
  table.responsive-table.admin-table select, table.responsive-table select { width: 100%; min-width: 0; }

  /* Schedule table stays a true table (too many dynamic columns for cards) —
     keep it scrollable but pin the first two columns so Pmt#/Date stay visible */
  .schedule-wrap table th:first-child, .schedule-wrap table td:first-child,
  .schedule-wrap table th:nth-child(2), .schedule-wrap table td:nth-child(2) {
    position: sticky;
    background: var(--surface);
    z-index: 1;
  }
  .schedule-wrap table th:first-child, .schedule-wrap table td:first-child { left: 0; }
  .schedule-wrap table th:nth-child(2), .schedule-wrap table td:nth-child(2) { left: 56px; }
  .schedule-wrap table th { background: #f8fafc; }
}

.error-text {
  color: #dc2626;
  font-weight: 700;
}

/* Accessible focus ring for keyboard/switch users, without adding
   an outline on mouse click */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .auth-modal-close, .nexis-json-close {
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
  }
}

.action-cell {
  white-space: nowrap;
}

.user-dropdown a.is-working { pointer-events: none; opacity: .75; }

/* Auth menu state */
.hidden {
  display: none !important;
}

.user-profile-btn.logged-out span {
  min-width: 46px;
  font-size: 12px;
}

.user-profile-btn.logged-in span {
  min-width: auto;
}

/* Small status dot on the avatar so login state is visible at a
   glance without opening the dropdown. */
.user-profile-btn { position: relative; }
.user-profile-btn::after {
  content: "";
  position: absolute;
  bottom: 4px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid #1e293b;
  background: #64748b;
}
.user-profile-btn.logged-in::after { background: #22c55e; }
.user-profile-btn.logged-out::after { background: #64748b; }

.user-dropdown a.is-working {
  pointer-events: none;
  opacity: 0.75;
}


/* User/Admin Settings */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.full-span {
  grid-column: 1 / -1;
}

.status-text {
  min-height: 20px;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 700;
}

.success-text {
  color: #15803d;
}

.admin-create-form {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.admin-create-form h3 {
  margin-bottom: 12px;
}

.form-action-align {
  display: flex;
  align-items: end;
}

.admin-table select {
  min-width: 130px;
  padding: 8px 10px;
}

.admin-table td {
  vertical-align: middle;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.55);
}

.auth-modal.hidden {
  display: none !important;
}

.auth-modal-card {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 14px;
}

.auth-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
}


/* NexisPlat chat result containment and full JSON viewer */
.nexis-chat-jobs,
.nexis-job-card,
.nexis-job-header,
.nexis-job-result,
.nexis-message-text {
  min-width: 0;
  max-width: 100%;
}

.nexis-job-card {
  width: 100%;
  overflow: hidden;
}

.nexis-job-prompt,
.nexis-job-status,
.nexis-message-text,
.nexis-job-id {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.nexis-job-result {
  max-height: 520px;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: .4rem;
}

.nexis-job-result h4 {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 0 .65rem;
  padding: .35rem 0;
  background: var(--surface, #fff);
}

.nexis-message-text {
  white-space: pre-wrap;
  line-height: 1.55;
}

.nexis-code-block {
  max-width: 100%;
  overflow: auto;
  white-space: pre;
}

.nexis-json-modal {
  position: fixed;
  inset: 0;
  z-index: 120000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .72);
}

.nexis-json-modal.hidden {
  display: none !important;
}

.nexis-json-modal-card {
  width: min(1100px, calc(100vw - 36px));
  height: min(820px, calc(100vh - 36px));
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 16px;
  background: var(--surface, #fff);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .35);
}

.nexis-json-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.nexis-json-modal-header h2 {
  margin: 0 0 4px;
}

.nexis-json-job-id {
  color: var(--muted, #64748b);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.nexis-json-close {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.nexis-json-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.nexis-json-output {
  flex: 1;
  min-height: 0;
  max-width: 100%;
  margin: 0;
  padding: 18px;
  overflow: auto;
  background: #0f172a;
  color: #e2e8f0;
  white-space: pre;
  tab-size: 2;
}

.nexis-json-output code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.nexis-json-error {
  padding: 16px 18px;
}

.nexis-history-modal-card {
  height: min(560px, calc(100vh - 36px));
}

.nexis-history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 14px 14px;
}

@media (max-width: 600px) {
  .nexis-job-result {
    max-height: 420px;
  }

  .nexis-json-modal {
    padding: 8px;
  }

  .nexis-json-modal-card {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }
}

/* ============================================================
   Chat thread (conversation-style layout for the NexisPlat chat)
   ============================================================ */
.nexis-chat-card { display: flex; flex-direction: column; }

.nexis-chat-thread {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 60vh;
  min-height: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 4px 10px;
  margin-bottom: 14px;
  scroll-behavior: smooth;
}

.nexis-chat-empty {
  margin: auto;
  color: var(--muted);
  font-style: italic;
  padding: 24px 0;
  text-align: center;
}

.nexis-chat-login-action {
  display: block;
  margin: 0 auto;
}

.nexis-turn { display: flex; flex-direction: column; gap: 8px; }

.nexis-bubble {
  max-width: 82%;
  border-radius: 16px;
  padding: 12px 14px;
  min-width: 0;
}

.nexis-bubble-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.nexis-bubble-user {
  align-self: flex-end;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-bottom-right-radius: 4px;
}

.nexis-bubble-user .nexis-bubble-label { justify-content: flex-end; }

.nexis-bubble-label .nexis-diagnostics-btn {
  width: 22px;
  height: 22px;
  font-size: 13px;
  background: transparent;
  color: var(--muted, #64748b);
  margin-left: auto;
}
.nexis-bubble-label .nexis-diagnostics-btn:hover { background: var(--surface, #e2e8f0); color: var(--primary); }

.nexis-bubble-assistant {
  align-self: flex-start;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  width: 100%;
  max-width: 92%;
}

.nexis-bubble-text {
  white-space: pre-wrap;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.nexis-bubble-attachments {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.nexis-bubble-status {
  font-size: 14px;
  color: var(--muted);
}

.nexis-bubble-result {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  max-height: 480px;
  overflow: auto;
}

.nexis-status-pill {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: .03em;
  background: #e2e8f0;
  color: #334155;
}

.nexis-status-queued, .nexis-status-running { background: #dbeafe; color: #1e3a8a; }
.nexis-status-complete { background: #dcfce7; color: #14532d; }
.nexis-status-failed { background: #fee2e2; color: #7f1d1d; }

.nexis-progress-bar {
  margin-top: 8px;
  height: 6px;
  border-radius: 3px;
  background: #e2e8f0;
  overflow: hidden;
}
.nexis-progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width .4s ease;
  width: 0%;
}

.nexis-findings-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}
.nexis-findings-table th,
.nexis-findings-table td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.nexis-findings-table th {
  font-weight: 700;
  color: #475569;
}
.nexis-limitations,
.nexis-citations {
  margin-top: 10px;
  font-size: 12px;
  color: #64748b;
}

.nexis-composer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.nexis-composer textarea { margin-top: 10px; }

@media (max-width: 768px) {
  .nexis-bubble { max-width: 92%; }
  .nexis-chat-thread { max-height: 50vh; }
}

/* ============================================================
   Admin dashboard tools (Home tab, admins only)
   ============================================================ */
.admin-badge {
  font-size: 12px;
  font-weight: 800;
  color: #92400e;
  background: #fef3c7;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.admin-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.admin-tool-tile {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: var(--surface-soft);
}

.admin-tool-tile h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  margin-bottom: 8px;
}

.admin-tool-tile p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.presence-embed-wrap { margin-top: 12px; }
.presence-embed-wrap.hidden { display: none; }

/* ---------- Floating chat button + floating chat panel ---------- */
.chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  background: var(--primary);
  box-shadow: 0 12px 28px rgba(37,99,235,.35);
  cursor: pointer;
  z-index: 90000;
  transition: transform .15s ease, background .15s ease;
}
.chat-fab:hover { background: var(--primary-dark); transform: translateY(-1px); }
.chat-fab:active { transform: translateY(0); }

.tab-panel.chat-floating {
  display: block;
  position: fixed;
  right: 20px;
  bottom: 92px;
  width: min(420px, calc(100vw - 40px));
  max-height: min(640px, calc(100vh - 140px));
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15,23,42,.35);
  padding: 16px;
  z-index: 89999;
}
.tab-panel.chat-floating .page-hero { display: none; }

.chat-float-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  margin-bottom: 10px;
  margin-left: auto;
}
.tab-panel.chat-floating .chat-float-close { display: inline-flex; }

@media (max-width: 768px) {
  .chat-fab {
    right: 16px;
    bottom: calc(78px + env(safe-area-inset-bottom));
  }
  .tab-panel.chat-floating {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: calc(146px + env(safe-area-inset-bottom));
    max-height: min(70vh, calc(100vh - 220px));
  }
}

/* Network status tile */
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.status-dot-online { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.status-dot-offline { background: #cbd5e1; }
.device-type-badge {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 2px 8px;
  border-radius: 999px;
}
.device-type-tailscale { background: #eff6ff; color: #1d4ed8; }
.device-type-wireguard { background: #f0fdf4; color: #15803d; }
.network-status-stale-note { color: #b45309; }

.presence-embed-frame {
  width: 100%;
  height: 480px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
}

@media (max-width: 768px) {
  .admin-tools-grid { grid-template-columns: 1fr; }
  .presence-embed-frame { height: 400px; }
}