:root {
  /* Refined dark — Linear/Vercel-style near-black with cool undertone */
  --bg:        #0a0c11;
  --panel:     #11141b;
  --panel-2:   #1a1e27;
  --panel-3:   #232834;
  --border:    #232834;
  --border-2:  #2d3441;
  --text:      #e7e9ee;
  --text-2:    #b8bcc7;
  --muted:     #7a8090;

  /* Primary accent — confident rose, single brand color */
  --accent:        #f43f5e;
  --accent-hover:  #e11d48;
  --accent-soft:   rgba(244, 63, 94, 0.12);

  /* Status palette — professional, restrained */
  --info:      #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.12);
  --success:      #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning:      #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger:       #f87171;
  --danger-soft:  rgba(248, 113, 113, 0.12);

  --shadow:    0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.55);
  --radius:    8px;
  --radius-lg: 12px;
}

/* Light theme — applied when <html data-theme="light"> is set. Same accent
   so the brand stays consistent; bg/panels/text invert with a gentler shadow.
   Status soft-bgs become slightly more saturated since they no longer compete
   with a dark background. */
:root[data-theme="light"] {
  --bg:        #f7f8fa;
  --panel:     #ffffff;
  --panel-2:   #f1f3f6;
  --panel-3:   #e7eaef;
  --border:    #e2e5ea;
  --border-2:  #cdd2da;
  --text:      #1a1d24;
  --text-2:    #3e4452;
  --muted:     #6b7280;

  --accent:        #e11d48;
  --accent-hover:  #be123c;
  --accent-soft:   rgba(225, 29, 72, 0.10);

  --info:      #2563eb;
  --info-soft: rgba(37, 99, 235, 0.10);
  --success:      #059669;
  --success-soft: rgba(5, 150, 105, 0.10);
  --warning:      #b45309;
  --warning-soft: rgba(180, 83, 9, 0.10);
  --danger:       #dc2626;
  --danger-soft:  rgba(220, 38, 38, 0.10);

  --shadow:    0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button { font-family: inherit; font-size: inherit; cursor: pointer; }

.app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  flex-shrink: 0;
  height: 100vh;
  overflow: hidden;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  padding: 0 12px 20px;
  color: var(--text);
  letter-spacing: 0.3px;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* keep the scrollbar subtle so it doesn't visually crowd the panel */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  text-align: left;
  padding: 10px 12px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  display: block;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}
.nav-btn:hover { background: var(--panel-2); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; }

/* Tenant / workspace switcher (only shown for users in >1 tenant). */
#nx-tenant-switcher {
  margin: 0 0 16px;
  padding: 8px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
#nx-tenant-switcher .nx-ts-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
#nx-tenant-switcher select {
  width: 100%;
  padding: 6px 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}

.nav-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 12px 4px;
  opacity: 0.7;
}
.nav-section:first-child { padding-top: 4px; }

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}
/* Sidebar-footer buttons look like nav-btn, not generic ghost outlines. */
.sidebar-footer .ghost,
.sidebar-footer button,
.sidebar-footer a {
  background: transparent;
  border: none;
  color: var(--muted);
  text-align: left;
  padding: 10px 12px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: block;
  width: 100%;
  transition: background 0.15s, color 0.15s;
}
.sidebar-footer .ghost:hover,
.sidebar-footer button:hover,
.sidebar-footer a:hover {
  background: var(--panel-2);
  color: var(--text);
}

/* Main */
.main {
  flex: 1;
  overflow: auto;
  padding: 32px 40px;
}
.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.view-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Inputs */
input[type="text"], input[type="search"], input[type="email"], input[type="tel"],
input[type="datetime-local"], input[type="date"], input[type="time"], input[type="url"],
input[type="password"], input[type="number"],
select, textarea {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

/* Modal/drawer form fields: enforce dark theme even if a more specific rule
   elsewhere has set a white background. Use the page bg (one shade darker than
   the modal) so inputs look recessed rather than glowing. Wins by specificity. */
#modal-body input, #modal-body select, #modal-body textarea,
.drawer input, .drawer select, .drawer textarea,
#workspace-body input, #workspace-body select, #workspace-body textarea {
  background-color: var(--bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}
#modal-body input:focus, #modal-body select:focus, #modal-body textarea:focus,
.drawer input:focus, .drawer select:focus, .drawer textarea:focus,
#workspace-body input:focus, #workspace-body select:focus, #workspace-body textarea:focus {
  border-color: var(--accent) !important;
}
#modal-body input::placeholder,
#modal-body textarea::placeholder,
#workspace-body input::placeholder,
.drawer input::placeholder { color: var(--muted); opacity: 1; }
/* And kill autofill bg specifically inside these containers — Chrome's autofill
   paints over our background otherwise. */
#modal-body input:-webkit-autofill,
.drawer input:-webkit-autofill,
#workspace-body input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset !important;
  box-shadow: 0 0 0 1000px var(--bg) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
/* Browsers paint a custom yellow/blue background on autofilled inputs that
   ignores our --panel color. Force the dark theme through the autofill state
   so secret-key fields don't pop bright white when a password manager fills. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--panel) inset !important;
  box-shadow: 0 0 0 1000px var(--panel) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  border: 1px solid var(--border) !important;
}
textarea { resize: vertical; min-height: 80px; }

/* Native <option> elements default to OS colors and look washed-out against
 * the dark theme. Force readable contrast on every dropdown option. */
select option,
select optgroup {
  background: var(--panel);
  color: var(--text);
}
select option:checked,
select option:hover {
  background: var(--accent);
  color: #fff;
}

/* Buttons */
.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  transition: background 0.15s;
}
.primary:hover { background: var(--accent-hover); }
.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.ghost:hover { background: var(--panel-2); color: var(--text); }
.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 6px;
}
.danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* Company grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  position: relative;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 6px;
}
.card-meta {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0;
  word-break: break-word;
}
.card-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.badge {
  display: inline-block;
  background: var(--panel-2);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

/* Table */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.data-table th {
  background: var(--panel-2);
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--panel-2); }
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}
.status-scheduled { background: var(--info-soft);    color: var(--info); }
.status-completed { background: var(--success-soft); color: var(--success); }
.status-cancelled { background: var(--danger-soft);  color: var(--danger); }
.status-pending   { background: var(--warning-soft); color: var(--warning); }

.status-select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  padding: 4px 22px 4px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='currentColor' d='M2 4l3 3 3-3z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 10px 10px;
  outline: none;
  transition: background-color .15s, color .15s;
}
.status-select:focus { box-shadow: 0 0 0 2px var(--accent-soft); }
.status-select option { background: var(--panel); color: var(--text); }
.role-viewer .status-select { pointer-events: none; opacity: .6; }

/* Empty */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

