/* ── Brand tokens ─────────────────────────────────────────── */
:root {
  --dark-red:    #a02932;
  --coal:        #141617;
  --romance-blue:#6a89a8;
  --white:       #ffffff;
  --success:     #144931;
  --warning:     #F39C07;
  --error-red:   #FF2929;
  --neutral-gray:#6C757D;
  --light-grey:  #EBECF0;

  --border:      #d1d5db;

  --sidebar-bg:      #1a1d1e;
  --sidebar-accent:  #a02932;
  --sidebar-text:    #ffffff;
  /* Derived opacity variants — overridden via inline <style> when custom colors are set */
  --sidebar-text-65: rgba(255,255,255,.65);
  --sidebar-text-50: rgba(255,255,255,.50);
  --sidebar-text-40: rgba(255,255,255,.40);
  --sidebar-text-35: rgba(255,255,255,.35);
  --sidebar-text-30: rgba(255,255,255,.30);
  --sidebar-text-28: rgba(255,255,255,.28);
  --sidebar-text-55: rgba(255,255,255,.55);
  --sidebar-text-15: rgba(255,255,255,.15);
  --sidebar-text-08: rgba(255,255,255,.08);
  --sidebar-text-07: rgba(255,255,255,.07);
  --sidebar-text-06: rgba(255,255,255,.06);
  --sidebar-accent-25: rgba(160,41,50,.25);
  --sidebar-accent-40: rgba(160,41,50,.40);
  --sidebar-w:   240px;
  --header-h:    56px;
  --radius:      6px;
  --shadow:      0 1px 4px rgba(0,0,0,.12);
  --shadow-md:   0 4px 16px rgba(0,0,0,.15);
}

/* ── Reset / base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  background: var(--light-grey);
  color: var(--coal);
  line-height: 1.6;
}
a { color: var(--dark-red); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&display=swap');

/* ── App shell ────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--sidebar-accent-40);
}
.sidebar-logo img {
  width: 160px;
}
/* Applied only to the default logo (dark artwork on transparent bg) so it renders white on the dark sidebar */
.sidebar-logo img.logo-invert {
  filter: brightness(0) invert(1);
}
.sidebar-logo a:hover { text-decoration: none; }

.sidebar-app-name {
  padding: 8px 16px 12px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sidebar-accent);
  border-bottom: 1px solid var(--sidebar-accent-40);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section {
  margin-bottom: 4px;
}
.nav-section-label {
  padding: 8px 16px 4px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sidebar-accent);
}
/* Collapsible section toggle */
button.nav-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  transition: color .15s;
}
button.nav-section-label:hover {
  color: var(--sidebar-text);
}
.nav-section-chevron {
  font-size: .8rem;
  opacity: .45;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform .22s ease, opacity .15s;
  margin-left: 4px;
  flex-shrink: 0;
}
.nav-section.collapsed .nav-section-chevron {
  transform: rotate(0deg);
  opacity: .3;
}
.nav-section-items {
  overflow: hidden;
  max-height: 600px;
  transition: max-height .28s ease;
}
.nav-section.collapsed .nav-section-items {
  max-height: 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--sidebar-text-65);
  font-size: .875rem;
  border-radius: 0;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: var(--sidebar-text-06);
  color: var(--sidebar-text);
  text-decoration: none;
}
.nav-item.active {
  background: var(--sidebar-accent-25);
  color: var(--sidebar-text);
  border-left-color: var(--sidebar-accent);
}
.nav-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-text-08);
  padding: 12px 16px;
}
.sidebar-version {
  font-size: .7rem;
  color: var(--sidebar-accent);
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: .04em;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sidebar-user-link {
  text-decoration: none;
  border-radius: var(--radius);
  padding: 6px 8px;
  margin: -6px -8px 4px;
  transition: background .15s;
}
.sidebar-user-link:hover,
.sidebar-user-link.active { background: var(--sidebar-text-08); }
.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--sidebar-accent);
  color: var(--sidebar-text);
  font-size: .85rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-name {
  font-size: .825rem;
  color: var(--sidebar-text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: .7rem;
  color: var(--sidebar-text-40);
  text-transform: capitalize;
}
.sidebar-logout {
  width: 100%;
  background: transparent;
  border: 1px solid var(--sidebar-text-15);
  color: var(--sidebar-text-55);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: .8rem;
  font-family: inherit;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s;
}
.sidebar-logout:hover {
  background: var(--sidebar-text-07);
  color: var(--sidebar-text);
}

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Top header ───────────────────────────────────────────── */
.top-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid #dde0e4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .875rem;
  color: var(--neutral-gray);
}
.breadcrumb a { color: var(--dark-red); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: #c5c9ce; }
.breadcrumb-current { color: var(--coal); font-weight: 600; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Page content ─────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 24px;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  position: relative;
  padding: 12px 40px 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-dismiss {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  opacity: .5;
  padding: 4px 6px;
  color: inherit;
  border-radius: 3px;
  transition: opacity .15s, background .15s;
  flex-shrink: 0;
}
.alert-dismiss:hover {
  opacity: 1;
  background: rgba(0, 0, 0, .07);
}
.alert-success {
  background: #d1f0e0;
  color: var(--success);
  border: 1px solid #a3dfc0;
}
.alert-error {
  background: #ffe4e4;
  color: var(--error-red);
  border: 1px solid #fbb;
}
.alert-warning {
  background: #fff8e1;
  color: #7a5000;
  border: 1px solid #f5d87e;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
/* Allow absolutely-positioned picker dropdowns to overflow the card boundary */
.card-open { overflow: visible; }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--light-grey);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--coal);
  margin: 0;
}
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--light-grey);
  background: #fafafa;
}

