/* ============================================================
   OnCall Intelligence — App Stylesheet
   Bootstrap 5 + Brand Overrides + App Shell
   Reference: /docs/brand.md
   ============================================================ */

/* ── Brand Tokens ─────────────────────────────────────────── */
:root {
  --ink:   #172f2d;
  --muted: #61706b;
  --paper: #f8f9f3;
  --line:  #dce2d7;
  --green: #264f44;
  --lime:  #d9efb9;

  /* Sidebar palette */
  --sb-bg:       #1a3530;
  --sb-hover:    #243e38;
  --sb-active:   #2d5447;
  --sb-border:   #2d4a43;
  --sb-text:     #b0c4bc;
  --sb-muted:    #5a7a70;
  --sb-width:    240px;
  --sb-collapsed:64px;

  /* Header */
  --hdr-height:  60px;

  /* Bootstrap overrides */
  --bs-primary:            #172f2d;
  --bs-primary-rgb:        23, 47, 45;
  --bs-body-bg:            #f8f9f3;
  --bs-body-color:         #172f2d;
  --bs-border-color:       #dce2d7;
  --bs-link-color:         #264f44;
  --bs-link-hover-color:   #325e4e;
  --bs-font-sans-serif:    Arial, Helvetica, sans-serif;
  --bs-border-radius:      6px;
  --bs-border-radius-lg:   10px;
}

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: Arial, Helvetica, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
}