/* Modal */
.modal-backdrop, .drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  z-index: 100;
}
.modal-backdrop { z-index: 110; }
.modal-backdrop[hidden], .drawer-backdrop[hidden] { display: none; }
.modal-backdrop { align-items: center; justify-content: center; }
.modal {
  background: var(--panel);
  border-radius: var(--radius);
  width: 90%;
  max-width: 520px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
/* Wide modal — used for schema-driven form editors and other content-heavy
   modals that need more horizontal room. Opt-in via class on .modal element. */
.modal.modal--wide { max-width: 960px; }
.modal.modal--xl   { max-width: 1180px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 17px; }
#modal-form { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
#modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-section { padding: 8px 0 0; margin-top: 6px; border-top: 1px solid var(--border); }
.field-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.field-section-label { margin: 0 0 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* Drawer — centered modal-style popup */
.drawer-backdrop { align-items: center; justify-content: center; }
.drawer {
  background: var(--panel);
  width: 92%;
  max-width: 1100px;
  height: auto;
  max-height: 90vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.drawer-header h2 { margin: 0; font-size: 19px; }
.drawer-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.detail-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 16px;
  margin-bottom: 24px;
}
.detail-grid dt { color: var(--muted); font-size: 13px; }
.detail-grid dd { margin: 0; font-size: 14px; }
.detail-grid .detail-group {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.detail-grid .detail-group:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.detail-grid .notes-full { grid-column: 1 / -1; white-space: pre-wrap; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 24px 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.appt-list { display: flex; flex-direction: column; gap: 8px; }
.appt-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.appt-item .appt-info { flex: 1; min-width: 0; }
.appt-item .appt-title { font-weight: 500; margin-bottom: 4px; }
.appt-item .appt-time { color: var(--muted); font-size: 12px; }
.appt-item .appt-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 200;
  animation: slideIn 0.2s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Overview */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.overview-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
}
.overview-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.overview-stat {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.overview-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 8px 0 12px;
}
.overview-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 16px;
  flex: 1;
}
.overview-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.link-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 0;
  cursor: pointer;
}
.link-btn:hover { color: var(--accent-hover); text-decoration: underline; }

.overview-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.overview-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.overview-panel .section-title { margin-top: 0; }
.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.mini-item:last-child { border-bottom: none; }
.mini-item .mini-title { font-size: 14px; }
.mini-item .mini-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.mini-item .mini-when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.mini-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* Notes */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.note-card {
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  border: 1px solid var(--border);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.note-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.note-card.color-default { background: var(--panel); }
.note-card.color-yellow { background: #4a4220; border-color: #6b5e2e; }
.note-card.color-blue   { background: #1f3a5c; border-color: #2c5180; }
.note-card.color-green  { background: #1f4a38; border-color: #2c6650; }
.note-card.color-red    { background: #4a2424; border-color: #6b3535; }
.note-card.color-purple { background: #3a2a52; border-color: #5a3f7e; }
.note-card.color-orange { background: #4d3520; border-color: #6e4d2e; }

/* Light-theme overrides: the dark hex backgrounds above stop being readable
   on a light page, so swap to pastel sticky-note shades with dark ink. */
:root[data-theme="light"] .note-card.color-default { background: #ffffff;             border-color: #e2e5ea;           color: #1a1d24; }
:root[data-theme="light"] .note-card.color-yellow  { background: #fef3c7;             border-color: #f59e0b;           color: #1a1d24; }
:root[data-theme="light"] .note-card.color-blue    { background: #dbeafe;             border-color: #3b82f6;           color: #1a1d24; }
:root[data-theme="light"] .note-card.color-green   { background: #d1fae5;             border-color: #10b981;           color: #1a1d24; }
:root[data-theme="light"] .note-card.color-red     { background: #fee2e2;             border-color: #ef4444;           color: #1a1d24; }
:root[data-theme="light"] .note-card.color-purple  { background: #ede9fe;             border-color: #a78bfa;           color: #1a1d24; }
:root[data-theme="light"] .note-card.color-orange  { background: #ffedd5;             border-color: #f97316;           color: #1a1d24; }
/* Force note title + body + footer into the dark ink so they read on the pastel bg
   regardless of which child class the renderer used. */
:root[data-theme="light"] .note-card .note-title  { color: #1a1d24; }
:root[data-theme="light"] .note-card .note-body   { color: #3e4452; }
:root[data-theme="light"] .note-card .note-footer { color: #6b7280; }
.note-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px;
  padding-right: 24px;
  word-break: break-word;
}
.note-body {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
  line-height: 1.5;
  opacity: 0.92;
}
.note-footer {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}
.pin-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pin-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.pin-btn.pinned { color: var(--warning); }
.color-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: transform 0.1s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected { border-color: var(--text); }
.color-swatch.color-default { background: var(--panel); }
.color-swatch.color-yellow { background: #4a4220; }
.color-swatch.color-blue   { background: #1f3a5c; }
.color-swatch.color-green  { background: #1f4a38; }
.color-swatch.color-red    { background: #4a2424; }
.color-swatch.color-purple { background: #3a2a52; }
.color-swatch.color-orange { background: #4d3520; }

/* Tasks */
.task-list {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.task-section-header {
  background: var(--panel-2);
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.task-section-header.overdue { color: var(--danger); }
.task-section-header .chev { transition: transform 0.15s; font-size: 10px; }
.task-section-header.collapsed .chev { transform: rotate(-90deg); }
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.task-row:hover { background: var(--panel-2); }
.task-row:last-child { border-bottom: none; }
.task-row.completed .task-title { text-decoration: line-through; color: var(--muted); }
.task-row.completed .task-meta { opacity: 0.6; }
.task-checkbox {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: transparent;
  transition: border-color 0.15s, background 0.15s;
}
.task-checkbox:hover { border-color: var(--accent); }
.task-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-size: 13px;
}
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14px; word-break: break-word; }
.task-meta {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.task-due.overdue { color: var(--danger); font-weight: 500; }
.task-due.today { color: var(--warning); font-weight: 500; }
.task-priority {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
}
.priority-high   { background: rgba(224, 92, 92, 0.15); color: var(--danger); }
.priority-medium { background: rgba(224, 160, 74, 0.15); color: var(--warning); }
.priority-low    { background: rgba(139, 149, 168, 0.15); color: var(--muted); }
.task-actions { display: flex; gap: 6px; flex-shrink: 0; }

@media (max-width: 768px) {
  .overview-split { grid-template-columns: 1fr; }
}

/* Card stats layout (used by dashboard cards) */
.card-stats, .email-stats {
  display: flex;
  gap: 14px;
  margin: 8px 0 14px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.card-stats strong, .email-stats strong { color: var(--text); font-size: 15px; }

.email-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.summary-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.summary-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.summary-label {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.email-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.template-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s;
  display: flex;
  flex-direction: column;
}
.template-card:hover { border-color: var(--accent); }
.template-name { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.template-subject { font-size: 13px; color: var(--muted); margin: 0 0 12px; word-break: break-word; }
.template-preview {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 12px;
}
.template-actions {
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.placeholder-help {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.placeholder-help code {
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

.status-sent { background: rgba(78, 201, 163, 0.15); color: var(--success); }
/* .status-scheduled lives in the canonical status block above (line 349). */
.status-failed { background: rgba(224, 92, 92, 0.15); color: var(--danger); }
.status-draft { background: rgba(139, 149, 168, 0.15); color: var(--muted); }

.opened-yes { color: var(--success); font-weight: 500; }
.opened-no { color: var(--muted); }

/* Test Forms */
.form-types-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.form-type-card {
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-type-card:hover { background: var(--panel-3); border-color: var(--accent); transform: translateY(-1px); }
.form-type-name { font-size: 15px; font-weight: 600; color: var(--text); }
.form-type-desc { font-size: 13px; color: var(--text-2); flex: 1; line-height: 1.5; }
.form-type-count {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.form-type-count strong { color: var(--text); font-size: 16px; }

/* Dynamic-rows table for group sign-in / shy bladder attempts */
.dyn-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
}
.dyn-table th, .dyn-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 13px;
}
.dyn-table th {
  background: var(--panel-2);
  font-weight: 500;
  color: var(--muted);
  text-align: left;
}
.dyn-table input {
  background: transparent;
  border: none;
  padding: 4px 0;
  width: 100%;
}
.dyn-table input:focus { background: var(--panel-2); }
.dyn-table .row-del {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}
.add-row-btn {
  margin-top: 6px;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.add-row-btn:hover { color: var(--text); border-color: var(--accent); }

/* ===== Printable form layout — branded, professional, print-ready =====
   Uses the dusty-rose brand accent and a clean sans-serif type stack.
   Designed to look like a real medical / DOT collection form, not a Word doc. */
.print-only { display: none; }

.printable-form {
  --pf-ink:    #0f172a;
  --pf-ink-2:  #334155;
  --pf-muted:  #6b7280;
  --pf-line:   #d1d5db;
  --pf-line-2: #e5e7eb;
  --pf-accent: #9d2553;
  --pf-accent-soft: #fbeef2;

  background: #fff;
  color: var(--pf-ink);
  padding: 0.5in 0.55in;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
  font-size: 10.5pt;
  line-height: 1.45;
  position: relative;
}
/* Top accent stripe — the spine of the brand */
.printable-form::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--pf-accent) 0%, #c2185b 100%);
}

/* Tenant letterhead (already injected from JS as .pf-biz) */
.printable-form .pf-biz {
  border-bottom: 1px solid var(--pf-line);
  padding: 14px 0 12px;
  margin-bottom: 16px;
}
.printable-form .pf-biz-name {
  font-size: 17pt;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--pf-ink);
  margin-bottom: 4px;
}
.printable-form .pf-biz-line { font-size: 9.5pt; color: var(--pf-ink-2); line-height: 1.55; }
.printable-form .pf-biz-logo { max-width: 180px; max-height: 60px; display: block; margin-bottom: 6px; }
.printable-form .pf-biz-creds { font-size: 9pt; color: var(--pf-muted); font-variant-numeric: tabular-nums; margin-top: 2px; }

/* Form title block */
.printable-form .pf-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--pf-accent);
}
.printable-form h1 {
  font-size: 19pt;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--pf-ink);
}
.printable-form .pf-subtitle {
  font-size: 10pt;
  color: var(--pf-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Section headers — small uppercase eyebrow with accent bar */
.printable-form h2 {
  font-size: 10pt;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pf-accent);
  margin: 24px 0 10px;
  padding: 6px 12px;
  background: var(--pf-accent-soft);
  border-left: 3px solid var(--pf-accent);
  border-radius: 0 4px 4px 0;
  page-break-after: avoid;
}

/* Field rows */
.printable-form .pf-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 24px;
  margin: 6px 0 14px;
}
.printable-form .pf-field { min-width: 0; padding: 4px 0; }
.printable-form .pf-label {
  font-size: 8.5pt;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pf-muted);
  display: block;
  margin-bottom: 3px;
}
.printable-form .pf-value {
  border-bottom: 1px solid var(--pf-line);
  padding: 3px 4px 4px;
  min-height: 19px;
  font-size: 10.5pt;
  color: var(--pf-ink);
}
.printable-form .pf-value:empty::after { content: "—"; color: var(--pf-line); }
.printable-form .pf-value.multiline {
  border: 1px solid var(--pf-line);
  border-radius: 4px;
  background: #fafbfc;
  padding: 8px 10px;
  min-height: 56px;
  white-space: pre-wrap;
  font-size: 10pt;
  line-height: 1.55;
}

/* Checkboxes — clean filled squares with check character */
.printable-form .pf-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  padding: 4px 0;
}
.printable-form .pf-checkbox {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 10pt;
}
.printable-form .pf-checkbox .box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--pf-ink-2);
  border-radius: 2px;
  text-align: center;
  line-height: 1;
  font-size: 10pt;
  font-weight: 700;
  color: var(--pf-accent);
  background: #fff;
}
.printable-form .pf-checkbox.checked .box {
  background: var(--pf-accent);
  color: #fff;
  border-color: var(--pf-accent);
}

/* Tables (donor lists, attempt logs, panel results) */
.printable-form table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 16px;
  font-size: 9.5pt;
  border: 1px solid var(--pf-line);
  border-radius: 4px;
  overflow: hidden;
}
.printable-form table th, .printable-form table td {
  border-bottom: 1px solid var(--pf-line-2);
  border-right: 1px solid var(--pf-line-2);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
}
.printable-form table th:last-child, .printable-form table td:last-child { border-right: 0; }
.printable-form table tr:last-child td { border-bottom: 0; }
.printable-form table thead tr { background: var(--pf-accent-soft); }
.printable-form table th {
  font-size: 8.5pt;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--pf-accent);
}

/* Signature blocks — bordered card with x-line and labeled */
.printable-form .pf-signature {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  page-break-inside: avoid;
}
.printable-form .pf-sigblock {
  border: 1px solid var(--pf-line);
  border-radius: 4px;
  padding: 10px 14px 12px;
  background: #fafbfc;
}
.printable-form .pf-sigline {
  border-top: 1px solid var(--pf-line);
  padding-top: 6px;
  margin-top: 24px;
  font-size: 8.5pt;
  color: var(--pf-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.printable-form .pf-sigvalue {
  font-family: "Brush Script MT", "Lucida Handwriting", cursive;
  font-size: 14pt;
  color: var(--pf-ink);
  padding: 8px 4px 4px;
  min-height: 28px;
}

/* Footer — confidentiality notice + branded line */
.printable-form .pf-footer {
  margin-top: 32px;
  padding-top: 12px;
  border-top: 2px solid var(--pf-accent);
  font-size: 8.5pt;
  color: var(--pf-muted);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}
.printable-form .pf-footer-confid {
  font-style: italic;
  flex: 1;
}
.printable-form .pf-footer-brand {
  text-align: right;
  white-space: nowrap;
  color: var(--pf-accent);
  font-weight: 600;
}
.printable-form .pf-notes {
  border: 1px solid var(--pf-line);
  background: #fafbfc;
  border-radius: 4px;
  padding: 10px 12px;
  min-height: 70px;
  white-space: pre-wrap;
  font-size: 10pt;
}

/* Print-specific tweaks */
@media print {
  .printable-form { padding: 0.4in 0.5in; }
  .printable-form h2 { page-break-after: avoid; }
  .printable-form .pf-row { page-break-inside: avoid; }
  /* Don't waste ink on the accent stripe — keep it crisp via -webkit-print-color-adjust */
  .printable-form, .printable-form * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Services / Comparison */
.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.compare-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.compare-card.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.compare-name { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.compare-panels {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}
.compare-price {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.compare-price small { font-size: 12px; color: var(--muted); font-weight: normal; margin-left: 4px; }
.compare-features {
  margin: 16px 0;
  flex: 1;
  list-style: none;
  padding: 0;
}
.compare-features li {
  padding: 4px 0;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.compare-features li::before {
  content: "✓";
  color: var(--success);
  font-weight: 600;
  flex-shrink: 0;
}
.compare-features li.no::before { content: "—"; color: var(--muted); }
.compare-features li.no { color: var(--muted); }

.discount-badge {
  display: inline-block;
  background: rgba(78, 201, 163, 0.15);
  color: var(--success);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  margin: 8px 0;
}

/* Inline service picker in invoice line items */
.service-picker {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 2px 6px;
  border-radius: 4px;
  text-decoration: underline;
}
.service-picker:hover { background: var(--panel-2); }

/* Invoice */
.status-paid    { background: rgba(78, 201, 163, 0.15); color: var(--success); }
.status-overdue { background: rgba(224, 92, 92, 0.15); color: var(--danger); }
/* Brighter amber so it reads on the dark theme (was #b45309 = 4.4:1, now #fbbf24 = 11:1). */
.status-partial { background: rgba(251, 191, 36, 0.18); color: #fbbf24; }
.status-void    { background: rgba(30, 32, 38, 0.85);   color: #fff; }
/* Status icon prefix — small glyph next to the label so colorblind users
   and printed pages distinguish states without color. Use ::before on an
   element with .status-icon-{kind} alongside the text label. */
.status-icon-paid::before     { content: "✓ "; }
.status-icon-partial::before  { content: "◐ "; }
.status-icon-overdue::before  { content: "! "; }
.status-icon-void::before     { content: "⊘ "; }
.status-icon-draft::before    { content: "○ "; }
.status-icon-sent::before     { content: "→ "; }

.line-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
}
.line-items-table th, .line-items-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 13px;
}
.line-items-table th {
  background: var(--panel-2);
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.line-items-table input {
  background: transparent;
  border: none;
  padding: 4px;
  width: 100%;
  color: var(--text);
}
.line-items-table input:focus { background: var(--panel-2); }
.line-items-table input[type="number"] { text-align: right; }
.line-items-table .amount-cell { text-align: right; color: var(--muted); }

.totals-box {
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--panel-2);
  border-radius: 6px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 24px;
  align-items: center;
}
.totals-box .total-label { color: var(--muted); font-size: 13px; text-align: right; }
.totals-box .total-value { text-align: right; font-variant-numeric: tabular-nums; min-width: 100px; }
.totals-box .grand .total-label { color: var(--text); font-weight: 600; font-size: 14px; }
.totals-box .grand .total-value { font-weight: 700; font-size: 16px; color: var(--accent); }

/* Printable invoice */
.printable-invoice {
  background: #fff;
  color: #000;
  padding: 0.5in;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 10.5pt;
  line-height: 1.5;
}
.printable-invoice .pi-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 3px solid #2563eb;
  padding-bottom: 18px;
  margin-bottom: 24px;
}
.printable-invoice .pi-logo {
  max-width: 200px;
  max-height: 70px;
  display: block;
  margin-bottom: 8px;
}
.printable-invoice .pi-biz-name {
  font-size: 22pt;
  font-weight: 700;
  color: #2563eb;
  margin: 0;
}
.printable-invoice .pi-biz-info {
  font-size: 9.5pt;
  color: #444;
  margin-top: 6px;
  white-space: pre-line;
}
.printable-invoice .pi-title-block {
  text-align: right;
}
.printable-invoice .pi-title {
  font-size: 28pt;
  font-weight: 300;
  letter-spacing: 4px;
  color: #555;
  margin: 0;
  text-transform: uppercase;
}
.printable-invoice .pi-meta {
  font-size: 10pt;
  margin-top: 8px;
}
.printable-invoice .pi-meta div { margin: 2px 0; }
.printable-invoice .pi-meta strong { display: inline-block; width: 80px; color: #555; }

.printable-invoice .pi-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 24px;
}
.printable-invoice .pi-party-label {
  font-size: 9pt;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  margin-bottom: 6px;
}
.printable-invoice .pi-party-name {
  font-size: 12pt;
  font-weight: 600;
  margin-bottom: 4px;
}
.printable-invoice .pi-party-info {
  font-size: 10pt;
  color: #444;
  white-space: pre-line;
}

.printable-invoice .pi-items {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}
.printable-invoice .pi-items th {
  background: #f3f4f6;
  border-bottom: 2px solid #2563eb;
  padding: 10px 12px;
  text-align: left;
  font-size: 9.5pt;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #555;
}
.printable-invoice .pi-items th.num,
.printable-invoice .pi-items td.num { text-align: right; }
.printable-invoice .pi-items td {
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}
.printable-invoice .pi-totals {
  margin-left: auto;
  width: 320px;
  margin-top: 12px;
}
.printable-invoice .pi-totals .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 10.5pt;
}
.printable-invoice .pi-totals .row.grand {
  border-top: 2px solid #2563eb;
  margin-top: 6px;
  padding-top: 12px;
  font-size: 14pt;
  font-weight: 700;
  color: #2563eb;
}
.printable-invoice .pi-notes {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid #ddd;
}
.printable-invoice .pi-notes-label {
  font-size: 9pt;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  margin-bottom: 6px;
}
.printable-invoice .pi-notes-body {
  font-size: 10pt;
  white-space: pre-wrap;
  color: #333;
}
.printable-invoice .pi-paid-stamp {
  position: absolute;
  top: 1.5in;
  right: 0.7in;
  border: 4px solid var(--success, #4ec9a3);
  color: var(--success, #4ec9a3);
  padding: 8px 24px;
  font-size: 28pt;
  font-weight: 800;
  letter-spacing: 4px;
  transform: rotate(-12deg);
  opacity: 0.6;
  pointer-events: none;
}
.printable-invoice .pi-footer {
  margin-top: 36px;
  padding-top: 12px;
  border-top: 1px solid #ddd;
  text-align: center;
  font-size: 9pt;
  color: #888;
}

@media print {
  body * { visibility: hidden !important; }
  #print-area, #print-area * { visibility: visible !important; }
  #print-area {
    display: block !important;
    position: absolute !important;
    left: 0;
    top: 0;
    width: 100%;
  }
  .printable-form {
    page-break-inside: avoid;
    padding: 0.5in;
  }
  @page {
    size: letter;
    margin: 0;
  }
}

@media (max-width: 768px) {
  .sidebar { width: 64px; padding: 16px 8px; }
  .brand, .nav-btn { font-size: 0; }
  .nav-btn { text-align: center; padding: 12px; }
  .nav-btn::first-letter { font-size: 16px; }
  .sidebar-footer { display: none; }
  .main { padding: 20px; }
  .field-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid dt { font-weight: 600; margin-top: 8px; }
}

/* ===== Home dashboard v2 ===== */
.kpi-strip {
  display: grid;
  /* Auto-fit so 4-financial + 2-operational tiles arrange nicely:
     6-across on wide desktops, ~3-across on tablets, 1-2 on phones. */
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color .15s, transform .08s;
}
.kpi:hover { border-color: var(--accent); }
.kpi:active { transform: translateY(1px); }
.kpi-label { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -0.025em; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.05; }
.kpi-value.kpi-pos { color: var(--success); }
.kpi-value.kpi-neg { color: var(--danger); }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-warn { border-color: var(--border-2); background: linear-gradient(180deg, var(--panel-2), var(--panel)); }

.home-split {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}
.home-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.home-panel .section-title { margin-bottom: 12px; }

.mini-list { display: flex; flex-direction: column; gap: 4px; }
.mini-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
}
.mini-item:hover { background: var(--panel-2); }
.mini-time { font-size: 12px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; min-width: 56px; }
.mini-grow { min-width: 0; }
.mini-title { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-when { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.mini-when.overdue { color: var(--danger); font-weight: 600; }
.mini-when.today { color: var(--warning); font-weight: 600; }
.mini-empty { padding: 18px 12px; color: var(--muted); font-size: 13px; text-align: center; }

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.quick-link {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: inherit;
  color: var(--text);
  transition: border-color .15s, background .12s;
}
.quick-link:hover { border-color: var(--accent); background: var(--panel-2); }
.quick-link strong { font-size: 14px; font-weight: 600; }
.quick-link span { font-size: 12px; color: var(--muted); }

/* ===== Bulk action bar ===== */
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 12px;
}
.bulk-count { font-size: 13px; color: var(--text); }
.bulk-count strong { color: var(--accent); font-weight: 700; }
.bulk-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.bulk-buttons button { padding: 6px 12px; font-size: 12px; }
.bulk-row-cb, #bulk-select-all { width: 16px; height: 16px; cursor: pointer; }

/* ===== Calendar ===== */
.cal-nav { display: inline-flex; align-items: center; gap: 6px; }
.cal-nav button { padding: 6px 10px; font-size: 13px; }
.cal-month-label { font-weight: 600; font-size: 15px; padding: 0 10px; min-width: 160px; }
.cal-view-toggle { display: inline-flex; gap: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.cal-view-toggle button { padding: 6px 14px; font-size: 12px; border-radius: 0; border: 0; background: transparent; }
.cal-view-toggle button.active { background: var(--accent); color: #fff; }
.cal-legend { display: flex; gap: 10px; margin: 14px 0 12px; font-size: 12px; }
.cal-grid {
  display: grid;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  gap: 1px;
  width: 100%;
  max-width: 100%;
}
.cal-grid-month { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-grid-week { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-day-header {
  padding: 8px 10px;
  background: var(--panel-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.cal-day {
  background: var(--panel);
  min-height: 100px;
  min-width: 0;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  transition: background .12s;
  overflow: hidden;
}
.cal-grid-week .cal-day { min-height: 320px; }
.cal-day:hover { background: var(--panel-2); }
.cal-day-dim { opacity: .4; }
.cal-day-today { background: var(--accent-soft); }
.cal-day-today:hover { background: var(--accent-soft); }
.cal-day-num { font-size: 12px; font-weight: 600; color: var(--text-2); align-self: flex-start; padding: 2px; }
.cal-day-today .cal-day-num { color: var(--accent); }
.cal-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 4px;
  border-left: 3px solid var(--accent);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  min-width: 0;
  max-width: 100%;
}
.cal-chip-title { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.cal-chip:hover { background: var(--panel-3); }
.cal-chip-company { border-left-color: var(--info); background: var(--info-soft); color: var(--info); }
.cal-chip-indiv   { border-left-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.cal-chip-invoice { border-left-color: var(--warning); background: var(--warning-soft); color: var(--warning); }
.cal-chip-task    { border-left-color: var(--success, #4ec9a3); background: rgba(78, 201, 163, 0.12); color: var(--success, #4ec9a3); }
.cal-chip-equipment { border-left-color: var(--danger, #e05c5c); background: rgba(224, 92, 92, 0.10); color: var(--danger, #e05c5c); }

/* ------------------------------ Signs page ------------------------------ */
.signs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.sign-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
}
.sign-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.sign-card-thumb {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.sign-card-thumb-inner {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  text-align: center;
  font-size: 14px;
  line-height: 1.25;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.sign-card-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.sign-card-title { font-weight: 600; color: var(--text); }
.sign-card-desc  { font-size: 13px; color: var(--muted); flex: 1; }
.sign-card-actions { display: flex; gap: 8px; }
.sign-card-actions .primary {
  background: var(--accent); color: #fff; border: 0; padding: 7px 14px;
  border-radius: 6px; font: inherit; font-weight: 500; cursor: pointer; flex: 1;
}

/* The actual rendered sign (used both in modal preview and on the print page). */
.sign {
  --sign-accent: #b91c1c;
  background: #fff;
  color: #111827;
  border: 6px solid var(--sign-accent);
  border-radius: 10px;
  padding: 28px 32px 24px;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-width: 800px;
  margin: 0 auto;
  /* Force browsers to print background colors and the colored band — without
     this, Chrome/Edge/Safari strip backgrounds when sending to the printer. */
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.sign * {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.sign-band {
  background: var(--sign-accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 4px;
  margin: -28px -32px 18px;
}
.sign-icon { font-size: 64px; line-height: 1; margin: 6px 0 10px; }
.sign-headline {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 6px 0 12px;
  color: var(--sign-accent);
  text-transform: uppercase;
}
.sign-sub { font-size: 16px; color: #1f2937; line-height: 1.5; margin: 0 0 14px; }
.sign-rule { height: 2px; background: #d1d5db; margin: 14px 0; }
.sign-foot { font-size: 12px; color: #4b5563; }
.sign-tenant { margin-top: 10px; font-size: 13px; font-weight: 600; color: #111827; }
.sign-list {
  text-align: left;
  font-size: 15px;
  line-height: 1.5;
  color: #1f2937;
  margin: 8px auto 14px;
  padding-left: 20px;
  max-width: 620px;
}
.sign-list li { margin-bottom: 6px; }

/* Modal preview shows the sign at letter-paper aspect ratio so it looks
   exactly like what'll come out of the printer. The .sign inside uses the
   same scaled-up typography as the print stylesheet. */
.sign-preview-wrap {
  background: #d1d5db;
  padding: 24px;
  border-radius: 8px;
  max-height: 75vh;
  overflow: auto;
  display: flex;
  justify-content: center;
}
.sign-preview-page {
  background: #fff;
  width: min(640px, 100%);
  aspect-ratio: 8.5 / 11;
  display: flex;
  align-items: stretch;
  padding: 0.35in;
  box-sizing: border-box;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
.sign-preview-page .sign {
  width: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.45in 0.5in;
  border-width: 8px;
  /* Print-size typography rendered inside the scaled letter-page so the
     proportions match what comes off the printer. */
}
.sign-preview-page .sign-band     { font-size: 17px; padding: 10px 14px; margin: -0.45in -0.5in 0.25in; letter-spacing: 0.18em; }
.sign-preview-page .sign-icon     { font-size: 92px; margin: 0.2in 0 0.15in; }
.sign-preview-page .sign-headline { font-size: 42px; line-height: 1.05; margin: 0.1in 0 0.18in; }
.sign-preview-page .sign-sub      { font-size: 17px; line-height: 1.4; margin: 0 0.3in 0.2in; }
.sign-preview-page .sign-list     { font-size: 14px; line-height: 1.5; max-width: 5in; margin: 0.1in auto 0.2in; }
.sign-preview-page .sign-rule     { margin: 0.18in 0; }
.sign-preview-page .sign-foot     { font-size: 11px; margin-top: 0.1in; }
.sign-preview-page .sign-tenant   { font-size: 14px; margin-top: 0.18in; }

/* Print page wrapper used by the Signs feature. The existing site-wide
   print rules (around line 1492) already toggle #print-area visible during
   printing, so we only style the sign layout here. */
.sign-print-page {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  box-sizing: border-box;
  min-height: 10in;
  padding: 0;
}
.sign-print-page .sign {
  width: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media print {
  /* margin:0 on @page eliminates the browser-injected URL / date / page-number
     headers and footers. We add the visual whitespace back via padding on the
     sign container instead, so the printed page is a clean sign edge-to-edge. */
  body.printing-sign { background: #fff !important; }
  html, body { background: #fff !important; }

  body.printing-sign #print-area {
    width: 100% !important;
    height: auto !important;
    min-height: 11in;
    padding: 0;
  }
  body.printing-sign #print-area .sign-print-page {
    min-height: 11in;
    padding: 0.35in;
    box-sizing: border-box;
  }
  body.printing-sign #print-area .sign {
    width: 100%;
    max-width: none;
    min-height: 10.3in;
    padding: 0.45in 0.5in;
    border-width: 10px;
    box-shadow: none;
    box-sizing: border-box;
  }
  /* Scale up text so it fills the page edge-to-edge. */
  body.printing-sign #print-area .sign-band     { font-size: 22px; padding: 14px 20px; margin: -0.45in -0.5in 0.3in; letter-spacing: 0.18em; }
  body.printing-sign #print-area .sign-icon     { font-size: 140px; margin: 0.3in 0 0.2in; }
  body.printing-sign #print-area .sign-headline { font-size: 64px; line-height: 1.05; margin: 0.1in 0 0.2in; }
  body.printing-sign #print-area .sign-sub      { font-size: 26px; line-height: 1.4; margin: 0 0.4in 0.2in; }
  body.printing-sign #print-area .sign-list     { font-size: 22px; line-height: 1.5; max-width: 6.5in; margin: 0.1in auto 0.2in; }
  body.printing-sign #print-area .sign-rule     { margin: 0.25in 0; }
  body.printing-sign #print-area .sign-foot     { font-size: 16px; margin-top: 0.1in; }
  body.printing-sign #print-area .sign-tenant   { font-size: 22px; margin-top: 0.2in; }
}
/* @page must be at top level of @media print, not nested in selectors. */
@media print {
  @page { size: letter; margin: 0; }
}

/* Live preview of upcoming recurring dates inside the appointment / invoice
   modals. Sits beneath the Repeat select. */
.recurrence-preview {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}
.recurrence-preview .rp-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
.recurrence-preview .rp-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
}
.rp-chip {
  display: inline-block;
  padding: 3px 9px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.rp-chip-first {
  background: rgba(78, 201, 163, 0.15);
  border-color: rgba(78, 201, 163, 0.4);
  color: var(--success, #4ec9a3);
  font-weight: 500;
}

/* US time-zone strip on the dashboard home page. */
.home-tz-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 10px;
  font-size: 12px;
}
.tz-cell {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.tz-cell.tz-local {
  background: rgba(78, 201, 163, 0.12);
  border-color: rgba(78, 201, 163, 0.4);
  color: var(--success, #4ec9a3);
  font-weight: 500;
}
.tz-abbr {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}
.tz-cell.tz-local .tz-abbr { color: var(--success, #4ec9a3); }
.tz-time { font-variant-numeric: tabular-nums; font-weight: 500; }
.tz-day-diff {
  font-size: 10px;
  color: var(--muted);
  background: var(--panel);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 2px;
}

/* Tenant business info strip on the dashboard home page. */
.home-business-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}
.home-business-strip a { color: var(--accent); text-decoration: none; }
.home-business-strip a:hover { text-decoration: underline; }
.home-business-strip .dot { opacity: 0.4; }

/* Privacy screen — blurs everything except the unlock overlay. */
body.nx-privacy-on .app {
  filter: blur(14px);
  transition: filter 0.18s ease;
  pointer-events: none;
  user-select: none;
}
#nx-privacy-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 17, 0.55);
  backdrop-filter: blur(2px);
}
.nx-privacy-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 40px;
  text-align: center;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.nx-privacy-icon { font-size: 42px; margin-bottom: 8px; }
.nx-privacy-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.nx-privacy-sub   { font-size: 13px; color: var(--muted); margin-bottom: 20px; line-height: 1.5; }
.nx-privacy-sub kbd {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: inherit;
}
.nx-privacy-panel .primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 10px 22px;
  border-radius: 6px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.nx-privacy-panel .primary:hover { filter: brightness(1.1); }

/* Signature pad (canvas-based) used in fillable forms. */
.signature-field { display: flex; flex-direction: column; gap: 4px; }
.sig-pad-wrap {
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 4px;
  margin-top: 4px;
}
.sig-pad {
  display: block;
  width: 100%;
  cursor: crosshair;
  background: var(--panel);
  border-radius: 4px;
  touch-action: none; /* let our handlers consume touch events without scrolling */
}
.sig-pad-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}
.sig-pad-actions .ghost.small {
  padding: 4px 10px;
  font-size: 12px;
}
.sig-legacy {
  margin-top: 2px;
  padding: 6px 10px;
  background: rgba(251, 191, 36, 0.10);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 4px;
}

/* Filter toggle buttons above the calendar grid. Reuses .cal-chip-* colors,
   but adds a click affordance + an "off" state. */
.cal-toggle {
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  padding: 4px 12px;
  user-select: none;
  transition: opacity 0.15s, filter 0.15s;
}
.cal-toggle:hover { filter: brightness(1.15); }
.cal-toggle-off {
  opacity: 0.4;
  filter: grayscale(0.6);
  text-decoration: line-through;
}
.cal-chip-time { font-weight: 600; opacity: .8; }
.cal-chip-title { overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-size: 10px; color: var(--muted); padding: 2px 4px; }

@media (max-width: 980px) {
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .home-split { grid-template-columns: 1fr; }
  .cal-day { min-height: 70px; }
  .cal-day-num { font-size: 11px; }
}

/* ===== Appointment services picker ===== */
.services-picker { display: flex; flex-direction: column; gap: 8px; }
.services-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 4px; }
.services-chips:empty + .services-pick-actions::before {
  content: "No services picked yet — choose what's being collected so invoicing is one click.";
  font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; flex-basis: 100%;
}
.svc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 10px;
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  font-size: 12px;
}
.svc-chip-name { font-weight: 500; }
.svc-chip-qty { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.svc-chip-amt { color: var(--muted); font-variant-numeric: tabular-nums; }
.svc-chip-rm {
  background: transparent; border: 0; color: var(--muted);
  width: 18px; height: 18px; padding: 0; line-height: 1;
  border-radius: 50%; font-size: 14px; display: inline-flex; align-items: center; justify-content: center;
}
.svc-chip-rm:hover { background: var(--danger-soft); color: var(--danger); }
.services-pick-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.services-add-btn { font-size: 12px; padding: 6px 12px; }
.services-total { font-size: 12px; font-variant-numeric: tabular-nums; }

.svc-pick-row {
  display: grid;
  grid-template-columns: auto 1fr 80px;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.svc-pick-row:last-child { border-bottom: 0; }
.svc-pick-row input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.svc-pick-name { font-weight: 500; font-size: 14px; }
.svc-pick-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.svc-pick-qty { width: 80px; padding: 4px 8px; }

/* Compact services row in appointment tables */
.row-services { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.row-svc-chip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--panel-2);
  color: var(--text-2);
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
}
.row-svc-more { color: var(--muted); }

/* Invoice header additions: type badge + seller credentials */
.printable-invoice .pi-biz-creds {
  font-size: 10pt;
  color: #555;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.printable-invoice .pi-type-badge {
  display: inline-block;
  font-size: 11pt;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f1eef9;
  color: #5b3aa8;
  margin-left: 8px;
  vertical-align: middle;
  letter-spacing: 0.04em;
}

/* Form editor — donor link bar */
.form-donor-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.form-donor-bar label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.form-donor-bar select { width: auto; flex: 1; min-width: 200px; }

/* Toast undo button */
#toast { display: inline-flex; align-items: center; gap: 14px; }
/* The ID selector above has higher specificity than the browser's default
   [hidden] rule, so without this override the toast never actually hides
   when toast() sets el.hidden = true. */
#toast[hidden] { display: none; }
.toast-undo {
  background: transparent;
  border: 1px solid rgba(255,255,255,.25);
  color: inherit;
  font: inherit;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.toast-undo:hover { background: rgba(255,255,255,.12); }

/* Mobile form filling — make schema-driven editor and modals usable on a phone in a van */
@media (max-width: 720px) {
  .modal { max-width: 100vw; max-height: 100vh; border-radius: 0; margin: 0; }
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal-header { position: sticky; top: 0; background: var(--panel); z-index: 5; padding: 14px 16px; }
  .modal-footer {
    position: sticky; bottom: 0; background: var(--panel); z-index: 5;
    padding: 12px 16px; box-shadow: 0 -8px 16px -8px rgba(0,0,0,.4);
  }
  .modal-footer button { flex: 1; padding: 12px; font-size: 15px; min-height: 44px; }
  #modal-body { padding: 16px; }

  /* Schema-driven form sections collapse cleanly */
  .form-section { padding: 14px 12px; }
  .form-section legend { font-size: 13px; }
  .field-row { grid-template-columns: 1fr !important; gap: 10px; }
  .field label { font-size: 13px; }
  input[type="text"], input[type="search"], input[type="email"], input[type="tel"],
  input[type="datetime-local"], input[type="date"], input[type="time"], input[type="url"],
  input[type="number"], select, textarea {
    padding: 11px 12px;
    font-size: 16px;            /* prevents iOS zoom-on-focus */
    min-height: 44px;
  }
  textarea { min-height: 100px; }

  /* Repeating-row tables (group sign-in, shy bladder attempts) — let them scroll horizontally
     instead of crushing the columns */
  .dyn-rows-table { display: block; overflow-x: auto; white-space: nowrap; }
  .dyn-rows-table th, .dyn-rows-table td { padding: 8px 10px; }
  .dyn-rows-table input, .dyn-rows-table select, .dyn-rows-table textarea {
    min-height: 36px; padding: 8px;
  }

  /* Print preview / printable invoice viewing on a phone */
  .printable-invoice { padding: 16px !important; }

  /* Form donor bar stacks vertically */
  .form-donor-bar { flex-wrap: wrap; }
  .form-donor-bar select { min-width: 100%; }

  /* Bigger checkboxes/radios for finger taps */
  input[type="checkbox"], input[type="radio"] { transform: scale(1.2); margin-right: 4px; }

  /* Services picker — chips stack and the list rows give qty inputs more room */
  .svc-pick-row { grid-template-columns: auto 1fr 70px; gap: 8px; padding: 10px 0; }
  .services-chips { gap: 8px; }
}

/* MRO disposition bar in form editor */
.form-mro-bar {
  margin-top: 18px;
  padding: 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.form-mro-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.mro-status-select { padding-left: 12px; }

/* CSV importer */
.csv-drop {
  border: 2px dashed var(--border-2);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  color: var(--text-2);
  transition: border-color .15s, background .15s;
}
.csv-drop.drag, .csv-drop:hover {
  border-color: var(--accent);
  background: var(--panel-2);
  color: var(--text);
}
.csv-map { display: flex; flex-direction: column; gap: 8px; }
.csv-map-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  align-items: center;
}
.csv-map-col select { width: 100%; }

/* Workspace panel modal */
.ws-panel { font-size: 14px; line-height: 1.55; color: var(--text); }
.ws-panel .section-title { margin-top: 18px; margin-bottom: 10px; }
.ws-id-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--text);
}
.ws-id-card div { font-size: 14px; line-height: 1.5; }
.ws-id-card strong { color: var(--text); }
.ws-label {
  display: inline-block;
  min-width: 88px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.ws-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted-2, var(--muted));
}
.ws-muted { color: var(--muted); }
.ws-you { font-size: 11px; }

.ws-invite-form {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 8px;
  margin: 8px 0 14px;
}
.ws-invite-form input,
.ws-invite-form select { min-height: 38px; }
.ws-invite-form button { white-space: nowrap; padding: 8px 16px; }
.ws-invite-msg { font-size: 12px; color: var(--muted); min-height: 16px; margin: 0 0 14px; }

.ws-members-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
  font-size: 13px;
}
.ws-members-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.ws-members-table tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.ws-members-table tbody tr:last-child td { border-bottom: 0; }
.ws-members-table tbody tr:hover { background: var(--panel-2); }

.ws-role-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  text-transform: capitalize;
}

.ws-pending-list { padding-left: 20px; margin: 8px 0 14px; color: var(--text); }
.ws-pending-list li { padding: 4px 0; font-size: 13px; }

.ws-billing {
  font-size: 13px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 8px 0 18px;
  color: var(--text);
}

/* Role permissions matrix in workspace modal */
.rp-form { margin: 8px 0 18px; }
.rp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.rp-table thead th {
  background: var(--panel-2);
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.rp-table th.rp-role { width: 130px; }
.rp-table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.rp-table tbody tr:last-child td { border-bottom: 0; }
.rp-table .rp-area strong { color: var(--text); display: block; font-size: 13px; }
.rp-table .rp-hint { color: var(--muted); font-size: 11px; margin-top: 2px; }
.rp-table .rp-cell { width: 130px; }

.rp-level {
  width: 110px;
  padding: 5px 24px 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
}
.rp-level.rp-none { color: var(--muted); background: var(--panel); }
.rp-level.rp-view { color: var(--info); background: var(--info-soft); border-color: transparent; }
.rp-level.rp-edit { color: var(--success); background: var(--success-soft); border-color: transparent; }

.rp-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }

/* Capability-driven read-only mode (set on body when current page's NX_PAGE_CAP
   resolves to view-only). Disables primary actions and edit/delete buttons. */
body.cap-readonly .primary,
body.cap-readonly button.danger,
body.cap-readonly .add-row-btn,
body.cap-readonly [data-act="edit"],
body.cap-readonly [data-act="del"],
body.cap-readonly [data-act="delete"],
body.cap-readonly [data-act="invoice"],
body.cap-readonly .status-select,
body.cap-readonly .bulk-bar { pointer-events: none; opacity: .5; }
body.cap-readonly #new-donor-btn,
body.cap-readonly #new-company-btn,
body.cap-readonly #new-invoice-btn,
body.cap-readonly #new-form-btn,
body.cap-readonly #new-task-btn,
body.cap-readonly #new-note-btn,
body.cap-readonly #new-service-btn,
body.cap-readonly #new-company-appt-btn,
body.cap-readonly #new-indiv-appt-btn,
body.cap-readonly #import-csv-btn,
body.cap-readonly #import-companies-csv-btn { display: none !important; }

/* Tenant collection-site header on printable forms (above the form title) */
.printable-form .pf-biz {
  border-bottom: 2px solid #d1d5db;
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.printable-form .pf-biz-name {
  font-size: 16pt;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #111827;
  margin-bottom: 4px;
}
.printable-form .pf-biz-line {
  font-size: 10pt;
  color: #4b5563;
  line-height: 1.5;
}
.printable-form .pf-biz-creds {
  font-size: 9.5pt;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* Workspace seat counter + progress bar */
.ws-seat-counter {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}
.ws-seat-counter strong { color: var(--text); font-variant-numeric: tabular-nums; }
.ws-seat-counter.is-full { color: var(--warning); }
.ws-seat-counter.is-full strong { color: var(--warning); }

.ws-seat-bar {
  height: 4px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 14px;
}
.ws-seat-fill {
  height: 100%;
  background: var(--accent);
  transition: width .25s ease, background .15s ease;
}
.ws-seat-fill.is-full { background: var(--warning); }

.ws-seat-full-note {
  background: var(--warning-soft, rgba(251,191,36,.12));
  border: 1px solid var(--warning, #fbbf24);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  margin: 8px 0 18px;
  line-height: 1.5;
}

/* Section title can host the seat counter on the right */
.ws-panel .section-title { display: flex; align-items: center; gap: 10px; }

/* Status pills used by Equipment, Training, Incidents pages */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.status-pill.status-ok      { background: rgba(78, 201, 163, 0.15); color: var(--success); }
.status-pill.status-soon    { background: rgba(251, 191, 36, 0.15); color: #b45309; }
.status-pill.status-today   { background: rgba(251, 146, 60, 0.20); color: #b45309; }
.status-pill.status-overdue { background: rgba(224, 92, 92, 0.15); color: var(--danger); }
.status-pill.status-none    { background: var(--panel-2); color: var(--muted); }

.muted.small, .small { font-size: 12px; color: var(--muted); }

/* ========== Polish pack (a11y, autosave, validation, mobile, drawer back-stack) ========== */

/* Skip-link: invisible until keyboard-focused, then jumps over the 18-item sidebar. */
.skip-link {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 9999;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform .15s;
}
.skip-link:focus { transform: translateY(0); }

/* Visible focus rings. Browser defaults are weak / inconsistent on dark
   theme — this gives every interactive control a uniform 2px accent halo. */
button:focus-visible,
.primary:focus-visible,
.ghost:focus-visible,
.danger:focus-visible,
.icon-btn:focus-visible,
.nav-btn:focus-visible,
.add-row-btn:focus-visible,
a.btn:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

/* Autosave indicator pinned to view-header (right side). */
.autosave-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 6px;
  background: transparent;
  transition: background .25s, color .25s;
  user-select: none;
}
.autosave-indicator .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.autosave-indicator.saving .dot   { background: #fbbf24; animation: nx-pulse 1s ease-in-out infinite; }
.autosave-indicator.saved   .dot  { background: var(--success); }
.autosave-indicator.error   { background: var(--danger-soft); color: var(--danger); }
.autosave-indicator.error   .dot  { background: var(--danger); }
@keyframes nx-pulse {
  0%, 100% { opacity: .35; }
  50%      { opacity: 1; }
}

/* Modal validation error summary at top of form. */
.modal-error-summary {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}
.modal-error-summary strong { display: block; margin-bottom: 4px; }
.modal-error-summary ul { margin: 4px 0 0 18px; padding: 0; }
.modal-error-summary a {
  color: var(--danger);
  text-decoration: underline;
  cursor: pointer;
}
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

/* Days-pending pill for MRO queue. */
.aging-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.aging-pill.fresh   { background: var(--panel-2);    color: var(--muted); }
.aging-pill.warning { background: rgba(251, 191, 36, 0.18); color: #fbbf24; }
.aging-pill.critical{ background: rgba(224, 92, 92, 0.18); color: var(--danger); }

/* Drawer back-stack breadcrumb. */
.drawer-backstack {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.drawer-backstack button {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  text-decoration: underline;
  font-family: inherit;
}
.drawer-backstack span.sep { color: var(--muted); }

/* First-run setup checklist on dashboard. */
.setup-checklist {
  background: linear-gradient(135deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 22px 26px;
  margin-bottom: 24px;
}
.setup-checklist h2 {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--text);
  letter-spacing: -.015em;
}
.setup-checklist .lead {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}
.setup-checklist ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.setup-checklist li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.setup-checklist li:first-child { border-top: 0; }
.setup-checklist .check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: transparent;
  font-weight: 700;
  font-size: 12px;
}
.setup-checklist li.done .check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.setup-checklist li.done .label { color: var(--muted); text-decoration: line-through; }
.setup-checklist .label { flex: 1; }
.setup-checklist .go-btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.setup-checklist li.done .go-btn { display: none; }
.setup-checklist .dismiss-link {
  display: block;
  text-align: right;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  margin-left: auto;
}

/* Sortable column headers. */
th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}
th.sortable:hover { color: var(--accent); }
th.sortable::after {
  content: " ↕";
  opacity: .25;
  font-size: 10px;
  margin-left: 2px;
}
th.sortable[aria-sort="ascending"]::after  { content: " ↑"; opacity: 1; color: var(--accent); }
th.sortable[aria-sort="descending"]::after { content: " ↓"; opacity: 1; color: var(--accent); }

/* Date-range filter — compact row of two dates + clear. */
.date-range-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.date-range-filter input[type="date"] {
  padding: 4px 8px;
  font-size: 12px;
  width: 130px;
}
.date-range-filter .clear-btn {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
  visibility: hidden;
}
.date-range-filter.active .clear-btn { visibility: visible; }

/* DOT vs Non-DOT split toggle on dashboard. */
.dot-split-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}
.dot-split-toggle button {
  background: transparent;
  border: 0;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}
.dot-split-toggle button.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Mobile sidebar (<880px). Becomes a slide-in drawer triggered by a hamburger. */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  width: 40px;
  height: 40px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  align-items: center;
  justify-content: center;
}
.mobile-menu-btn:hover { border-color: var(--accent); }
.mobile-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}
@media (max-width: 880px) {
  .mobile-menu-btn { display: inline-flex; }
  body.has-sidebar .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    width: 260px;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .mobile-menu-backdrop { display: block; }
  body.has-sidebar .main { margin-left: 0; padding-top: 60px; }
  body.has-sidebar .sidebar-footer { display: flex !important; }
  .view-header { flex-wrap: wrap; gap: 10px; }
}

/* Empty-state coachable copy reused from existing .empty class but tighter spacing for inline use. */
.empty-inline {
  text-align: center;
  padding: 24px 16px;
  color: var(--muted);
  font-size: 13px;
}

/* First-time tip bar — shown once per page on first visit, dismissable. */
.first-time-tip {
  background: rgba(91, 141, 239, 0.10);
  border: 1px solid rgba(91, 141, 239, 0.35);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin: 8px 0 14px;
}
.first-time-tip button {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  font-family: inherit;
}

/* ========== Home page — needs-attention + recent views ========== */

.recent-views {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  align-items: center;
}
.recent-views .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
}
.recent-views button.chip {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color .15s, background .15s;
}
.recent-views button.chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.recent-views button.chip .kind {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.needs-attention {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 0 0 22px;
}
.needs-attention .heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.needs-attention .heading .count {
  background: var(--warning-soft);
  color: var(--warning);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.needs-attention .heading.all-clear .count {
  background: var(--success-soft);
  color: var(--success);
}
.needs-attention ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.needs-attention li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.needs-attention li:first-child { border-top: 0; }
.needs-attention li button {
  background: transparent;
  color: var(--accent);
  border: 0;
  font: inherit;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
}
.needs-attention li button:hover { text-decoration: underline; }
.needs-attention li .severity-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 10px;
  flex-shrink: 0;
}
.needs-attention li .severity-dot.high { background: var(--danger); }
.needs-attention li .severity-dot.med  { background: var(--warning); }
.needs-attention li .severity-dot.low  { background: var(--info); }
.needs-attention li .severity-dot.ok   { background: var(--success); }

/* Collapsible sidebar sections — chevron on the section header. */
.sidebar .nav-section.collapsible {
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-right: 10px;
}
.sidebar .nav-section.collapsible::after {
  content: "▾";
  font-size: 10px;
  color: var(--muted);
  transition: transform .15s;
}
.sidebar .nav-section.collapsible.collapsed::after { transform: rotate(-90deg); }
.sidebar .nav-section.collapsible.collapsed + .nav-group { display: none; }

/* Workspace -> Data grid: per-entity import/export cards. */
.ws-data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.ws-data-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ws-data-card .ws-data-title {
  font-weight: 600;
  font-size: 14px;
}
.ws-data-card .ws-data-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  flex: 1;
}
.ws-data-card .ws-data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.ws-data-card .ws-data-actions button {
  padding: 6px 12px;
  font-size: 12px;
}

/* First-time hint pointing at the collapsible-section chevron in the sidebar. */
.nx-hint-popover {
  position: fixed;
  z-index: 9999;
  background: var(--accent);
  color: #fff;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  max-width: 240px;
  pointer-events: auto;
  animation: nxHintIn 0.25s ease-out;
}
@keyframes nxHintIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.nx-hint-popover::before {
  content: "";
  position: absolute;
  top: 18px;
  left: -8px;
  width: 0; height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 8px solid var(--accent);
}
.nx-hint-popover .hint-title {
  font-weight: 600;
  margin-bottom: 4px;
}
.nx-hint-popover .hint-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.nx-hint-popover button {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 0;
  padding: 4px 12px;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.nx-hint-popover button:hover { background: rgba(255, 255, 255, 0.28); }
/* Soft glow on the section header the popover points at. */
.nav-section.collapsible.nx-hint-target {
  background: var(--accent-soft);
  border-radius: 4px;
  animation: nxHintPulse 1.6s ease-in-out infinite;
}
@keyframes nxHintPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}

/* Sub-380px polish (iPhone SE, small Androids). */
@media (max-width: 380px) {
  .view-header h1 { font-size: 20px; }
  .summary-tile  { padding: 14px 12px; }
  .summary-num   { font-size: 22px; }
  .actions       { flex-wrap: wrap; gap: 6px; }
  .data-table th, .data-table td { padding: 8px 6px; font-size: 12px; }
  .first-time-tip { flex-direction: column; align-items: flex-start; }
  .modal { width: calc(100vw - 16px); max-width: none; }
  .drawer { width: calc(100vw - 16px); max-width: none; }
}





/* ============================================================
 * Auth pages (login / signup / accept-invite / forgot-password /
 * reset-password / verify-email). Consolidated 2026-05-06 from
 * per-page <style> blocks so we can drop unsafe-inline from CSP.
 * Variations are class modifiers on .login-card.
 * ============================================================ */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg, #f6f7f9);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.login-card.is-wide { max-width: 420px; }
.login-card.is-centered { text-align: center; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p.sub {
  margin: 0 0 20px;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.5;
}
.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: #374151;
}
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
}
.login-card input:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -1px;
  border-color: #3b82f6;
}
.login-card .row { margin-bottom: 14px; }
.login-card button {
  width: 100%;
  padding: 10px 14px;
  background: #111827;
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.login-card button:hover { background: #1f2937; }
.login-card button:disabled { opacity: .6; cursor: not-allowed; }
.login-card .err { color: #b91c1c; font-size: 13px; margin: 8px 0 0; min-height: 18px; }
.login-card .ok  { color: #047857; font-size: 14px; margin: 14px 0 0; line-height: 1.55; }
.login-card .hint { font-size: 12px; color: #6b7280; margin: 4px 0 0; }
.login-card a.btn {
  display: inline-block;
  margin-top: 18px;
  padding: 10px 22px;
  background: #111827;
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.login-card a.btn:hover { background: #1f2937; }
.login-card .icon { font-size: 36px; margin-bottom: 8px; }
.login-card .icon.ok    { color: #047857; }
.login-card .icon.err   { color: #b91c1c; }
.login-card .small-link { text-align: center; margin: 14px 0 0; font-size: 13px; color: #6b7280; }
.login-card .small-link a { color: #2563eb; }

/* The reset-password ok-msg uses an inline link that needs underline. */
.login-card .ok a { color: #047857; text-decoration: underline; }


/* ============================================================
 * Inline-style utility classes — replace style="..." attributes
 * so the CSP can drop unsafe-inline. Added 2026-05-06.
 * ============================================================ */
.section--top-pad { padding-top: 24px; }
.muted-note       { margin: 6px 0 0; }
.muted-note-tight { margin: 4px 0 0; }
.mb-3             { margin-bottom: 12px; }
.mt-3             { margin-top: 12px; }
.mt-3-wrap        { margin-top: 12px; flex-wrap: wrap; align-items: center; }
.mt-5             { margin-top: 28px; }
.training-section { margin-top: 32px; }
.inline-cb-label  { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.retention-h2     { margin-top: 28px; font-size: 16px; }
.retention-note   { margin: 0 0 8px; }
.section-bullet-note { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.bulk-cb-th       { width: 32px; }
.training-h-main  { margin: 0 0 4px; font-size: 18px; letter-spacing: -0.015em; }
.training-h-sub   { margin: 0 0 16px; font-size: 13px; }
.section-title.with-top-gap { margin-top: 28px; }
.actions.with-gap-row       { margin: 24px 0 12px; gap: 8px; }

/* ============================================================
 * app.js innerHTML utility classes — replace style="..." in
 * generated markup. Added 2026-05-06.
 * ============================================================ */
.btn-row-action     { padding: 4px 10px; font-size: 12px; }       /* row-action buttons (the 37-use pattern) */
.btn-md             { padding: 6px 12px; }
.btn-pill           { padding: 8px 14px; }
.btn-pill-wide      { padding: 8px 18px; }
.btn-pill-row       { padding: 5px 12px; font-size: 13px; }
.fs-11              { font-size: 11px; }
.fs-12              { font-size: 12px; }
.fs-13              { font-size: 13px; }
.tabular            { font-variant-numeric: tabular-nums; }
.text-center        { text-align: center; }
.text-left          { text-align: left; }
.center-pad         { text-align: center; padding: 18px; }
.is-disabled-overlay { opacity: 0.45; pointer-events: none; }
.row-action-flex     { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.color-accent        { color: var(--accent); }
.color-muted-11      { color: var(--muted); font-size: 11px; }
.color-error-deep    { color: #9d2553; }
.col-30              { width: 30%; }
.col-25              { width: 25%; }
.icon-30             { width: 30px; }
.full-grid-row       { grid-column: 1 / -1; }
.ws-pre              { white-space: pre-wrap; }
.field-info-card     { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; font-size: 13px; line-height: 1.55; }
.action-row-flex     { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.mt-2-tight          { margin-top: 2px; }
.muted-tight         { margin: 0 0 14px; }
.note-min-margin     { margin-top: 0; font-size: 13px; }
.btn-auto-w          { width: auto; }

/* More app.js utilities — second pass. */
.mt-action          { margin-top: 18px; }
.mt-2               { margin-top: 8px; }
.mt-12              { margin-top: 12px; }
.mt-14              { margin-top: 14px; }
.mb-1               { margin-bottom: 4px; }
.mb-2               { margin-bottom: 8px; }
.mb-3-explicit      { margin-bottom: 12px; }
.mb-14              { margin-bottom: 14px; }
.col-110            { width: 110px; }
.col-70             { width: 70px; }
.col-20             { width: 20%; }
.is-hidden          { display: none; }
.constrained-600    { max-width: 600px; }
.modal-body-pad     { padding: 16px 20px; max-height: 60vh; overflow-y: auto; }
.empty-state        { color: var(--muted); text-align: center; padding: 20px; }
/* Regulatory / informational callouts — theme-aware */
.reg-callout {
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  border-radius: 6px;
  border-left: 4px solid var(--border-2);
  background: var(--panel-2);
}
.reg-callout strong { color: var(--text); }
.reg-callout-info { background: var(--info-soft);    border-left-color: var(--info); }
.reg-callout-warn { background: var(--warning-soft); border-left-color: var(--warning); }
.reg-callout-ok   { background: var(--success-soft); border-left-color: var(--success); }
.reg-callout-err  { background: var(--danger-soft);  border-left-color: var(--danger); }
.color-muted        { color: var(--muted); }
.btn-row-tight      { padding: 6px 10px; font-size: 11px; }
.text-right         { text-align: right; }
.note-12-faint      { font-size: 12px; color: #64748b; }
.note-mb-12         { font-size: 12px; margin: 0 0 10px; }
.btn-pill-sm        { padding: 7px 14px; }
.note-mb-deep       { margin-bottom: 8px; color: #475569; }
.faint-shortcut     { opacity: .55; font-size: 11px; }
.tile-pad           { padding: 18px 16px; text-align: left; }
.label-strong       { font-weight: 600; margin-bottom: 4px; }
.amt-right-tabular  { text-align: right; font-variant-numeric: tabular-nums; }
.color-muted-10     { color: var(--muted); font-size: 10px; }
.tabular-tight      { font-variant-numeric: tabular-nums; }
.tile-flex          { flex: 1; padding: 14px; text-align: left; }

/* ============================================================
 * Global search overlay (Ctrl/Cmd+K). Was previously injected
 * via JS at runtime — moved to static CSS 2026-05-06 so the
 * strict CSP can refuse runtime <style> injection.
 * ============================================================ */
#gsearch-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 9999;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
#gsearch-overlay[hidden] { display: none; }
.gsearch-shell {
  background: #fff;
  width: min(640px, 92vw);
  border-radius: 12px;
  box-shadow: 0 24px 48px rgba(0,0,0,.18);
  overflow: hidden;
  border: 1px solid #e5e7eb;
}
#gsearch-input {
  width: 100%; box-sizing: border-box;
  border: 0; padding: 16px 18px; font-size: 16px;
  outline: none;
  border-bottom: 1px solid #f1f5f9;
}
#gsearch-results { max-height: 50vh; overflow-y: auto; }
.gsearch-row {
  display: flex; gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f8fafc;
  align-items: baseline;
}
.gsearch-row:hover, .gsearch-row.active { background: #f1f5f9; }
.gsearch-kind {
  flex: 0 0 auto;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: #64748b;
  min-width: 72px;
}
.gsearch-title { flex: 1 1 auto; font-size: 14px; color: #0f172a; }
.gsearch-sub   { flex: 0 0 auto; font-size: 12px; color: #64748b; }
.gsearch-muted { padding: 12px 18px; font-size: 12px; color: #64748b; }

/* ============================================================
 * Role-based UI gating (was previously injected at runtime).
 * Hides mutating buttons / nav for role=viewer.
 * ============================================================ */
body.role-viewer .primary:not(#nx-privacy-unlock),
body.role-viewer button.danger,
body.role-viewer .add-row-btn,
body.role-viewer [data-act="edit"],
body.role-viewer [data-act="del"],
body.role-viewer [data-act="delete"],
body.role-viewer [data-act="add-appt"] { display: none !important; }
body.role-viewer #new-company-btn,
body.role-viewer #new-form-btn,
body.role-viewer #new-invoice-btn,
body.role-viewer #export-btn,
body.role-viewer #import-btn { display: none !important; }

/* Privacy unlock button must always be visible & interactive regardless
   of role — losing it strands the user behind the privacy curtain. */
#nx-privacy-unlock {
  display: inline-block !important;
  pointer-events: auto !important;
  visibility: visible !important;
}

/* ===== KPI trend indicators (added 2026-05-06) =====
   Tiny "▲ 12% vs last month" / "▼ 4% vs last week" line under each KPI value.
   Color-coded: positive trend on revenue metrics → green; positive trend on
   overdue/MRO queue → red. Empty when there's no prior period to compare to
   (e.g., new tenant, no data last month). */
.kpi-trend {
  font-size: 11px;
  font-weight: 500;
  margin-top: 6px;
  color: var(--muted);
  letter-spacing: 0.01em;
  min-height: 14px;
}
.kpi-trend.is-up   { color: var(--success, #34d399); }
.kpi-trend.is-down { color: var(--danger, #f43f5e); }
.kpi-trend.is-flat { color: var(--muted); }
.kpi-trend .arrow { display: inline-block; margin-right: 3px; }

/* ===== Today's queue cross-domain groups =====
   Sub-headers within the Today list that separate appointments from MRO
   queue items, expiring equipment, and training refreshers. */
.today-group { margin-top: 14px; }
.today-group:first-child { margin-top: 0; }
.today-group-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.today-group-title .count {
  background: var(--panel-2, #1a1e27);
  color: var(--text-2, #b8bcc7);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
}
.today-group-title.is-warn .count { background: rgba(244, 63, 94, 0.18); color: var(--danger, #f43f5e); }
.today-group-title.is-info .count { background: rgba(96, 165, 250, 0.18); color: var(--info, #60a5fa); }

/* ===== Company tags (added 2026-05-06) =====
   Lightweight pill labels on company cards + drawer. Free-form text;
   user enters comma-separated values in the edit form. */
.company-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 14px;
}
.company-tags.card-tags { margin: 8px 0 0; }
.company-tag-pill {
  display: inline-block;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
  border-radius: 999px;
  background: var(--accent-soft, rgba(244, 63, 94, 0.12));
  color: var(--accent, #f43f5e);
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.company-tag-pill.is-more {
  background: var(--panel-2, #1a1e27);
  color: var(--muted);
}

/* Inline × on company tag pills (drawer-only — card pills stay flat). */
.company-tag-pill .tag-remove {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 0 0 6px;
  margin: 0;
  opacity: 0.55;
  font-weight: 600;
}
.company-tag-pill .tag-remove:hover { opacity: 1; }

/* Top-of-drawer display-only tag strip — no add/remove affordance, just
   a quick visual indicator. The full Tags management section still lives
   at the bottom of the drawer. */
.drawer-tags-top { margin: 0 0 14px; }

/* Compact tag pills inside table rows + small note indicator. */
.company-tags.row-tags { margin: 4px 0 0; gap: 4px; }
.company-tags.row-tags .company-tag-pill { font-size: 10px; padding: 1px 7px; }
.row-note-indicator {
  display: inline-block;
  font-size: 12px;
  margin-left: 6px;
  cursor: help;
  opacity: 0.85;
}

/* Customer statement (open-invoices summary in modal + print). */
.statement-print { font-size: 14px; }
.statement-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.statement-header h2 { margin: 0 0 4px; font-size: 20px; }
.statement-from { text-align: right; }
.statement-total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.statement-total { font-size: 24px; font-weight: 700; }
.aging-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.aging-grid > div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}
.statement-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
}
.statement-table th,
.statement-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.statement-table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.statement-table .text-right,
.statement-table th.text-right { text-align: right; }
.statement-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
@media print {
  body * { visibility: hidden !important; }
  #print-area, #print-area * { visibility: visible !important; }
  #print-area {
    position: absolute; left: 0; top: 0; width: 100%;
    padding: 24px;
  }
  .statement-actions { display: none !important; }
}

/* =====================================================
 * Reports tabs (revenue / forms / collectors)
 * ===================================================== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tabs .tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
.tabs .tab.active { color: var(--accent, #2563eb); border-bottom-color: var(--accent, #2563eb); }

/* =====================================================
 * Command palette (Cmd-K)
 * ===================================================== */
.nx-cmdk-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 10000;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.nx-cmdk-modal {
  width: min(640px, 92vw);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: 70vh;
}
.nx-cmdk-modal input {
  width: 100%;
  padding: 14px 18px;
  border: 0;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  outline: none;
}
.nx-cmdk-results { flex: 1; overflow-y: auto; padding: 6px; }
.nx-cmdk-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.nx-cmdk-row.is-active { background: #eef2ff; }
.nx-cmdk-kind {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.nx-cmdk-label { font-weight: 500; }
.nx-cmdk-hint { font-size: 12px; }
.nx-cmdk-empty { padding: 20px; text-align: center; }
.nx-cmdk-foot {
  display: flex; gap: 18px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  font-size: 12px;
}

/* =====================================================
 * Saved filter views pill row
 * ===================================================== */
.nx-saved-views {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-left: 8px;
}
.nx-saved-views select { font-size: 13px; }

/* =====================================================
 * First-run wizard
 * ===================================================== */
.nx-firstrun-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.nx-firstrun-modal {
  width: min(520px, 100%);
  background: #fff;
  color: #0f172a;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35);
}
.nx-firstrun-modal h2 { margin: 0 0 4px; color: #0f172a; }
.nx-firstrun-modal header p { color: #475569; margin: 0; }
.nx-firstrun-steps {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 14px;
}
.nx-firstrun-steps li {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f8fafc;
  color: #0f172a;
}
.nx-firstrun-steps .nx-fr-step-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
  color: #0f172a;
}
.nx-firstrun-steps p { color: #475569; }
.nx-firstrun-modal input,
.nx-firstrun-steps input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  background: #fff !important;
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a;
}
.nx-firstrun-steps input::placeholder { color: #94a3b8; }
.nx-firstrun-steps input:-webkit-autofill,
.nx-firstrun-steps input:-webkit-autofill:hover,
.nx-firstrun-steps input:-webkit-autofill:focus {
  -webkit-text-fill-color: #0f172a !important;
  -webkit-box-shadow: 0 0 0 1000px #fff inset !important;
  box-shadow: 0 0 0 1000px #fff inset !important;
  caret-color: #0f172a;
}
.nx-firstrun-foot {
  display: flex; justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* =====================================================
 * What's new banner
 * ===================================================== */
.nx-whats-new {
  position: fixed;
  bottom: 16px; right: 16px;
  width: min(380px, calc(100vw - 32px));
  background: #fff;
  color: #0f172a;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.18);
  padding: 14px 16px;
  z-index: 8000;
  font-size: 13px;
  line-height: 1.45;
}
.nx-wn-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}
.nx-wn-head strong { color: #0f172a; }
.nx-wn-head .muted { font-size: 11px; }
.nx-wn-head .icon-btn { margin-left: auto; }
.nx-wn-list {
  margin: 0; padding: 0; list-style: none;
  color: #0f172a;
}
.nx-wn-list li {
  padding: 9px 0;
  border-top: 1px solid #e2e8f0;
}
.nx-wn-list li:first-child { border-top: 0; padding-top: 4px; }
.nx-wn-list li strong { color: #0f172a; font-weight: 600; }

/* =====================================================
 * Custom prompt / confirm — replaces window.prompt + confirm
 * with our dark-theme modal styling. Used app-wide.
 * ===================================================== */
.nx-prompt-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 11000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.nx-prompt-modal {
  width: min(440px, 100%);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  padding: 22px 22px 18px;
  box-shadow: var(--shadow-lg, 0 25px 50px -12px rgba(0,0,0,0.45));
}
.nx-prompt-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.nx-prompt-body {
  font-size: 13.5px;
  color: var(--text-2);
  margin-bottom: 14px;
  line-height: 1.5;
}
.nx-prompt-input {
  width: 100%;
  background: var(--bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.nx-prompt-input:focus { border-color: var(--accent) !important; }
textarea.nx-prompt-input { resize: vertical; min-height: 80px; }
.nx-prompt-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ==== nxConfirm() / nxShowUpgradeModal() — added 2026-05-08 ==== */
.nx-confirm-bg {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: nx-fade-in 120ms ease;
}
.nx-confirm {
  background: var(--bg, #fff); color: var(--text, #161b26);
  width: min(440px, 100%);
  border-radius: 14px;
  padding: 24px 24px 20px;
  box-shadow: 0 24px 48px -12px rgba(0,0,0,0.35);
  border: 1px solid var(--border, #e5e7eb);
}
.nx-confirm h3 { margin: 0 0 8px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.nx-confirm-msg { color: var(--muted, #475569); font-size: 14px; line-height: 1.5; margin-bottom: 22px; }
.nx-confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.nx-confirm-actions button,
.nx-confirm-actions a.primary {
  padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 500;
  border: 0; cursor: pointer; text-decoration: none; display: inline-block;
}
.nx-confirm-actions button.ghost { background: transparent; color: var(--text, #161b26); border: 1px solid var(--border, #e5e7eb); }
.nx-confirm-actions button.primary,
.nx-confirm-actions a.primary { background: #9d2553; color: #fff; }
.nx-confirm-actions button.primary:hover,
.nx-confirm-actions a.primary:hover { background: #7e1d42; }
.nx-confirm-actions button.danger { background: #b91c1c; color: #fff; }
.nx-confirm-actions button.danger:hover { background: #991b1b; }
.nx-upgrade { text-align: center; padding-top: 28px; }
.nx-upgrade-icon { font-size: 36px; margin-bottom: 6px; }
.nx-upgrade .nx-confirm-actions { justify-content: center; }
@keyframes nx-fade-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

/* ==== Sidebar plan-gate badge ==== */
.sidebar .nav-btn .plan-badge {
  display: inline-block;
  background: #9d2553; color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px;
  margin-left: 6px; vertical-align: middle;
  letter-spacing: 0.05em;
}

/* ==== DOT Pro upgrade preview (dot.html, Standard plan) ==== */
.dot-preview { max-width: 1100px; margin: 0 auto; padding: 12px 0 64px; }
.dot-preview-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #f1f5f9; padding: 44px 44px 38px; border-radius: 16px;
  margin-bottom: 28px; text-align: center;
  box-shadow: 0 18px 36px -18px rgba(15, 23, 42, 0.45);
}
.dot-preview-eyebrow {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: rgba(157, 37, 83, 0.18); color: #f9a8d4;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 14px;
}
.dot-preview-hero h1 { margin: 0 0 12px; font-size: 30px; line-height: 1.2; letter-spacing: -0.02em; color: #fff; }
.dot-preview-lead { color: #cbd5e1; font-size: 14px; line-height: 1.6; max-width: 720px; margin: 0 auto 22px; }
.dot-preview-ctas { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-primary-pill, .btn-ghost-pill {
  display: inline-block; padding: 11px 22px; border-radius: 8px;
  font-weight: 600; font-size: 14px; text-decoration: none;
}
.btn-primary-pill { background: #fff; color: #0f172a; }
.btn-primary-pill:hover { background: #e2e8f0; }
.btn-ghost-pill { background: transparent; color: #f1f5f9; border: 1px solid rgba(255,255,255,0.25); }
.btn-ghost-pill:hover { background: rgba(255, 255, 255, 0.08); }

.dot-preview-mock {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 18px 20px; margin: 0 auto 32px; max-width: 880px;
  position: relative;
}
.dot-preview-mock::after {
  content: 'PREVIEW'; position: absolute; top: 12px; right: 16px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  color: #94a3b8; padding: 3px 8px; border: 1px solid #e2e8f0; border-radius: 4px;
}
.dpm-tabs { display: flex; gap: 18px; padding-bottom: 12px; border-bottom: 1px solid #f1f5f9; margin-bottom: 16px; overflow-x: auto; }
.dpm-tab { font-size: 13px; color: #94a3b8; white-space: nowrap; padding-bottom: 6px; }
.dpm-tab.active { color: #161b26; font-weight: 600; border-bottom: 2px solid #9d2553; }
.dpm-card-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 14px; }
.dpm-pill { background: #fce7f3; color: #9d2553; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.dpm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dpm-table th { text-align: left; padding: 8px; color: #64748b; font-weight: 500; font-size: 11px; text-transform: uppercase; border-bottom: 1px solid #f1f5f9; }
.dpm-table td { padding: 9px 8px; border-bottom: 1px solid #f8fafc; }
.dpm-table code { font-family: ui-monospace, monospace; color: #475569; font-size: 12px; }
.dpm-muted td { color: #94a3b8; font-style: italic; text-align: center; }

.dot-preview-features { padding: 12px 0 24px; }
.dot-preview-features h2 {
  text-align: center; font-size: 22px; margin: 0 0 24px;
  letter-spacing: -0.01em; color: #161b26;
}
.dpf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.dpf-cell {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 18px; transition: border-color .15s, transform .15s;
}
.dpf-cell:hover { border-color: #fbcfe8; }
.dpf-cell .dpf-i { font-size: 20px; display: block; margin-bottom: 6px; }
.dpf-cell strong { display: block; font-size: 14px; margin-bottom: 4px; color: #161b26; }
.dpf-cell p { margin: 0; font-size: 12px; color: #64748b; line-height: 1.5; }
.dpf-cell code { font-family: ui-monospace, monospace; font-size: 11px; background: #f1f5f9; padding: 1px 5px; border-radius: 3px; color: #475569; }

.dot-preview-cta-block {
  text-align: center; padding: 32px 24px; margin-top: 24px;
  background: #fdf2f8; border: 1px solid #fce7f3; border-radius: 12px;
}
.dot-preview-cta-block h3 { margin: 0 0 6px; font-size: 18px; color: #161b26; }
.dot-preview-cta-block h3 strong { color: #9d2553; }
.dot-preview-cta-block .muted { color: #64748b; font-size: 13px; margin: 0 0 20px; }
.dot-preview-cta-block .btn-primary-pill { background: #9d2553; color: #fff; }
.dot-preview-cta-block .btn-primary-pill:hover { background: #7e1d42; }
.dot-preview-cta-block .btn-ghost-pill { color: #9d2553; border-color: #fbcfe8; }
.dot-preview-cta-block .btn-ghost-pill:hover { background: #fce7f3; }

@media (max-width: 880px) {
  .dpf-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .dpf-grid { grid-template-columns: 1fr; }
  .dot-preview-hero { padding: 28px 20px; }
  .dot-preview-hero h1 { font-size: 22px; }
}

/* ==== Home page DOT KPI card — promo variant (Standard plan) ==== */
.kpi-dot-promo {
  padding: 18px 20px; border-radius: 12px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); color: #f1f5f9;
}
.kpi-dot-promo-eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #f9a8d4; margin-bottom: 6px; }
.kpi-dot-promo-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.kpi-dot-promo-sub { font-size: 12px; color: #cbd5e1; line-height: 1.5; margin-bottom: 12px; }
.kpi-dot-promo-cta { color: #f9a8d4; font-size: 13px; font-weight: 600; text-decoration: none; }
.kpi-dot-promo-cta:hover { color: #fff; }

/* Setup wizard — highlight the next step ("current") and surface its hint */
.setup-checklist li.current {
  background: #fef3c7;
  border-left: 3px solid #d97706;
  padding-left: 12px;
  border-radius: 6px;
}
.setup-checklist li.current .label { font-weight: 600; }
.setup-checklist .step-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  color: #92400e;
  line-height: 1.4;
}
.setup-checklist li.done .label { text-decoration: line-through; opacity: 0.6; }
.setup-checklist li button:disabled { opacity: 0.4; cursor: default; }