/* ── Stat cards ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--dark-red);
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--coal);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: .8rem;
  color: var(--neutral-gray);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.stat-trend {
  font-size: .73rem;
  color: var(--neutral-gray);
  margin-top: 6px;
}

/* ── Page header row ──────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--coal);
}

/* ── Buttons ──────────────────────────────────────────────────────────
   Three fixed-height standards — height (not padding) is the source of
   truth, so a button's size can never drift from font-size, icon/emoji
   content, or an inline style adding text. Any buttons that sit in the same
   row/toolbar must share one of these three classes so their tops/bottoms
   line up exactly:
     .btn-lg  44px  — standalone/hero actions (auth, intake submit)
     .btn     38px  — default; the vast majority of buttons
     .btn-sm  30px  — dense contexts: table rows, compact toolbars, tabs
   ────────────────────────────────────────────────────────────────────── */
:root {
  --btn-h-lg: 44px;
  --btn-h-md: 38px;
  --btn-h-sm: 30px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--btn-h-md);
  padding: 0 16px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .875rem;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--dark-red);
  color: #fff;
  border-color: var(--dark-red);
}
.btn-primary:hover { background: #841f27; border-color: #841f27; color: #fff; }
.btn-secondary {
  background: var(--white);
  color: var(--coal);
  border-color: #c5c9ce;
}
.btn-secondary:hover { background: var(--light-grey); }
.btn-danger {
  background: var(--error-red);
  color: #fff;
  border-color: var(--error-red);
}
.btn-danger:hover { background: #d42020; border-color: #d42020; color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--coal);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--light-grey); }
.btn-lg { height: var(--btn-h-lg); padding: 0 22px; font-size: 1rem; gap: 8px; }
.btn-sm { height: var(--btn-h-sm); padding: 0 12px; font-size: .8rem; gap: 4px; }
.btn-block { width: 100%; }
.btn-link {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
  color: var(--dark-red);
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  cursor: pointer;
  text-decoration: underline;
}

/* ── Tables ───────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table th {
  background: var(--dark-red);
  color: #fff;
  font-weight: 700;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  font-size: .8rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid #eef0f2;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fafbfc; }
.table-actions { display: flex; gap: 8px; align-items: center; }
.table-empty {
  text-align: center;
  color: var(--neutral-gray);
  padding: 40px 20px;
  font-style: italic;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .73rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.badge-success  { background: #d1f0e0; color: var(--success); }
.badge-info     { background: #dce8f3; color: #1e4d73; }
.badge-warning  { background: #fef3dc; color: #8a5a00; }
.badge-error    { background: #ffe4e4; color: #a02020; }
.badge-neutral  { background: var(--light-grey); color: var(--neutral-gray); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  margin-bottom: 5px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--coal);
}
.form-label .req { color: var(--dark-red); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #c5c9ce;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .9rem;
  color: var(--coal);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--romance-blue);
  box-shadow: 0 0 0 3px rgba(106,137,168,.2);
}
.form-control.is-invalid { border-color: var(--error-red); }
.has-error .form-control { border-color: var(--error-red); }
.form-error {
  margin-top: 4px;
  font-size: .8rem;
  color: var(--error-red);
}
.form-error-banner {
  background: #ffe4e4;
  border: 1px solid #fbb;
  color: var(--error-red);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: .875rem;
}
.form-hint {
  margin-top: 4px;
  font-size: .78rem;
  color: var(--neutral-gray);
}
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--dark-red);
  cursor: pointer;
}
.form-check-label {
  font-size: .9rem;
  color: var(--coal);
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0 20px;
}

.form-section {
  margin-bottom: 28px;
}
.form-section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--dark-red);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--light-grey);
  margin-bottom: 16px;
}

.form-actions {
  display: flex;
  gap: 12px;
  padding-top: 8px;
}

/* ── Filter bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar .form-control {
  width: auto;
  min-width: 180px;
}
.filter-bar form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Status filter picker ────────────────────────────────── */
.sf-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
/* Include / Exclude button-group toggle */
.sf-mode-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}
.sf-mode-btn {
  display: inline-flex;
  align-items: center;
  height: var(--btn-h-sm);
  padding: 0 13px;
  font-size: .8rem;
  font-family: inherit;
  cursor: pointer;
  background: #fff;
  color: var(--neutral-gray);
  line-height: 1;
  transition: background .1s, color .1s;
  user-select: none;
  white-space: nowrap;
}
.sf-mode-btn + .sf-mode-btn { border-left: 1px solid var(--border); }
.sf-mode-btn input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.sf-mode-btn.sf-mode-active        { background: var(--dark-red); color: #fff; }
.sf-mode-btn:not(.sf-mode-active):hover { background: var(--light-grey); color: var(--coal); }
/* Picker wrap — flex container so chips + input share one row */
.sf-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 4px 10px 4px;
  cursor: text;
  min-height: 38px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  transition: border-color .15s, box-shadow .15s;
}
.sf-wrap:focus-within {
  border-color: var(--romance-blue);
  box-shadow: 0 0 0 3px rgba(106,137,168,.15);
}
/* display:contents lets chips flow as flex items of sf-wrap */
.sf-chips { display: contents; }
/* Chips */
.sf-chip {
  display: inline-flex;
  align-items: stretch;
  background: var(--light-grey);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-left-color: var(--romance-blue);
  border-radius: 4px;
  font-size: .81rem;
  color: var(--coal);
  user-select: none;
  overflow: hidden;
  flex-shrink: 0;
}
.sf-chip-label {
  display: block;
  padding: 3px 6px 3px 7px;
  line-height: 1.4;
  white-space: nowrap;
}
.sf-chip-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  padding: 0;
  border: none;
  border-left: 1px solid rgba(0,0,0,.10);
  background: rgba(0,0,0,.04);
  color: var(--neutral-gray);
  font-size: .78rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.sf-chip-remove:hover {
  background: rgba(255,41,41,.14);
  color: var(--error-red);
}
/* Inline search input */
.sf-input {
  flex: 1;
  min-width: 120px;
  border: none;
  outline: none;
  background: transparent;
  padding: 3px 2px;
  font-size: .85rem;
  font-family: inherit;
  color: var(--coal);
}
.sf-input::placeholder { color: #adb3bc; }
/* Dropdown panel */
.sf-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  z-index: 300;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}
.sf-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background .1s;
}
.sf-item:hover,
.sf-item-active { background: var(--light-grey); }
.sf-item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: block;
}
.sf-item-label {
  display: block;
  font-size: .88rem;
  color: var(--coal);
}
.sf-empty {
  display: block;
  padding: 10px 14px;
  font-size: .84rem;
  color: var(--neutral-gray);
  font-style: italic;
}

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding-top: 16px;
  flex-wrap: wrap;
}
.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--radius);
  font-size: .85rem;
  border: 1px solid #dde0e4;
  background: var(--white);
  color: var(--coal);
  transition: background .15s;
}
.pagination a:hover { background: var(--light-grey); text-decoration: none; }
.pagination .active {
  background: var(--dark-red);
  color: #fff;
  border-color: var(--dark-red);
}
.pagination .disabled { color: #c5c9ce; cursor: default; }

/* ── Detail layout ────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.detail-table { width: 100%; }
.detail-table tr td:first-child {
  font-weight: 600;
  color: var(--neutral-gray);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  width: 36%;
  padding: 8px 12px 8px 0;
  vertical-align: top;
}
.detail-table tr td:last-child {
  padding: 8px 0;
  color: var(--coal);
  font-size: .9rem;
}
.detail-table tr { border-bottom: 1px solid var(--light-grey); }
.detail-table tr:last-child { border-bottom: none; }

/* ── Dashboard layout ─────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ── Report Builder grid (4-col: quarter/half/full objects) ─── */
.report-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .report-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .report-grid { grid-template-columns: 1fr; }
}