a { color: var(--green); }
a:hover { color: #325e4e; }

h1, h2, h3, h4, h5, h6 {
  line-height: 1.12;
  letter-spacing: -0.045em;
  font-weight: 500;
  color: var(--ink);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  --bs-btn-bg:                var(--ink);
  --bs-btn-border-color:      var(--ink);
  --bs-btn-color:             #ffffff;
  --bs-btn-hover-bg:          #325e4e;
  --bs-btn-hover-border-color:#325e4e;
  --bs-btn-hover-color:       #ffffff;
  --bs-btn-active-bg:         #264f44;
  --bs-btn-active-border-color:#264f44;
  --bs-btn-focus-shadow-rgb:  23, 47, 45;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  padding: 10px 20px;
  transition: background .2s, transform .2s;
}
.btn-primary:hover { transform: translateY(-1px); }

.btn-lime {
  background: var(--lime);
  color: #183b2d;
  border: none;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  padding: 10px 20px;
  transition: background .2s;
}
.btn-lime:hover { background: #eefbdc; color: #183b2d; }

/* ── Forms ────────────────────────────────────────────────── */
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 5px;
}

.form-control, .form-select {
  border-color: var(--line);
  border-radius: 6px;
  font-size: 14px;
  color: var(--ink);
  background-color: #fff;
}

.form-control:focus, .form-select:focus {
  border-color: #9a6500;
  box-shadow: 0 0 0 3px rgba(154, 101, 0, .15);
  outline: none;
}

.form-control::placeholder { color: var(--muted); }
.form-text { font-size: 11px; color: var(--muted); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffefb;
  box-shadow: 0 10px 30px rgba(32,59,52,.07);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  padding: 18px 24px;
}

.card-body { padding: 24px; }

/* ── Status Pills ─────────────────────────────────────────── */
.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.pill-amber { background: #f5edcf; color: #73561b; }
.pill-green { background: #e5efde; color: #426239; }
.pill-gray  { background: #edf0ed; color: #526354; }
.pill-red   { background: #f6dede; color: #8a2f2f; }
.pill-blue  { background: #dbedf5; color: #1a5276; }

/* ── Vendor star rating ───────────────────────────────────── */
.star-rating-filled { color: #f5a623; }
.star-rating-empty  { color: #c9ccc7; }

/* ── Attachments (file list / card views) ────────────────────── */
.attachment-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.attachment-card .attachment-thumb {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  font-size: 40px;
  color: var(--muted);
}
.attachment-card .attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attachment-card .attachment-name {
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-card .attachment-actions {
  position: absolute;
  inset: 0;
  bottom: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(23, 47, 45, 0.55);
  opacity: 0;
  transition: opacity .15s ease;
}
.attachment-card:hover .attachment-actions { opacity: 1; }
.attachment-actions .btn {
  --bs-btn-padding-x: .45rem;
  --bs-btn-padding-y: .3rem;
}

/* ── Eyebrow Labels ───────────────────────────────────────── */
.eyebrow {
  font-size: 10px;
  letter-spacing: 1.8px;
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
}

/* ── Brand Mark ───────────────────────────────────────────── */
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.02;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark .mark-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--lime);
  width: 44px;
  height: 44px;
  border-radius: 13px;
  flex-shrink: 0;
}
.brand-mark .mark-icon svg { width: 28px; height: 28px; }
.brand-mark .brand-sub {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1.3px;
  margin-top: 5px;
}

/* ── Auth Layout ──────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  padding: 40px 16px;
}

.auth-card { width: 100%; max-width: 440px; }
.auth-card .card-body { padding: 36px 40px; }

.auth-brand { text-align: center; margin-bottom: 28px; }

.auth-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.04em;
  margin-bottom: 4px;
}

.auth-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert-brand-error {
  background: #fdf3f3;
  border: 1px solid #e8c4c4;
  color: #7a2a2a;
  border-radius: 6px;
  font-size: 13px;
  padding: 10px 14px;
}
.alert-brand-success {
  background: #f0f8ea;
  border: 1px solid #c5ddb4;
  color: #2f5c1e;
  border-radius: 6px;
  font-size: 13px;
  padding: 10px 14px;
}
/* Neutral, brand-green note: context rather than a problem or a win. */
.alert-brand-info {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 6px;
  font-size: 13px;
  padding: 10px 14px;
}

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

/* ── Utilities ────────────────────────────────────────────── */
.text-muted-brand { color: var(--muted) !important; }
.text-green       { color: var(--green) !important; }
.bg-paper         { background: var(--paper) !important; }
.border-brand     { border-color: var(--line) !important; }

/* ============================================================
   App Shell Layout
   ============================================================ */

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

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sb-width);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .2s ease;
  z-index: 100;
}

.sidebar.collapsed {
  width: var(--sb-collapsed);
}

/* Brand area */
.sidebar-brand {
  padding: 18px 14px 17px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  min-height: var(--hdr-height);
}

/* Override brand-mark colours for dark sidebar */
.sidebar-brand .brand-mark {
  color: #e5ede8;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand .brand-mark .mark-icon {
  background: var(--lime);
  color: var(--ink);
  flex-shrink: 0;
}

/* Hide wordmark when collapsed */
.sidebar.collapsed .sidebar-brand .brand-mark > span:last-child {
  display: none;
}

/* Nav scroll area */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--sb-border) transparent;
}

/* Group headings */
.nav-group-label {
  font-size: 9px;
  letter-spacing: 1.6px;
  font-weight: 700;
  color: var(--sb-muted);
  padding: 16px 20px 5px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}

.sidebar.collapsed .nav-group-label { opacity: 0; height: 0; padding: 0; overflow: hidden; }

/* Admin group toggle button */
.nav-group-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  padding: 16px 20px 5px;
  cursor: pointer;
  font-size: 9px;
  letter-spacing: 1.6px;
  font-weight: 700;
  color: var(--sb-muted);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
}

.nav-group-toggle .toggle-caret {
  margin-left: auto;
  font-size: 11px;
  transition: transform .2s;
}

.nav-group-toggle.is-closed .toggle-caret { transform: rotate(-90deg); }

.sidebar.collapsed .nav-group-toggle { opacity: 0; height: 0; padding: 0; overflow: hidden; }

/* Admin items collapse */
.admin-nav-items {
  overflow: hidden;
  transition: max-height .25s ease;
  max-height: 600px; /* tall enough to fit all items */
}

.admin-nav-items.is-closed { max-height: 0; }
.sidebar.collapsed .admin-nav-items { max-height: 600px !important; }

/* Nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  margin: 1px 8px;
  border-radius: 6px;
  color: var(--sb-text);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: background .15s, color .15s;
  cursor: pointer;
}

.nav-item:hover  { background: var(--sb-hover);  color: #e0ede8; }
.nav-item.active { background: var(--sb-active);  color: #ffffff; }

.nav-item .nav-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  line-height: 1;
}

.nav-item .nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  background: var(--lime);
  color: #183b2d;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1.6;
}

/* Collapsed: center icons, hide text + badges */
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
  margin: 1px 8px;
  gap: 0;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge { display: none; }

/* Nav item dropdown (e.g. Jobs → Work Orders / Projects) */
.nav-dropdown-toggle {
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.nav-dropdown-toggle .toggle-caret {
  margin-left: auto;
  font-size: 11px;
  transition: transform .2s;
  flex-shrink: 0;
}

.nav-dropdown-toggle.is-closed .toggle-caret { transform: rotate(-90deg); }

.nav-subitems {
  overflow: hidden;
  transition: max-height .25s ease;
  max-height: 200px;
}

.nav-subitems.is-closed { max-height: 0; }
.sidebar.collapsed .nav-subitems { max-height: 200px !important; }

.nav-item.nav-subitem { padding-left: 34px; }

/* ── Mobile backdrop ──────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}

.sidebar-backdrop.visible { display: block; }

/* ── App content area ─────────────────────────────────────── */
.app-content {
  margin-left: var(--sb-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left .2s ease;
}

.app-shell.sidebar-collapsed .app-content {
  margin-left: var(--sb-collapsed);
}

/* ── Panel modal (covers header + main, sidebar stays usable) ──── */
.modal-panel {
  left: var(--sb-width);
  width: calc(100% - var(--sb-width));
  transition: left .2s ease, width .2s ease;
}

#app-shell.sidebar-collapsed .modal-panel {
  left: var(--sb-collapsed);
  width: calc(100% - var(--sb-collapsed));
}

.modal-panel .modal-dialog {
  width: 100%;
  max-width: none;
}

.modal-panel .modal-content {
  border-left: 1px solid var(--line);
  box-shadow: -4px 0 24px rgba(0,0,0,.08);
}

@media (max-width: 991px) {
  .modal-panel {
    left: 0 !important;
    width: 100% !important;
  }
}

/* ── App Header ───────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  height: var(--hdr-height);
  background: #fffefb;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 0 16px;
  z-index: 50;
  flex-shrink: 0;
}

.header-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.header-toggle:hover { color: var(--ink); background: #eef1ec; }

/* Search */
.header-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.header-search .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.header-search input {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 12px 7px 34px;
  font-size: 13px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}

.header-search input:focus {
  outline: none;
  border-color: #9a6500;
  box-shadow: 0 0 0 3px rgba(154,101,0,.15);
  background: #fff;
}

.header-search input::placeholder { color: var(--muted); }

/* Global search results dropdown */
.gs-results {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(23,47,45,.12);
  z-index: 200;
  max-height: 460px;
  overflow-y: auto;
  padding: 4px 0;
}
.header-search.open .gs-results { display: block; }

.gs-state {
  padding: 22px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.gs-state i { font-size: 24px; display: block; margin-bottom: 8px; color: var(--line); }

.gs-group-head {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.gs-group-head .bi { font-size: 12px; }

.gs-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  padding: 8px 16px;
  border: 0;
  background: #fff;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}
.gs-item:hover,
.gs-item.active {
  background: var(--paper);
}
.gs-item.active { box-shadow: inset 3px 0 0 var(--green); }

.gs-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-item-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-item-match {
  font-size: 11px;
  color: var(--muted);
}
.gs-item-match b { font-weight: 600; color: var(--ink); }

.gs-results mark {
  background: rgba(154,101,0,.18);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* Right-side actions */
.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.btn-new-request {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 15px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s;
  margin-right: 6px;
}
.btn-new-request:hover { background: #325e4e; color: #fff; }

.submit-new-wrap { position: relative; }
.submit-new-caret { font-size: 10px; opacity: .75; }

.submit-new-dropdown {
  display: none;
  position: absolute;
  right: 6px;
  top: calc(100% + 8px);
  width: 185px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(23,47,45,.1);
  z-index: 200;
  overflow: hidden;
}
.submit-new-dropdown.open { display: block; }

.submit-new-dropdown a {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  transition: background .12s;
}
.submit-new-dropdown a:hover { background: var(--paper); }

.header-icon-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 19px;
  padding: 7px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
  transition: color .15s, background .15s;
}
.header-icon-btn:hover { color: var(--ink); background: #eef1ec; }

/* Notification dropdown */
.notif-wrap { position: relative; }

.notif-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 310px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(23,47,45,.12);
  z-index: 200;
  overflow: hidden;
}
.notif-dropdown.open { display: block; }

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}

.notif-empty {
  padding: 36px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.notif-empty i { font-size: 28px; display: block; margin-bottom: 10px; color: var(--line); }

#notif-toggle { position: relative; }

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #a33c2c;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.notif-mark-all {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.notif-mark-all:hover { text-decoration: underline; }

.notif-list { max-height: 380px; overflow-y: auto; }

.notif-item {
  display: block;
  width: 100%;
  padding: 12px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--paper); }
.notif-item.unread { box-shadow: inset 3px 0 0 var(--green); }
.notif-item.unread .notif-title { font-weight: 600; }

.notif-title { font-size: 13px; color: var(--ink); }
.notif-body {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-time { margin-top: 4px; font-size: 11px; color: var(--muted); }

/* User menu */
.user-menu-wrap { position: relative; }

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  transition: background .15s;
}
.user-menu-btn:hover { background: #eef1ec; }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-info { text-align: left; line-height: 1.25; }
.user-name { font-size: 13px; font-weight: 600; color: var(--ink); display: block; }
.user-role { font-size: 10px; color: var(--muted); text-transform: capitalize; display: block; }

.user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 185px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(23,47,45,.1);
  z-index: 200;
  overflow: hidden;
}
.user-dropdown.open { display: block; }

.user-dropdown a,
.user-dropdown button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background .12s;
}
.user-dropdown a:hover,
.user-dropdown button:hover { background: var(--paper); }

.user-dropdown hr {
  margin: 4px 0;
  border: none;
  border-top: 1px solid var(--line);
}

.user-dropdown .sign-out-btn { color: #7a2a2a; }

/* ── Page content ─────────────────────────────────────────── */
.app-main {
  flex: 1;
  padding: 36px 40px;
}

/* ── Placeholder screens ──────────────────────────────────── */
.placeholder-page { max-width: 600px; }

.placeholder-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f5edcf;
  color: #73561b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 22px;
}

.placeholder-title {
  font-size: clamp(28px, 3vw, 44px);
  font-weight: 500;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin-bottom: 14px;
  line-height: 1.1;
}

.placeholder-desc {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.75;
  max-width: 520px;
  margin: 0;
}

/* ── Page headings ────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.page-title {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.12;
  color: var(--ink);
  margin: 6px 0 8px;
}

.page-desc {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 640px;
  margin: 0;
}

.page-desc code {
  font-size: 12.5px;
  color: var(--green);
  background: #eef1ec;
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── Settings ─────────────────────────────────────────────── */
.settings-loading {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  padding: 24px 0;
}

/* ── Two-column layout ────────────────────────────────────── */
.settings-layout {
  display: flex;
  align-items: flex-start;
  gap: 32px;
}

/* Left nav */
.settings-nav {
  flex: 0 0 200px;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding-bottom: 24px;
}

.setnav-category { margin-bottom: 8px; }

.setnav-cat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 10px 6px;
}

.setnav-sub-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 10px 4px 18px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.setnav-item {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  padding: 6px 10px 6px 18px;
  border-radius: 6px;
  transition: background .12s, color .12s;
  line-height: 1.3;
}

.setnav-item i { color: var(--muted); font-size: 13px; flex-shrink: 0; }
.setnav-item:hover { background: rgba(38,79,68,.07); color: var(--green); text-decoration: none; }
.setnav-item:hover i { color: var(--green); }
.setnav-item.active { background: var(--lime); color: var(--green); font-weight: 600; }
.setnav-item.active i { color: var(--green); }

/* Add-group button in nav */
.setnav-add-group { padding: 16px 10px 4px; }

.setnav-add-group button {
  background: none;
  border: 1px dashed var(--line);
  border-radius: 6px;
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.setnav-add-group button:hover { border-color: var(--green); color: var(--green); }

/* Right content */
.settings-content { flex: 1 1 0; min-width: 0; }

/* Category and subcategory headings in content */
.settings-category-section { margin-bottom: 40px; }

.settings-cat-heading {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.settings-sub-heading {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 24px 0 12px;
}

/* Card header with edit/delete actions */
.settings-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.settings-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-top: 2px;
}

.btn-schema-action {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: background .1s, color .1s;
}
.btn-schema-action:hover { background: #eef1ec; color: var(--ink); }
.btn-delete-group:hover, .btn-field-delete:hover { background: #f5e5e5; color: #7a2a2a; }

/* Per-field edit/delete tools */
.setting-row { position: relative; }

.setting-field-tools {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s;
}

.setting-row:hover .setting-field-tools { opacity: 1; }

.btn-field-edit, .btn-field-delete {
  background: none;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  transition: background .1s, color .1s;
}
.btn-field-edit:hover  { background: #eef1ec; color: var(--ink); }
.btn-field-delete:hover { background: #f5e5e5; color: #7a2a2a; }

/* Add-field row */
.setting-row-add {
  padding: 10px 0 4px;
}

.btn-add-field {
  background: none;
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.btn-add-field:hover { border-color: var(--green); color: var(--green); }

/* Modal form tweaks */
.modal-body .form-label { font-size: 13px; margin-bottom: 4px; }
.modal-body .form-text  { font-size: 11.5px; }
.modal-body .req        { color: #9a3b3b; }
.modal-group-errors:empty, .modal-field-errors:empty { display: none; }

/* ── Icon picker ──────────────────────────────────────────── */
.icon-picker-wrap { position: relative; }

.icon-picker-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0;
  background: #fff;
  border: 1px solid var(--bs-border-color, #dce2d7);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.icon-picker-trigger:focus,
.icon-picker-trigger:hover { border-color: var(--green); outline: none; }
.icon-picker-trigger i:first-child { color: var(--green); font-size: 15px; }
.icon-picker-label { flex: 1; font-size: 12.5px; color: var(--muted); }

.icon-picker-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  z-index: 1070;
  padding: 8px;
}
.icon-picker-dropdown.open { display: block; }

.icon-picker-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 12.5px;
  margin-bottom: 8px;
  outline: none;
  color: var(--ink);
}
.icon-picker-search:focus { border-color: var(--green); }

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 192px;
  overflow-y: auto;
}

.icon-pick-item {
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
  transition: background .1s, border-color .1s, color .1s;
}
.icon-pick-item:hover   { background: #eef1ec; border-color: var(--line); }
.icon-pick-item.selected { background: var(--lime); border-color: var(--green); color: var(--green); }

/* Cards */
.settings-card {
  max-width: 720px;
  margin-bottom: 20px;
}

.settings-card .card-header { padding: 18px 24px; }

.settings-card-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}

.settings-card-title i { color: var(--green); font-size: 15px; }

.settings-card-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
  margin: 8px 0 0;
}

.settings-card .card-body { padding: 8px 24px 20px; }

.setting-row {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: none; padding-bottom: 4px; }

.setting-row .form-label { margin-bottom: 6px; }
.setting-row .form-text  { margin-top: 6px; }

.setting-row .req { color: #9a3b3b; font-weight: 400; }

/* Switch rows read label-first, so no separate .form-label */
.setting-row-switch .form-check { margin: 0; min-height: auto; }

.setting-row-switch .form-check-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.setting-row-switch .form-check-input {
  width: 36px;
  height: 19px;
  margin-top: 1px;
  margin-right: 10px;
  background-color: #e4e8e1;
  border-color: var(--line);
  cursor: pointer;
  box-shadow: none;
}

.setting-row-switch .form-check-input:checked {
  background-color: var(--green);
  border-color: var(--green);
}

.setting-row-switch .form-check-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(38,79,68,.12);
}

.setting-row-switch .form-text { margin-left: 46px; }

/* Secret fields */
.setting-secret { position: relative; }

.setting-secret .form-control { padding-right: 42px; }

.btn-reveal {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 32px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  border-radius: 5px;
  cursor: pointer;
}
.btn-reveal:hover { color: var(--ink); background: #eef1ec; }

.setting-secret-state {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.btn-clear-secret {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  color: #7a2a2a;
  cursor: pointer;
}
.btn-clear-secret:hover { text-decoration: underline; }

/* Field-level errors */
.setting-field-error {
  font-size: 12px;
  color: #9a3b3b;
  margin-top: 6px;
}
.setting-field-error:empty { display: none; }

.setting-input.is-invalid {
  border-color: #c27676;
  background-image: none;
}
.setting-input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(154,59,59,.1); }

/* Card footer */
.settings-card-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  border-radius: 0 0 10px 10px;
}

.settings-saved-note { font-size: 12px; color: var(--muted); }

.settings-meta {
  font-size: 12px;
  color: var(--muted);
  max-width: 720px;
  margin: 0;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sb-width) !important; /* never icon-only on mobile */
    transition: transform .25s ease;
  }

  .sidebar.mobile-open { transform: translateX(0); }

  .app-content {
    margin-left: 0 !important;
  }

  .app-main { padding: 24px 20px; }
}

@media (max-width: 575px) {
  .header-search { display: none; }
  .btn-new-request .btn-label { display: none; }
  .user-info { display: none; }
  .app-main { padding: 20px 16px; }
}

/* ── Help / Support modal ─────────────────────────────────── */
.support-ticket-list {
  max-height: 50vh;
  overflow-y: auto;
}

.support-ticket-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--bs-border-radius);
  margin-bottom: 10px;
  background: #fff;
}

.support-ticket-number {
  font-family: var(--bs-font-monospace, monospace);
  letter-spacing: .02em;
}

.support-ticket-title {
  font-weight: 600;
  color: var(--ink);
}

.support-ticket-desc {
  white-space: pre-wrap;
}

.support-ticket-response {
  padding: 8px 10px;
  border-left: 3px solid var(--bs-success);
  background: var(--bs-success-bg-subtle, #eafaf1);
  border-radius: var(--bs-border-radius);
}

.support-ticket-response-label {
  font-weight: 600;
}

.support-ticket-response-body {
  white-space: pre-wrap;
}

/* ── Support request dashboard ────────────────────────────── */
.support-stat {
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}

.support-stat:hover,
.support-stat:focus-visible {
  border-color: var(--green);
  transform: translateY(-2px);
}

.support-stat.active {
  border-color: var(--green);
  background: var(--lime);
}

.support-stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.support-stat-value {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.045em;
  color: var(--ink);
}

#support-dash-table tbody tr { cursor: pointer; }

.support-env-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #73561b;
  background: #f5edcf;
  padding: 1px 6px;
  border-radius: 4px;
}

.support-detail-desc {
  white-space: pre-wrap;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--bs-border-radius);
  background: #fffefb;
}

.support-note {
  padding: 10px 12px;
  border-left: 3px solid var(--line);
  margin-bottom: 8px;
}

.support-note-meta {
  font-size: 12px;
  color: var(--muted);
}

.support-note-body { white-space: pre-wrap; }

.support-note-reply {
  border-left-color: var(--accent, #0d6efd);
  background: rgba(13,110,253,.04);
}

/* ── Help modal chat view ─────────────────────────────────── */
.support-modal-chat-header {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 5;
}

.support-conversation {
  max-height: 340px;
  overflow-y: auto;
}

.support-modal-chat-footer {
  border-top: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  bottom: 0;
  z-index: 5;
}

.support-msg {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}
.support-msg-staff { align-items: flex-start; }
.support-msg-user  { align-items: flex-end; }

.support-msg-bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.45;
}
.support-msg-staff .support-msg-bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.support-msg-user .support-msg-bubble {
  background: var(--accent, #0d6efd);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.support-msg-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── AI agent modal ───────────────────────────────────────── */
.ai-agent-dialog { max-width: 900px; }
.ai-agent-content { height: 70vh; }

.ai-agent-body {
  display: flex;
  padding: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.ai-agent-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  padding: 14px;
  overflow-y: auto;
}

.ai-agent-chat-list { display: flex; flex-direction: column; gap: 4px; }

.ai-agent-chat-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
}
.ai-agent-chat-item:hover { background: #eef1ec; }
.ai-agent-chat-item.active { background: var(--lime); font-weight: 600; }
.ai-agent-chat-item .ai-agent-chat-type {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 600;
}

.ai-agent-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ai-agent-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-agent-placeholder {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 320px;
  font-size: 13px;
}
.ai-agent-placeholder i { font-size: 32px; display: block; margin-bottom: 10px; color: var(--line); }

.ai-agent-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  white-space: pre-wrap;
  line-height: 1.45;
}
.ai-agent-msg-user {
  align-self: flex-end;
  background: var(--green);
  color: #fff;
}
.ai-agent-msg-assistant {
  align-self: flex-start;
  background: #f1f3ee;
  color: var(--ink);
  max-width: 95%;
}
.ai-agent-msg-assistant p { margin: 0 0 8px; }
.ai-agent-msg-assistant p:last-child { margin-bottom: 0; }
.ai-agent-msg-pending { opacity: .6; }

.ai-agent-table-wrap {
  overflow-x: auto;
  white-space: normal;
  margin: 4px 0;
}
.ai-agent-table-wrap:last-child { margin-bottom: 0; }

.ai-agent-table {
  border-collapse: collapse;
  font-size: 12.5px;
  width: 100%;
}
.ai-agent-table th, .ai-agent-table td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
  white-space: nowrap;
}
.ai-agent-table th {
  background: #e4e9de;
  font-weight: 600;
  color: var(--ink);
}
.ai-agent-table tbody tr:nth-child(even) { background: #fafbf8; }

.ai-agent-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.ai-agent-input-row .form-control { flex: 1; }

.ai-agent-type-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ai-agent-type-card:hover { border-color: var(--green); background: #f8faf7; }
.ai-agent-type-card i { font-size: 22px; color: var(--green); }
.ai-agent-type-card span { display: flex; flex-direction: column; }
.ai-agent-type-card small { color: var(--muted); }

/* ============================================================
   Admin → Phase 1 Tasks
   ============================================================ */

.p1t-progress-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffefb;
  padding: 18px 22px;
  margin-bottom: 24px;
}

.p1t-progress-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 10px;
}

.p1t-progress-label .text-muted-brand {
  font-weight: 500;
  margin-left: 4px;
}

.p1t-progress-track {
  height: 8px;
  border-radius: 20px;
  background: var(--line);
  overflow: hidden;
}

.p1t-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 20px;
  transition: width .25s ease;
}

.p1t-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffefb;
  margin-bottom: 18px;
  overflow: hidden;
}