/* ── Dashboard widget system ──────────────────────────────── */

/* Drag handle — hidden until customize mode */
.widget-drag-handle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: grab;
  color: var(--neutral-gray);
  opacity: 0.45;
  transition: opacity .15s, background .15s;
  user-select: none;
  flex-shrink: 0;
}
.dash-customizing .widget-drag-handle {
  display: inline-flex;
}
.widget-drag-handle:hover {
  opacity: 1;
  background: var(--light-grey);
}
.widget-drag-handle:active {
  cursor: grabbing;
  opacity: 1;
}

/* Hide button — shown only in customize mode */
.widget-hide-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--neutral-gray);
  font-size: .75rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.widget-hide-btn-inline {
  width: auto;
  height: auto;
  border-radius: var(--radius);
  padding: 3px 8px;
  font-size: .75rem;
}
.dash-customizing .widget-hide-btn {
  display: inline-flex;
}
.widget-hide-btn:hover {
  background: #fee2e2;
  color: #991b1b;
}

/* Stat-cards customize bar (shown only in customize mode) */
.dash-customize-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 8px;
  margin-bottom: 6px;
}
.dash-customizing .dash-customize-bar {
  display: flex;
}

/* Stats widget area — subtle outline in customize mode */
.dash-customizing .stats-widget-area {
  border: 2px dashed #e8d5d5;
  border-radius: var(--radius);
  padding: 10px 10px 4px;
  margin-bottom: 4px;
}

/* Sortable drag states */
.widget-ghost {
  opacity: 0.35;
  background: var(--light-grey) !important;
  border: 2px dashed var(--dark-red) !important;
  border-radius: var(--radius);
}
.widget-ghost * { visibility: hidden; }
.widget-chosen {
  box-shadow: var(--shadow-md);
}
.widget-dragging {
  opacity: 0.92;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  transform: rotate(0.8deg);
}

/* Highlight sortable columns while dragging */
.dash-customizing .sortable-col {
  min-height: 60px;
  border-radius: var(--radius);
  transition: background .15s;
}
.dash-customizing .sortable-col.sortable-drag-over {
  background: rgba(160,41,50,.04);
}

/* Add widget chip grid */
.widget-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.widget-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--white);
  transition: border-color .15s, box-shadow .15s, background .15s;
  user-select: none;
}
.widget-chip:hover {
  border-color: var(--dark-red);
  background: #fdf5f5;
  box-shadow: var(--shadow);
}
.widget-chip-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}
.widget-chip-body {
  flex: 1;
  min-width: 0;
}
.widget-chip-label {
  font-size: .875rem;
  font-weight: 600;
  color: var(--coal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.widget-chip-desc {
  font-size: .75rem;
  color: var(--neutral-gray);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.widget-chip-add {
  font-size: .75rem;
  font-weight: 700;
  color: var(--dark-red);
  flex-shrink: 0;
  white-space: nowrap;
}

/* [x-cloak] hide before Alpine initialises */
[x-cloak] { display: none !important; }

/* ── Auth pages ───────────────────────────────────────────── */
.auth-body {
  background: var(--coal);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-wrapper {
  width: 100%;
  max-width: 420px;
  padding: 24px 16px;
}
.auth-card {
  background: var(--white);
  border-radius: 10px;
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}
.auth-logo {
  text-align: center;
  margin-bottom: 20px;
}
.auth-logo img { width: 180px; }
.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--coal);
  text-align: center;
  margin-bottom: 4px;
}
.auth-subtitle {
  font-size: .85rem;
  color: var(--neutral-gray);
  text-align: center;
  margin-bottom: 24px;
}
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: .78rem;
  color: rgba(255,255,255,.3);
}
.auth-form .form-group { margin-bottom: 16px; }

/* ── Inline delete form ───────────────────────────────────── */
.inline-form { display: inline; }

/* ── Form enhancements ────────────────────────────────────── */
.form-control-sm { padding: 4px 8px; font-size: .85rem; }
.form-hint {
  font-size: .78rem;
  color: var(--neutral-gray);
  margin-top: 4px;
}
.form-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: .9rem;
}
.form-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: 10px 0;
}