.p1t-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}

.p1t-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.p1t-section-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.p1t-section-count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.p1t-section-caret {
  transition: transform .15s ease;
  color: var(--muted);
}

.p1t-section.collapsed .p1t-section-caret { transform: rotate(-90deg); }
.p1t-section.collapsed .p1t-section-body { display: none; }

.p1t-section-body { padding: 6px 20px 14px; }

.p1t-subsection-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 16px 0 6px;
}

.p1t-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}
.p1t-item:last-child { border-bottom: none; }

.p1t-item-check {
  margin-top: 3px;
  flex-shrink: 0;
}

.p1t-item-body {
  flex: 1 1 auto;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
  cursor: text;
  outline: none;
  word-break: break-word;
}

.p1t-item.is-done .p1t-item-body {
  color: var(--muted);
  text-decoration: line-through;
}

.p1t-item-body:focus {
  background: #fff;
  box-shadow: 0 0 0 2px rgba(38,79,68,.15);
  border-radius: 4px;
  padding: 1px 4px;
  margin: -1px -4px;
}

.p1t-item-delete {
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--muted);
  opacity: 0;
  padding: 2px 4px;
  transition: opacity .1s ease;
}

.p1t-item:hover .p1t-item-delete { opacity: 1; }
.p1t-item-delete:hover { color: #a23b3b; }

.p1t-add-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.p1t-add-row input {
  flex: 1 1 auto;
}

/* ══════════════════════════════════════════════════════════
   Audit log

   Shell comes from .card + Bootstrap's .table, matching the work orders,
   intake queue and properties pages. Only what Bootstrap has no equivalent
   for lives here.
   ══════════════════════════════════════════════════════════ */

/* Failed actions are tinted so they stand out when scanning. */
.al-row-failure > td { background: #fdf6f6; }

.al-when  { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 12px; }
.al-actor-name  { font-weight: 600; }
.al-actor-email { color: var(--muted); font-size: 12px; display: block; }
.al-actor-none  { color: var(--muted); font-style: italic; }
.al-action {
  background: #eef2ea;
  border-radius: 4px;
  color: var(--green);
  font-size: 12px;
  padding: 2px 6px;
  white-space: nowrap;
}
.al-record, .al-ip { color: var(--muted); font-size: 12px; white-space: nowrap; }

.al-toggle {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}
.al-toggle:hover { color: var(--ink); }

/* Expandable before/after panel. No Bootstrap equivalent. */
.al-detail-cell { background: #f7f9f4; }
.al-detail-grid {
  display: grid;
  grid-template-columns: 170px 1fr 1fr;
  gap: 4px 14px;
  font-size: 12px;
}
.al-detail-head {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding-bottom: 4px;
}
.al-detail-field { font-weight: 600; }
.al-detail-from  { color: #8a2f2f; word-break: break-word; }
.al-detail-to    { color: #426239; word-break: break-word; }
.al-detail-plain { word-break: break-word; }
.al-detail-ua    { color: var(--muted); font-size: 12px; margin-top: 10px; word-break: break-all; }
.al-detail-none  { color: var(--muted); font-style: italic; font-size: 12px; }

@media (max-width: 900px) {
  .al-table-wrap .card-body { overflow-x: auto; }
  #al-table { min-width: 900px; }
}

/* ── System Inbox ─────────────────────────────────────────── */

.ib-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.ib-list-pane {
  flex: 0 0 380px;
  max-height: 75vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ib-reading-pane {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 75vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 20px;
}

.ib-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.ib-row:hover      { background: #f7f9f4; }
.ib-row-active     { background: var(--lime); }
.ib-row-new        { font-weight: 600; }

.ib-row-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}
.ib-row-when    { color: var(--muted); white-space: nowrap; font-weight: 400; font-size: 12px; }
.ib-row-subject { font-size: 13px; margin-top: 2px; }
.ib-row-to      { color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; }

.ib-r-meta      { color: var(--muted); font-size: 13px; line-height: 1.5; }
.ib-r-meta strong { color: var(--ink); }

.ib-r-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.ib-att-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  background: #f7f9f4;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
}
.ib-att-download        { cursor: pointer; color: var(--green); }
.ib-att-download:hover   { background: var(--lime); }
.ib-att-download:disabled { opacity: 0.6; cursor: default; }
.ib-att-pending   { font-style: italic; }
.ib-att-blocked   { color: #8a2f2f; background: #fdf6f6; border-color: #f0d6d6; }
.ib-att-unstored  { font-style: italic; }

.ib-r-text   { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 14px; }
.ib-r-iframe { width: 100%; height: 55vh; border: 0; }

@media (max-width: 900px) {
  .ib-layout { flex-direction: column; }
  .ib-list-pane, .ib-reading-pane { flex: 1 1 auto; width: 100%; max-height: 50vh; }
}

/* ── Routing Rules (rule builder) ─────────────────────────── */

.rr-row {
  background: #f7f9f4;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.rr-test-panel {
  background: #f7f9f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.rr-test-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  min-height: 32px;
}

/* ── Standard report cards ────────────────────────────────── */
.report-tile .card-body { display: flex; flex-direction: column; }

.report-tile .eyebrow { display: block; margin-bottom: 4px; }

.report-tile-desc {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.report-tile-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.report-tile-metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fffefb;
}

.report-tile-metric-value {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.045em;
  color: var(--ink);
  word-break: break-word;
}

.report-tile-metric-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}

.report-tile-metric-detail {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.report-tile-rows { border-top: 1px solid var(--line); padding-top: 10px; }

.report-tile-rows-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.report-tile-row { padding: 6px 0; border-bottom: 1px solid var(--line); }
.report-tile-row:last-of-type { border-bottom: 0; }

.report-tile-row-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.report-tile-row-label { font-weight: 600; word-break: break-word; }
.report-tile-row-value { white-space: nowrap; }

.report-tile-row-detail {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.report-tile-empty, .report-tile-unavailable {
  color: var(--muted);
  font-size: 13px;
}

.report-tile-foot {
  color: var(--muted);
  font-size: 12px;
  margin: 14px 0 0;
}

.report-tile-link { align-self: flex-start; margin-top: 12px; }

.report-tile-off { background: var(--paper); }

@media (max-width: 575px) {
  .report-tile-metrics { grid-template-columns: minmax(0, 1fr); }
}

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar { margin-bottom: 8px; }

.filter-bar-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}

.filter-bar-spacer { flex: 1; min-width: 8px; }

.filter-bar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.fqt-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.fqt-tab {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--line, var(--bs-border-color));
  background: var(--paper, white);
  color: var(--ink, inherit);
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  line-height: 1.6;
}

.fqt-tab:hover { background: var(--muted, #f0f0f0); }

.fqt-active {
  background: var(--ink, #333);
  color: var(--paper, white);
  border-color: var(--ink, #333);
}

.filter-btn {
  padding: 4px 10px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--line, var(--bs-border-color));
  border-radius: 6px;
  background: var(--paper, white);
  color: var(--ink, inherit);
  cursor: pointer;
  white-space: nowrap;
}

.filter-btn:hover { background: var(--muted, #f0f0f0); }
.filter-btn-clear { color: var(--muted-fg, var(--bs-secondary-color, #888)); }

.filter-panel {
  border: 1px solid var(--line, var(--bs-border-color));
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 4px;
  background: var(--card, white);
}

.filter-panel-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: flex-start;
}

.tf-field-row { flex: 1 1 220px; min-width: 200px; max-width: 380px; }
.tf-field-row--wide { flex: 0 0 100%; max-width: 100%; }

/* Select dropdown */
.tf-select-wrap { position: relative; }

.tf-select-toggle {
  width: 100%;
  text-align: left;
  padding: 5px 10px;
  font-size: 13px;
  border: 1px solid var(--line, var(--bs-border-color));
  border-radius: 6px;
  background: var(--paper, white);
  color: var(--ink, inherit);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tf-select-toggle:hover { background: var(--muted, #f0f0f0); }

.tf-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  min-width: 200px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line, var(--bs-border-color));
  border-radius: 6px;
  background: var(--card, white);
  z-index: 200;
  padding: 4px 0;
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
}

.tf-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.tf-check-row:hover { background: var(--muted, #f5f5f5); }

/* Range inputs */
.tf-range-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
}

.tf-range-label {
  font-size: 12px;
  color: var(--muted-fg, var(--bs-secondary-color, #888));
  white-space: nowrap;
  margin-right: 2px;
}

.tf-affix {
  font-size: 13px;
  color: var(--muted-fg, var(--bs-secondary-color, #888));
}

.tf-num {
  flex: 1 1 55px;
  min-width: 55px;
  max-width: 110px;
  padding: 4px 6px;
  font-size: 13px;
  border: 1px solid var(--line, var(--bs-border-color));
  border-radius: 6px;
  background: var(--paper, white);
  color: var(--ink, inherit);
}

.tf-date {
  flex: 1 1 100px;
  min-width: 100px;
  max-width: 140px;
  padding: 4px 6px;
  font-size: 13px;
  border: 1px solid var(--line, var(--bs-border-color));
  border-radius: 6px;
  background: var(--paper, white);
  color: var(--ink, inherit);
}

.tf-range-sep {
  font-size: 13px;
  color: var(--muted-fg, var(--bs-secondary-color, #888));
}

/* Boolean */
.tf-bool {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  padding: 5px 2px;
  user-select: none;
}

/* Filter chips */
.filter-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0 4px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 10px;
  font-size: 12px;
  border-radius: 20px;
  background: var(--muted, #f0f0f0);
  color: var(--ink, inherit);
  border: 1px solid var(--line, var(--bs-border-color));
  white-space: nowrap;
}

.filter-chip-x {
  cursor: pointer;
  opacity: 0.55;
  font-size: 15px;
  line-height: 1;
  padding: 0 1px;
}

.filter-chip-x:hover { opacity: 1; }

/* Saved views */
.filter-views-wrap { position: relative; }

.filter-views-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  right: 0;
  min-width: 230px;
  border: 1px solid var(--line, var(--bs-border-color));
  border-radius: 8px;
  background: var(--card, white);
  z-index: 210;
  padding: 6px 0;
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
}

.filter-view-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  font-size: 13px;
  gap: 8px;
}

.filter-view-item:hover { background: var(--muted, #f5f5f5); }

.filter-view-name {
  flex: 1;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-view-del {
  opacity: 0.4;
  font-size: 17px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  flex-shrink: 0;
}

.filter-view-del:hover { opacity: 1; }

.filter-views-sep {
  height: 1px;
  background: var(--line, var(--bs-border-color));
  margin: 4px 0;
}

.filter-view-save {
  display: flex;
  gap: 6px;
  padding: 6px 12px 4px;
}

.tf-view-name {
  flex: 1;
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid var(--line, var(--bs-border-color));
  border-radius: 6px;
  background: var(--paper, white);
  color: var(--ink, inherit);
}

/* Table toolbar (count + search, inside a card above its table) */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line, var(--bs-border-color));
}

@media (max-width: 575px) {
  .fqt-tab   { padding: 3px 10px; font-size: 12px; }
  .filter-btn { padding: 3px 8px; font-size: 12px; }
  .tf-field-row { max-width: 100%; }
}

/* ── Skeleton loading placeholders ─────────────────────────────
   Shared shimmer utility for any page that renders its layout before
   async data arrives. Give an element class="skel" plus a size (width/
   height, or a modifier below) while its real content is loading, then
   remove the class (or hide it) once data is in. */
@keyframes skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel {
  display: inline-block;
  border-radius: 6px;
  background: linear-gradient(100deg, #eceee8 30%, #f6f7f3 50%, #eceee8 70%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  color: transparent !important;
  vertical-align: middle;
}
.skel-text   { height: 0.9em; width: 100%; border-radius: 4px; }
.skel-title  { height: 36px; width: 70px; border-radius: 6px; }
.skel-chip   { height: 20px; width: 72px; border-radius: 20px; }
.skel-bar    { width: 100%; border-radius: 6px 6px 0 0; }

/* A skeleton row/card has no real text to size against, so give its
   shimmer bars a little breathing room. */
.skel-row td { padding-top: 14px; padding-bottom: 14px; }
.skel-card {
  padding: 12px 14px;
  border: 1px solid var(--line, var(--bs-border-color));
  border-radius: var(--bs-border-radius, 8px);
  margin-bottom: 10px;
  background: #fff;
}
.skel-card .skel { display: block; }

@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; }
}

/* ── Page-load entrance animation ──────────────────────────────
   Give a top-level block class="anim-rise" (plus anim-d1..anim-d6 for a
   stagger) so the page's shape visibly settles in as soon as it renders,
   whether or not its content is still loading. */
@keyframes appRiseIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim-rise {
  opacity: 0;
  animation: appRiseIn 0.45s ease-out forwards;
}
.anim-d1 { animation-delay: 60ms; }
.anim-d2 { animation-delay: 120ms; }
.anim-d3 { animation-delay: 180ms; }
.anim-d4 { animation-delay: 240ms; }
.anim-d5 { animation-delay: 300ms; }
.anim-d6 { animation-delay: 360ms; }

/* Fade-in for content swapped into a loading placeholder once data
   arrives (table rows, list rows, cards, tiles) -- add class="anim-fade"
   to each newly-rendered element. */
@keyframes appFadeIn { from { opacity: 0; } to { opacity: 1; } }
.anim-fade { animation: appFadeIn 0.25s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .anim-rise { animation: none; opacity: 1; }
  .anim-fade { animation: none; }
}