/* ── Rich-text content display ────────────────────────────── */
.rich-content p   { margin-bottom: .5em; }
.rich-content ul,
.rich-content ol  { padding-left: 1.5em; margin-bottom: .5em; }
.rich-content a   { color: var(--romance-blue); text-decoration: underline; }
.rich-content strong { font-weight: 700; }
.rich-content em     { font-style: italic; }

/* ── Saved Views ─────────────────────────────────────────── */
.sv-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}
.sv-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--neutral-gray);
  flex-shrink: 0;
}
.sv-empty {
  font-size: .8rem;
  color: var(--neutral-gray);
  font-style: italic;
}
/* Each saved-view chip */
.sv-chip {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--white);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.sv-chip:hover {
  border-color: var(--dark-red);
  box-shadow: 0 1px 4px rgba(160,41,50,.12);
}
.sv-chip--active {
  border-color: var(--dark-red);
  background: rgba(160,41,50,.06);
}
.sv-chip--active .sv-chip-name {
  color: var(--dark-red);
  font-weight: 600;
}
.sv-chip-name {
  padding: 4px 10px;
  font-size: .8rem;
  color: var(--coal);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.sv-chip-name:hover { color: var(--dark-red); text-decoration: none; }
.sv-chip-del-form { display: contents; }
.sv-chip-del {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  padding: 4px 8px;
  cursor: pointer;
  color: var(--neutral-gray);
  font-size: .85rem;
  line-height: 1;
  transition: background .15s, color .15s;
}
.sv-chip:hover .sv-chip-del { border-left-color: rgba(160,41,50,.2); }
.sv-chip-del:hover {
  background: var(--error-red);
  color: #fff;
}
/* "+ Save view" trigger button */
.sv-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: .8rem;
  font-family: inherit;
  color: var(--neutral-gray);
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}
.sv-add-btn:hover {
  border-color: var(--dark-red);
  color: var(--dark-red);
}
/* Inline save form */
.sv-save-form { display: flex; align-items: center; }
.sv-name-input {
  padding: 4px 10px !important;
  height: 32px !important;
  font-size: .82rem !important;
  width: 180px;
  min-width: 140px;
}

/* ── Guest picker ────────────────────────────────────────── */
.gp-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 6px 10px 4px;
  cursor: text;
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
.gp-wrap:focus-within {
  border-color: var(--romance-blue);
  box-shadow: 0 0 0 3px rgba(106,137,168,.15);
}
/* Chips row */
.gp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
/* Individual chip */
.gp-chip {
  display: inline-flex;
  align-items: stretch;
  background: #fff;
  border: 1px solid #b0b8c4;
  border-radius: 4px;
  font-size: .84rem;
  color: var(--coal);
  user-select: none;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  max-width: 300px;
}
.gp-chip-name {
  display: block;
  padding: 4px 8px 4px 10px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gp-chip-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  padding: 0;
  border: none;
  border-left: 1px solid #dde1e7;
  background: #f4f6f9;
  color: #8a92a0;
  font-size: .85rem;
  line-height: 1;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.gp-chip-remove:hover {
  background: #fdeaea;
  color: var(--error-red);
}
/* Text input */
.gp-input {
  display: block;
  width: 100%;
  min-width: 160px;
  border: none;
  outline: none;
  background: transparent;
  padding: 4px 2px;
  font-size: .9rem;
  font-family: inherit;
  color: var(--coal);
}
.gp-input::placeholder { color: #adb3bc; }
/* Dropdown panel — div-based, no bullets possible */
.gp-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,.14);
  z-index: 300;
  max-height: 296px;
  overflow-y: auto;
  padding: 4px 0;
}
/* Dropdown items */
.gp-item {
  display: block;
  padding: 10px 16px 10px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .1s, border-color .1s;
}
.gp-item:hover,
.gp-item-active {
  background: var(--light-grey);
  border-left-color: var(--dark-red);
}
.gp-item-name {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  color: var(--coal);
  line-height: 1.3;
}
.gp-item-email {
  display: block;
  font-size: .76rem;
  color: var(--neutral-gray);
  margin-top: 2px;
  line-height: 1.2;
}
.gp-empty {
  display: block;
  padding: 12px 16px;
  font-size: .85rem;
  color: var(--neutral-gray);
  font-style: italic;
}
.gp-hint {
  font-size: .78rem;
  color: var(--neutral-gray);
  margin-top: 6px;
}

/* ── Notes ───────────────────────────────────────────────── */
.notes-list { border-top: 1px solid var(--border); }
.note-item {
  padding: 16px 20px;
  border-bottom: 1px solid #e9ecef;
}
.note-item:last-child { border-bottom: none; }
.note-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: .82rem;
  color: var(--neutral-gray);
}
.note-author { font-weight: 600; color: var(--coal); }
.note-sep    { color: #c5c9ce; }
.note-date   { font-style: italic; }
.note-body   { font-size: .9rem; line-height: 1.6; }

/* ── Lookup 3-column grid ─────────────────────────────────── */
.lookup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-items: start;
}
.lookup-card .table th,
.lookup-card .table td { padding: 8px 10px; font-size: .85rem; }
@media (max-width: 1100px) { .lookup-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px)  { .lookup-grid { grid-template-columns: 1fr; } }

/* ── Settings grid ────────────────────────────────────────── */
.settings-grid { max-width: 720px; }

/* ── Upload / headshot preview ────────────────────────────── */
input[type="file"].form-control {
  padding: 6px 10px;
  cursor: pointer;
}

/* ── Sortable table headers ───────────────────────────────── */
/* Scoped to .table th so specificity beats the global a { color: var(--dark-red) } rule. */
.sortable-th { white-space: nowrap; }

.table th .sort-link,
.table th .sort-link:link,
.table th .sort-link:visited,
.table th .sort-link:hover,
.table th .sort-link:active {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #fff !important;
  text-decoration: none;
  font-weight: 700;
  font-size: inherit;
  letter-spacing: inherit;
}
.table th .sort-link:hover {
  text-decoration: underline;
}

.sort-icon {
  font-size: .7rem;
  line-height: 1;
  font-style: normal;
  opacity: .45;
}
.sort-icon--idle  { opacity: .35; }
.sort-icon--asc,
.sort-icon--desc  { opacity: 1; }

/* ── Badge extras ─────────────────────────────────────────── */
.badge-warning {
  background: rgba(243,156,7,.15);
  color: #b07900;
  border: 1px solid rgba(243,156,7,.3);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
