/* ==========================================================================
   Pest Control CRM - Admin Panel
   Stylesheet: design tokens, layout shell, components
   Palette taken from the project design brief (Part 5 - Visual Direction)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* Brand palette - exact values from the design brief */
  --deep-space: #080C16;
  --navy: #0F1624;
  --ink-card: #141E30;
  --gold: #C8A86B;
  --champagne: #E8D5A3;
  --frost: #F0F4FF;
  --slate-mist: #8895AA;
  --signal-green: #22C55E;

  /* Gold darkened for use as text on light surfaces (AA contrast) */
  --gold-deep: #8A6A28;
  --gold-tint: #FBF4E6;

  /* Neutral surfaces */
  --bg: #F4F6FB;
  --surface: #FFFFFF;
  --surface-2: #F8FAFD;
  --line: #E3E8F0;
  --line-soft: #EEF1F7;

  /* Text */
  --ink: #12161F;
  --ink-2: #3B4453;
  --ink-3: #6B7688;
  --ink-4: #96A0B0;

  /* Semantic status colours */
  --green: #1B7F4C;
  --green-bg: #E8F6EE;
  --blue: #1F5FAF;
  --blue-bg: #E9F1FB;
  --amber: #8A5A00;
  --amber-bg: #FCF2DD;
  --purple: #5B3FA8;
  --purple-bg: #F0EBFB;
  --red: #A3282B;
  --red-bg: #FBECEC;
  --grey: #5A6474;
  --grey-bg: #EEF1F6;

  /* Metrics */
  --sidebar-w: 256px;
  --header-h: 62px;
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 2px 10px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 34px rgba(8, 12, 22, .14);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: var(--blue); }
a:hover { color: #17457F; }

h1, h2, h3, h4, h5, h6 { color: var(--ink); font-weight: 700; letter-spacing: -.2px; }

.text-muted-2 { color: var(--ink-3) !important; }
.text-muted-3 { color: var(--ink-4) !important; }
.mono { font-family: var(--mono); }
.fs-13 { font-size: 13px; }
.fs-12 { font-size: 12px; }
.fs-11 { font-size: 11px; }
.fw-600 { font-weight: 600; }
.lh-tight { line-height: 1.3; }

.section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 8px;
}

/* Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C9D1DE; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #AEB9CA; }

/* --------------------------------------------------------------------------
   3. Login screen (index.html)
   -------------------------------------------------------------------------- */
/* A single centred card on a navy ground. No marketing panel: this is an
   internal tool and the person signing in already knows what it is. */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  background: var(--navy);
  background-image:
    radial-gradient(circle at 18% 12%, rgba(200, 168, 107, .13) 0%, rgba(200, 168, 107, 0) 42%),
    radial-gradient(circle at 84% 88%, rgba(31, 95, 175, .16) 0%, rgba(31, 95, 175, 0) 46%);
}

.auth-box { width: 100%; max-width: 428px; }

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-bottom: 20px;
}

.auth-brand .brand-name { font-size: 16px; }
.auth-brand .brand-sub { font-size: 10px; }

.auth-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius-lg);
  box-shadow: 0 26px 64px rgba(4, 7, 14, .42);
  padding: 32px 34px 28px;
}

.auth-card h1 { font-size: 22px; margin: 0 0 4px; }
.auth-card .sub { color: var(--ink-3); font-size: 13.6px; margin-bottom: 24px; }

.auth-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  background: var(--gold-tint);
  color: var(--gold-deep);
  margin-bottom: 14px;
}

.auth-icon.green { background: var(--green-bg); color: var(--green); }

.auth-foot {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12.6px;
  color: var(--ink-3);
  text-align: center;
}

.auth-legal {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
  color: #7C8AA3;
}

.auth-legal a { color: #A9B6CA; }
.auth-legal a:hover { color: #FFFFFF; }

/* Live password requirement checklist */
.pw-rules { list-style: none; padding: 0; margin: 8px 0 0; }
.pw-rules li { display: flex; align-items: center; gap: 7px; font-size: 12.2px; color: var(--ink-3); padding: 2px 0; }
.pw-rules li i { font-size: 13px; color: var(--ink-4); }
.pw-rules li.met { color: var(--green); }
.pw-rules li.met i { color: var(--green); }

.role-switch {
  display: flex;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 22px;
}

.role-switch button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
}

.role-switch button.active { background: var(--navy); color: #FFFFFF; }

/* --------------------------------------------------------------------------
   4. Brand mark (neutral placeholder - final brand name is pending)
   -------------------------------------------------------------------------- */
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--gold);
  color: var(--navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -.5px;
  flex: 0 0 auto;
}

.brand-mark.sm { width: 28px; height: 28px; font-size: 13px; border-radius: 8px; }
.brand-name { font-weight: 700; font-size: 14.5px; color: #FFFFFF; line-height: 1.2; }
.brand-sub { font-size: 10.5px; letter-spacing: .9px; text-transform: uppercase; color: var(--slate-mist); }

/* --------------------------------------------------------------------------
   5. App shell - sidebar
   -------------------------------------------------------------------------- */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform .22s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  min-height: var(--header-h);
}

.sidebar-company { padding: 13px 18px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.sidebar-company .co-name { color: #E7ECF5; font-size: 13px; font-weight: 600; }

.company-id-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--champagne);
  background: rgba(200, 168, 107, .12);
  border: 1px solid rgba(200, 168, 107, .3);
  padding: 2px 8px;
  border-radius: 20px;
  cursor: pointer;
}

.company-id-chip:hover { background: rgba(200, 168, 107, .2); color: var(--champagne); }

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 10px 0 18px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); }

.nav-group-title {
  padding: 14px 20px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #64738C;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8.5px 20px;
  color: #AEBACB;
  font-size: 13.4px;
  font-weight: 500;
  border-left: 3px solid transparent;
  border-radius: 0;
}

.sidebar-nav .nav-link i { font-size: 15.5px; width: 19px; text-align: center; color: #7C8AA3; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .05); color: #FFFFFF; }
.sidebar-nav .nav-link:hover i { color: var(--gold); }

.sidebar-nav .nav-link.active {
  background: rgba(200, 168, 107, .1);
  border-left-color: var(--gold);
  color: #FFFFFF;
  font-weight: 600;
}

.sidebar-nav .nav-link.active i { color: var(--gold); }
.sidebar-nav .nav-link .badge { margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 3px 7px; }

.sidebar-backdrop { position: fixed; inset: 0; background: rgba(8, 12, 22, .5); z-index: 1035; display: none; }
.sidebar-backdrop.show { display: block; }

/* --------------------------------------------------------------------------
   5b. Collapsed sidebar (desktop only)
   The rail keeps the icons and turns the group titles into dividers. Labels
   are hidden with font-size rather than display, because they are bare text
   nodes inside the links; hover titles are added by script.js.
   -------------------------------------------------------------------------- */
@media (min-width: 992px) {
  .sidebar-collapsed { --sidebar-w: 76px; }

  .app-sidebar,
  .app-main { transition: width .2s ease, margin-left .2s ease; }

  .sidebar-collapsed .sidebar-brand { justify-content: center; padding: 14px 0; }
  .sidebar-collapsed .sidebar-brand > span:last-child { display: none; }
  .sidebar-collapsed .sidebar-company { display: none; }

  .sidebar-collapsed .nav-group-title {
    font-size: 0;
    padding: 0;
    margin: 14px 18px 8px;
    height: 1px;
    background: rgba(255, 255, 255, .1);
  }

  .sidebar-collapsed .sidebar-nav .nav-link {
    font-size: 0;
    gap: 0;
    justify-content: center;
    padding: 10px 0;
    border-left-width: 0;
    border-right: 3px solid transparent;
  }

  .sidebar-collapsed .sidebar-nav .nav-link i { font-size: 17px; width: auto; }
  .sidebar-collapsed .sidebar-nav .nav-link .badge { display: none; }
  .sidebar-collapsed .sidebar-nav .nav-link.active { border-right-color: var(--gold); }
}

/* --------------------------------------------------------------------------
   6. App shell - header, content, footer
   -------------------------------------------------------------------------- */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
}

.sidebar-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}

.page-heading { min-width: 0; }
.page-heading h1 { font-size: 17px; margin: 0; line-height: 1.25; }
.page-heading .crumb { font-size: 11.5px; color: var(--ink-4); }

.header-search { position: relative; width: 300px; }
.header-search .bi-search { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-4); font-size: 14px; }
.header-search .form-control { padding-left: 34px; background: var(--surface-2); border-color: var(--line); height: 38px; font-size: 13px; }
.header-search .form-control:focus { background: var(--surface); }

.header-search-results {
  position: absolute;
  top: 44px;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  max-height: 340px;
  overflow-y: auto;
  z-index: 20;
}

.header-search-results.show { display: block; }
.header-search-results .res-group { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-4); padding: 8px 10px 4px; font-weight: 700; }
.header-search-results a.res-item { display: flex; justify-content: space-between; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--ink-2); font-size: 13px; }
.header-search-results a.res-item:hover { background: var(--surface-2); color: var(--ink); }
.header-search-results .res-empty { padding: 16px 10px; text-align: center; color: var(--ink-4); font-size: 13px; }

.icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* Desktop-only collapse control; the drawer toggle takes over below 992px */
.sidebar-collapse-btn { display: inline-flex; }

.icon-btn .dot {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--surface);
}

/* Just the avatar and a chevron - the name and role live in the dropdown */
.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  border-radius: 30px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.user-chip:hover { background: var(--surface-2); }

.dropdown-user {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 16px 10px;
  min-width: 240px;
}

.dropdown-user .du-text { min-width: 0; }
.dropdown-user .du-name { display: block; font-size: 13.6px; font-weight: 700; color: var(--ink); line-height: 1.25; }
.dropdown-user .du-role { display: block; font-size: 11.5px; color: var(--gold-deep); font-weight: 600; }
.dropdown-user .du-mail { display: block; font-size: 11.5px; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink-card);
  color: var(--champagne);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
}

.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.lg { width: 46px; height: 46px; font-size: 16px; }
.avatar.xl { width: 68px; height: 68px; font-size: 22px; }
.avatar.blue { background: var(--blue-bg); color: var(--blue); }
.avatar.green { background: var(--green-bg); color: var(--green); }
.avatar.amber { background: var(--amber-bg); color: var(--amber); }
.avatar.purple { background: var(--purple-bg); color: var(--purple); }
.avatar.red { background: var(--red-bg); color: var(--red); }

.app-content { flex: 1 1 auto; padding: 22px; }

.app-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 13px 22px;
  font-size: 12.2px;
  color: var(--ink-4);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  justify-content: space-between;
}

.app-footer a { color: var(--ink-3); }
.app-footer a:hover { color: var(--ink); }

/* Notification dropdown */
.notif-dropdown { width: 366px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.notif-head { padding: 12px 15px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.notif-head h6 { margin: 0; font-size: 13.5px; }
.notif-list { max-height: 336px; overflow-y: auto; }
.notif-item { display: flex; gap: 11px; padding: 11px 15px; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); }
.notif-item:hover { background: var(--surface-2); color: var(--ink-2); }
.notif-item.unread { background: #F7FAFF; }
.notif-item.unread:hover { background: #EFF5FF; }
.notif-item .n-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.notif-item .n-text { font-size: 12.3px; color: var(--ink-3); }
.notif-item .n-time { font-size: 11px; color: var(--ink-4); margin-top: 3px; }
.notif-foot { padding: 9px 15px; text-align: center; font-size: 12.5px; }

.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex: 0 0 auto;
}

.notif-icon.blue { background: var(--blue-bg); color: var(--blue); }
.notif-icon.green { background: var(--green-bg); color: var(--green); }
.notif-icon.amber { background: var(--amber-bg); color: var(--amber); }
.notif-icon.red { background: var(--red-bg); color: var(--red); }
.notif-icon.purple { background: var(--purple-bg); color: var(--purple); }
.notif-icon.gold { background: var(--gold-tint); color: var(--gold-deep); }

/* --------------------------------------------------------------------------
   7. Cards
   -------------------------------------------------------------------------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }

.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}

.card-header h2, .card-header h3, .card-header h5, .card-header h6 { margin: 0; font-size: 14.5px; font-weight: 700; }
.card-header .sub { font-size: 12px; color: var(--ink-3); margin: 1px 0 0; }
.card-body { padding: 18px; }
.card-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 11px 18px; }
.card-header.no-border { border-bottom: 0; padding-bottom: 0; }

/* Stat cards */
.stat-card { position: relative; overflow: hidden; height: 100%; }
.stat-card .card-body { padding: 16px 17px; }
.stat-card .stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.stat-card .stat-label { font-size: 11.5px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--ink-3); }
.stat-card .stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.7px; margin-top: 6px; line-height: 1.1; }
.stat-card .stat-foot { font-size: 12px; color: var(--ink-3); margin-top: 7px; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex: 0 0 auto;
}

.stat-icon.navy { background: var(--navy); color: var(--gold); }
.stat-icon.blue { background: var(--blue-bg); color: var(--blue); }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.amber { background: var(--amber-bg); color: var(--amber); }
.stat-icon.red { background: var(--red-bg); color: var(--red); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }
.stat-icon.gold { background: var(--gold-tint); color: var(--gold-deep); }

.trend { font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.trend.up { color: var(--green); }
.trend.down { color: var(--red); }
.trend.flat { color: var(--ink-3); }

/* Attention list */
.attn-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line-soft); }
.attn-item:last-child { border-bottom: 0; }
.attn-item .a-title { font-size: 13.4px; font-weight: 600; }
.attn-item .a-sub { font-size: 12px; color: var(--ink-3); }

/* Key / value detail list */
.kv-list { margin: 0; }
.kv-list dt { font-size: 12px; color: var(--ink-3); font-weight: 500; padding: 7px 0 0; }
.kv-list dd { font-size: 13.4px; color: var(--ink); font-weight: 600; margin: 0 0 7px; padding-bottom: 7px; border-bottom: 1px solid var(--line-soft); }
.kv-list dd:last-child { border-bottom: 0; }

/* Record detail pages (owner / technician / customer) */
.detail-hero { margin-bottom: 16px; overflow: hidden; }
.detail-hero::before { content: ""; display: block; height: 4px; background: linear-gradient(90deg, var(--navy), var(--gold)); }
.detail-hero .card-body { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.detail-hero .dh-logo { width: 68px; height: 68px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); object-fit: contain; padding: 4px; flex: 0 0 auto; }
.detail-hero .dh-main { flex: 1 1 260px; min-width: 0; }
.detail-hero .dh-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; font-size: 19px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.detail-hero .dh-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-3); }
.detail-hero .dh-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 9px; font-size: 12.5px; color: var(--ink-2); }
.detail-hero .dh-meta span { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.detail-hero .dh-meta i { color: var(--ink-4); font-size: 14px; }
.detail-hero .dh-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.detail-card { height: 100%; }
.detail-card .card-header > i { color: var(--gold-deep); font-size: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.detail-item { display: flex; gap: 11px; align-items: flex-start; min-width: 0; padding: 11px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); background: var(--surface-2); }
.detail-item.wide { grid-column: 1 / -1; }
.detail-item .di-icon { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); color: var(--gold-deep); display: inline-flex; align-items: center; justify-content: center; font-size: 15px; flex: 0 0 auto; }
.detail-item .di-body { min-width: 0; }
.detail-item .di-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-3); }
.detail-item .di-value { display: block; margin-top: 2px; font-size: 13.6px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; white-space: pre-line; }
.detail-item a.di-value { color: var(--blue); text-decoration: none; }
.detail-item a.di-value:hover { text-decoration: underline; }
.detail-item .di-value.is-empty { color: var(--ink-4); font-weight: 500; }

@media (max-width: 575.98px) {
  .detail-hero .dh-actions { margin-left: 0; width: 100%; }
  .detail-hero .dh-actions .btn { flex: 1 1 0; justify-content: center; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   8. Tables
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }

.table { margin: 0; font-size: 13.4px; color: var(--ink-2); border-color: var(--line-soft); }

.table > thead > tr > th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 10.8px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  padding: 10px 14px;
  white-space: nowrap;
  vertical-align: middle;
}

.table > tbody > tr > td { padding: 12px 14px; vertical-align: middle; border-color: var(--line-soft); }
.table > tbody > tr:hover > td { background: #FBFCFE; }
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table .t-primary { font-weight: 600; color: var(--ink); }
.table .t-sub { font-size: 11.8px; color: var(--ink-4); }
.table .t-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.col-actions, .table th.col-actions { text-align: right; white-space: nowrap; }

.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table th.sortable::after { content: "\F282"; font-family: "bootstrap-icons"; font-size: 9px; margin-left: 5px; opacity: .35; }
.table th.sortable.asc::after { content: "\F235"; opacity: .9; }
.table th.sortable.desc::after { content: "\F229"; opacity: .9; }

.row-flag td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.row-flag-amber td:first-child { box-shadow: inset 3px 0 0 var(--amber); }

.cell-user { display: flex; align-items: center; gap: 10px; }
.empty-row td { padding: 46px 14px !important; text-align: center; color: var(--ink-4); }

/* Table toolbar */
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.table-toolbar .search-box { position: relative; flex: 1 1 220px; max-width: 320px; }
.table-toolbar .search-box .bi-search { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-4); font-size: 13px; }
.table-toolbar .search-box .form-control { padding-left: 32px; }
.table-toolbar .form-select, .table-toolbar .form-control { height: 36px; font-size: 13px; }
.table-toolbar .form-select { width: auto; min-width: 140px; }

/* Pagination footer */
.table-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 11px 18px;
  border-top: 1px solid var(--line);
}

.table-foot .range-info { font-size: 12.5px; color: var(--ink-3); }

/* List footer (admin.partials.pagination): result count left, page links right. */
.list-pager { margin-top: 12px; }
.list-pager nav > div { gap: 12px; }
.list-pager p { margin: 0; }
.pagination { margin: 0; }
.pagination .page-link { color: var(--ink-2); border-color: var(--line); font-size: 13px; padding: 5px 11px; box-shadow: none; }
.pagination .page-link:hover { background: var(--surface-2); color: var(--ink); }
.pagination .page-item.active .page-link { background: var(--navy); border-color: var(--navy); color: #FFFFFF; }
.pagination .page-item.disabled .page-link { color: var(--ink-4); background: var(--surface-2); }

/* --------------------------------------------------------------------------
   9. Badges and pills
   -------------------------------------------------------------------------- */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 20px;
  white-space: nowrap;
  line-height: 1.35;
}

.badge-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-status.no-dot::before { display: none; }

.st-green { background: var(--green-bg); color: var(--green); }
.st-blue { background: var(--blue-bg); color: var(--blue); }
.st-amber { background: var(--amber-bg); color: var(--amber); }
.st-red { background: var(--red-bg); color: var(--red); }
.st-purple { background: var(--purple-bg); color: var(--purple); }
.st-grey { background: var(--grey-bg); color: var(--grey); }
.st-gold { background: var(--gold-tint); color: var(--gold-deep); }
.st-navy { background: var(--navy); color: var(--champagne); }

.pill-soft {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.pill-amc { background: var(--gold-tint); border-color: #EBDCBC; color: var(--gold-deep); }

/* --------------------------------------------------------------------------
   10. Buttons and forms
   -------------------------------------------------------------------------- */
.btn { font-size: 13.4px; font-weight: 600; border-radius: var(--radius-sm); padding: 7.5px 14px; display: inline-flex; align-items: center; gap: 7px; line-height: 1.4; }
.btn i { font-size: 15px; }
.btn-sm { font-size: 12.5px; padding: 5px 10px; }
.btn-sm i { font-size: 13.5px; }
.btn-lg { font-size: 14.5px; padding: 10px 20px; }

.btn-primary { background: var(--navy); border-color: var(--navy); color: #FFFFFF; }
.btn-primary:hover, .btn-primary:focus { background: #1A2436; border-color: #1A2436; color: #FFFFFF; }
.btn-primary:active { background: var(--deep-space) !important; border-color: var(--deep-space) !important; }
.btn-check:checked + .btn-primary { background: var(--deep-space); border-color: var(--deep-space); }

.btn-gold { background: var(--gold); border: 1px solid var(--gold); color: var(--navy); }
.btn-gold:hover { background: #BC9A57; border-color: #BC9A57; color: var(--navy); }

.btn-outline-secondary { border-color: var(--line); color: var(--ink-2); background: var(--surface); }
.btn-outline-secondary:hover { background: var(--surface-2); border-color: #D3DAE6; color: var(--ink); }

.btn-soft { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.btn-soft:hover { background: #EEF2F8; color: var(--ink); }

.btn-danger-soft { background: var(--red-bg); border: 1px solid #F3D9D9; color: var(--red); }
.btn-danger-soft:hover { background: #F7DEDE; color: var(--red); }

.btn-success-soft { background: var(--green-bg); border: 1px solid #CFE9DA; color: var(--green); }
.btn-success-soft:hover { background: #DBF0E5; color: var(--green); }

.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; }
.btn-icon i { font-size: 15px; }

.btn-whatsapp { background: #E8F6EE; border: 1px solid #CFE9DA; color: #10693D; }
.btn-whatsapp:hover { background: #D8F0E4; color: #0B5330; }

.form-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.form-label .req { color: var(--red); }
.form-label .opt { color: var(--ink-4); font-weight: 500; }

.form-control, .form-select {
  font-size: 13.5px;
  border-color: var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--ink);
  background-color: var(--surface);
}

.form-control::placeholder { color: var(--ink-4); }
.form-control:focus, .form-select:focus { border-color: var(--slate-mist); box-shadow: 0 0 0 3px rgba(136, 149, 170, .18); }
.form-control:disabled, .form-select:disabled { background: var(--surface-2); color: var(--ink-3); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--red); }
.invalid-feedback { font-size: 11.8px; color: var(--red); }

.form-text { font-size: 11.8px; color: var(--ink-4); }
.input-group-text { background: var(--surface-2); border-color: var(--line); font-size: 13px; color: var(--ink-3); }

.form-check-input { border-color: #CBD3E0; }
.form-check-input:checked { background-color: var(--navy); border-color: var(--navy); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(136, 149, 170, .18); border-color: var(--slate-mist); }
.form-check-label { font-size: 13.2px; color: var(--ink-2); }
.form-switch .form-check-input:checked { background-color: var(--green); border-color: var(--green); }

.form-section-title {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .7px;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-bottom: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

/* Selectable option tiles */
.option-tile { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; cursor: pointer; background: var(--surface); height: 100%; }
.option-tile:hover { border-color: var(--slate-mist); background: var(--surface-2); }
.option-tile .ot-title { font-size: 13.8px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.option-tile .ot-desc { font-size: 12.2px; color: var(--ink-3); margin-top: 3px; }
.option-tile input { display: none; }
.option-tile.selected { border-color: var(--gold-deep); background: var(--gold-tint); box-shadow: 0 0 0 1px var(--gold-deep) inset; }

/* Chip multi-select */
.chip-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 20px; padding: 6px 13px; font-size: 12.8px; font-weight: 600; cursor: pointer; }
.chip:hover { border-color: var(--slate-mist); }
.chip.active { background: var(--navy); border-color: var(--navy); color: #FFFFFF; }

/* --------------------------------------------------------------------------
   11. Tabs and filters
   -------------------------------------------------------------------------- */
.nav-tabs-line { border-bottom: 1px solid var(--line); gap: 2px; padding: 0 18px; flex-wrap: nowrap; overflow-x: auto; }

.nav-tabs-line .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-3);
  font-size: 13.2px;
  font-weight: 600;
  padding: 11px 12px;
  border-radius: 0;
  background: transparent;
  white-space: nowrap;
}

.nav-tabs-line .nav-link:hover { color: var(--ink); }
.nav-tabs-line .nav-link.active { color: var(--navy); border-bottom-color: var(--gold); background: transparent; }
.nav-tabs-line .nav-link .count { font-size: 11px; color: var(--ink-4); margin-left: 5px; font-weight: 600; }

.seg-filter { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg-filter button { border: 0; background: transparent; font-size: 12.5px; font-weight: 600; color: var(--ink-3); padding: 5px 12px; border-radius: 5px; }
.seg-filter button:hover { color: var(--ink); }
.seg-filter button.active { background: var(--surface); color: var(--navy); box-shadow: var(--shadow-sm); }

/* --------------------------------------------------------------------------
   12. Modals, wizard, toasts
   -------------------------------------------------------------------------- */
.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--line); padding: 16px 20px; }
.modal-title { font-size: 15.5px; font-weight: 700; }
.modal-header .sub { font-size: 12.3px; color: var(--ink-3); margin: 2px 0 0; }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--line); padding: 13px 20px; gap: 8px; }
.modal-footer > * { margin: 0; }

.modal-icon { width: 46px; height: 46px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; flex: 0 0 auto; }
.modal-icon.red { background: var(--red-bg); color: var(--red); }
.modal-icon.green { background: var(--green-bg); color: var(--green); }
.modal-icon.amber { background: var(--amber-bg); color: var(--amber); }
.modal-icon.blue { background: var(--blue-bg); color: var(--blue); }
.modal-icon.gold { background: var(--gold-tint); color: var(--gold-deep); }

/* Booking wizard */
.wizard-steps { display: flex; gap: 5px; padding: 15px 20px; background: var(--surface-2); border-bottom: 1px solid var(--line); overflow-x: auto; }
.wizard-steps .ws { flex: 1 1 0; min-width: 88px; }
.wizard-steps .ws .bar { height: 3px; border-radius: 3px; background: var(--line); margin-bottom: 7px; }
.wizard-steps .ws .lbl { font-size: 11px; font-weight: 600; color: var(--ink-4); letter-spacing: .3px; }
.wizard-steps .ws.done .bar { background: var(--gold); }
.wizard-steps .ws.done .lbl { color: var(--ink-3); }
.wizard-steps .ws.current .bar { background: var(--navy); }
.wizard-steps .ws.current .lbl { color: var(--navy); }

.wizard-pane { display: none; }
.wizard-pane.active { display: block; }

.toast-container { z-index: 1090; }
.toast { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 13.2px; }
.toast .toast-body { display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: var(--ink-2); }
.toast .toast-body i { font-size: 17px; }
.toast.t-ok .toast-body i { color: var(--green); }
.toast.t-err .toast-body i { color: var(--red); }
.toast.t-info .toast-body i { color: var(--blue); }
.toast.t-warn .toast-body i { color: var(--amber); }

/* --------------------------------------------------------------------------
   13. Charts
   -------------------------------------------------------------------------- */
.chart-box { position: relative; height: 268px; }
.chart-box.sm { height: 208px; }
.chart-box.lg { height: 322px; }

.chart-legend { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.chart-legend .cl { display: flex; align-items: center; gap: 8px; font-size: 12.6px; color: var(--ink-2); }
.chart-legend .cl .sw { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.chart-legend .cl .val { margin-left: auto; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   14. Calendar
   -------------------------------------------------------------------------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-left: 1px solid var(--line); border-top: 1px solid var(--line); }

.cal-head {
  padding: 9px 10px;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: center;
}

.cal-cell { min-height: 118px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 7px 8px; background: var(--surface); cursor: pointer; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.muted { background: var(--surface-2); }
.cal-cell.muted .cal-date { color: var(--ink-4); }
.cal-cell.today { background: #FFFCF4; box-shadow: inset 0 0 0 2px var(--gold); }
.cal-date { font-size: 12.5px; font-weight: 700; color: var(--ink-2); display: flex; align-items: center; justify-content: space-between; }
.cal-date .cnt { font-size: 10.5px; font-weight: 700; color: var(--ink-4); }

.cal-ev { display: block; font-size: 11.3px; padding: 3px 6px; border-radius: 5px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.cal-ev.blue { background: var(--blue-bg); color: var(--blue); }
.cal-ev.green { background: var(--green-bg); color: var(--green); }
.cal-ev.amber { background: var(--amber-bg); color: var(--amber); }
.cal-ev.purple { background: var(--purple-bg); color: var(--purple); }
.cal-ev.red { background: var(--red-bg); color: var(--red); }
.cal-more { font-size: 11px; color: var(--ink-4); margin-top: 3px; display: block; }

/* Agenda list */
.agenda-item { display: flex; gap: 14px; padding: 13px 18px; border-bottom: 1px solid var(--line-soft); }
.agenda-item:last-child { border-bottom: 0; }
.agenda-time { width: 78px; flex: 0 0 auto; font-size: 12.6px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.agenda-time .dur { display: block; font-size: 11px; color: var(--ink-4); font-weight: 500; }
.agenda-body { flex: 1 1 auto; min-width: 0; }
.agenda-body .a-name { font-size: 13.6px; font-weight: 600; }
.agenda-body .a-meta { font-size: 12.2px; color: var(--ink-3); }

/* --------------------------------------------------------------------------
   15. Timeline (AMC visits, activity, audit)
   -------------------------------------------------------------------------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.timeline .tl-item { position: relative; padding: 0 0 18px; }
.timeline .tl-item:last-child { padding-bottom: 0; }

.timeline .tl-dot {
  position: absolute;
  left: -26px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--ink-4);
}

.timeline .tl-item.done .tl-dot { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.timeline .tl-item.next .tl-dot { border-color: var(--gold); background: var(--gold-tint); color: var(--gold-deep); }
.timeline .tl-item.cancel .tl-dot { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.timeline .tl-title { font-size: 13.4px; font-weight: 600; }
.timeline .tl-meta { font-size: 12.1px; color: var(--ink-3); }

/* --------------------------------------------------------------------------
   16. Progress and usage
   -------------------------------------------------------------------------- */
.progress { height: 7px; background: var(--line-soft); border-radius: 20px; }
.progress-bar { background: var(--navy); border-radius: 20px; }
.progress-bar.gold { background: var(--gold); }
.progress-bar.green { background: var(--green); }
.progress-bar.amber { background: #D89B1F; }
.progress-bar.red { background: #C0453F; }
.progress-mini { height: 5px; width: 92px; }

.usage-row { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.usage-row:last-child { border-bottom: 0; }
.usage-row .u-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.usage-row .u-top b { font-weight: 600; }
.usage-row .u-val { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   17. Empty states, callouts, misc panels
   -------------------------------------------------------------------------- */
.empty-state { text-align: center; padding: 52px 24px; }

.empty-state .es-icon {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-4);
  font-size: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.empty-state h5 { font-size: 15px; margin-bottom: 5px; }
.empty-state p { color: var(--ink-3); font-size: 13.2px; max-width: 400px; margin: 0 auto 16px; }

.callout { border: 1px solid var(--line); border-left: 3px solid var(--blue); background: var(--blue-bg); border-radius: 0 var(--radius) var(--radius) 0; padding: 13px 16px; font-size: 13px; color: var(--ink-2); }
.callout.warn { border-left-color: var(--amber); background: var(--amber-bg); }
.callout.ok { border-left-color: var(--green); background: var(--green-bg); }
.callout.stop { border-left-color: var(--red); background: var(--red-bg); }
.callout .c-title { font-weight: 700; color: var(--ink); display: block; margin-bottom: 3px; font-size: 13px; }
.callout p:last-child { margin-bottom: 0; }

/* Photo and attachment thumbnails */
.thumb-grid { display: flex; flex-wrap: wrap; gap: 10px; }

.thumb {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ink-4);
  font-size: 10.5px;
  gap: 4px;
  text-align: center;
  padding: 6px;
}

.thumb i { font-size: 20px; }
.thumb.before { border-color: #D6E1F2; background: #F5F9FF; color: var(--blue); }
.thumb.after { border-color: #CFE9DA; background: #F3FBF6; color: var(--green); }
.thumb.add { border-style: dashed; cursor: pointer; }
.thumb.add:hover { border-color: var(--slate-mist); color: var(--ink-3); }

/* Signature preview */
.sign-box { border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--surface-2); height: 92px; display: flex; align-items: center; justify-content: center; color: var(--ink-4); font-size: 12.5px; font-style: italic; }

/* Document (A4 PDF) preview */
.doc-preview { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 26px 28px; font-size: 12.6px; color: var(--ink-2); }
.doc-preview .doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--navy); padding-bottom: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.doc-preview .doc-co { font-size: 15px; font-weight: 700; color: var(--navy); }
.doc-preview .doc-title { font-size: 17px; font-weight: 700; color: var(--navy); letter-spacing: 1.5px; text-transform: uppercase; }
.doc-preview table { width: 100%; font-size: 12.4px; }
.doc-preview .doc-items th { background: var(--surface-2); font-size: 10.5px; letter-spacing: .7px; text-transform: uppercase; color: var(--ink-3); padding: 7px 9px; border-bottom: 1px solid var(--line); }
.doc-preview .doc-items td { padding: 7px 9px; border-bottom: 1px solid var(--line-soft); }
.doc-preview .totals td { padding: 4px 0; }
.doc-preview .grand td { border-top: 1px solid var(--line); font-weight: 700; color: var(--ink); font-size: 14px; padding-top: 8px; }

/* Settings side navigation */
.settings-nav .nav-link { color: var(--ink-2); font-size: 13.3px; font-weight: 500; padding: 8px 12px; border-radius: var(--radius-sm); display: flex; align-items: center; gap: 9px; }
.settings-nav .nav-link i { color: var(--ink-4); font-size: 15px; }
.settings-nav .nav-link:hover { background: var(--surface-2); }
.settings-nav .nav-link.active { background: var(--navy); color: #FFFFFF; font-weight: 600; }
.settings-nav .nav-link.active i { color: var(--gold); }

/* Plan comparison cards */
.plan-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--surface); height: 100%; }
.plan-card.featured { border-color: var(--gold-deep); box-shadow: 0 0 0 1px var(--gold-deep) inset; }
.plan-card .p-name { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-3); }
.plan-card .p-price { font-size: 30px; font-weight: 700; letter-spacing: -1px; margin: 6px 0 2px; }
.plan-card .p-price small { font-size: 13px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.plan-card ul { list-style: none; padding: 0; margin: 16px 0 0; }
.plan-card ul li { display: flex; gap: 9px; font-size: 13px; color: var(--ink-2); padding: 6px 0; }
.plan-card ul li i { color: var(--green); font-size: 15px; }

/* Colour key */
.key-list { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.key-list .k { display: flex; align-items: center; gap: 7px; font-size: 12.3px; color: var(--ink-2); }
.key-list .k .sw { width: 11px; height: 11px; border-radius: 3px; }
.sw-blue { background: var(--blue); }
.sw-green { background: var(--green); }
.sw-amber { background: #D89B1F; }
.sw-purple { background: var(--purple); }
.sw-red { background: var(--red); }
.sw-navy { background: var(--navy); }
.sw-gold { background: var(--gold); }
.sw-slate { background: var(--slate-mist); }

/* --------------------------------------------------------------------------
   18. Responsive - desktop first, then tablet, then phone
   Breakpoints follow Bootstrap's so utility classes in the markup and the
   rules here always agree about where a layout changes.
   -------------------------------------------------------------------------- */

/* Nothing may push the page sideways: media and canvases stay inside their box. */
img, svg, canvas, video { max-width: 100%; }

/* Long unbroken strings (emails, GST numbers, URLs) wrap instead of widening
   their column. Applied to the text carriers, not to layout containers. */
.a-meta, .t-sub, .du-mail, .kv-list dd, .callout, .notif-item .n-text { overflow-wrap: break-word; }

@media (max-width: 1400px) {
  .header-search { width: 236px; }
}

@media (max-width: 1199.98px) {
  .app-content { padding: 18px; }
  .stat-card .stat-value { font-size: 23px; }
}

/* --- Tablet and below: the sidebar becomes an overlay drawer ------------- */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-collapse-btn { display: none; }
  .header-search { display: none; }
  .app-header { padding: 0 16px; gap: 10px; }
  .app-content { padding: 16px; }
  .cal-cell { min-height: 92px; }

  /* Data tables stop squeezing their columns to min-content: they keep the
     widths the content actually needs and .table-wrap scrolls sideways.
     Desktop is left alone - there the table still fills the card as before. */
  .table-scroll { min-width: max-content; }

  /* Dropdowns are anchored to the viewport edge, so cap them to it. */
  .notif-dropdown { width: min(366px, calc(100vw - 24px)); }


  .doc-preview { padding: 20px 18px; }
}

/* --- Small tablet and large phone ---------------------------------------- */
@media (max-width: 767.98px) {
  .app-content { padding: 13px; }
  .card-header { padding: 12px 14px; }
  .card-body { padding: 14px; }
  .table-toolbar { padding: 11px 14px; }
  .table-foot { padding: 10px 14px; justify-content: center; }
  .auth-card { padding: 26px 20px 22px; }
  .page-heading .crumb { display: none; }
  .cal-cell { min-height: 74px; padding: 5px; }
  .cal-ev { font-size: 10px; }

  .stat-card .card-body { padding: 14px 15px; }
  .stat-card .stat-value { font-size: 22px; }

  /* Charts give back vertical space; Chart.js redraws to the new box. */
  .chart-box { height: 236px; }
  .chart-box.sm { height: 190px; }
  .chart-box.lg { height: 268px; }

  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }

  .empty-state { padding: 38px 18px; }
  .plan-card { padding: 16px; }
  .thumb { width: 84px; height: 84px; }
  .agenda-time { width: 68px; }
  .agenda-item { padding: 12px 14px; }
  .attn-item { padding: 11px 14px; }
}

/* --- Phones -------------------------------------------------------------- */
@media (max-width: 575.98px) {
  .app-content { padding: 12px; }
  .app-header { padding: 0 12px; gap: 8px; }

  /* The header is a fixed height, so its text truncates rather than wraps. */
  .page-heading h1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .icon-btn, .sidebar-toggle { width: 34px; height: 34px; font-size: 15px; }
  .avatar { width: 28px; height: 28px; font-size: 11px; }

  /* Toolbar controls go full width and stack, instead of being squeezed
     into unreadable slivers on one line. */
  .table-toolbar .search-box { flex: 1 1 100%; max-width: none; }
  .table-toolbar .form-select { flex: 1 1 100%; width: 100%; min-width: 0; }
  .table-toolbar > .ms-auto { margin-left: 0 !important; width: 100%; }

  /* Segmented filters scroll rather than overflow the card. */
  .seg-filter { display: flex; max-width: 100%; overflow-x: auto; }
  .seg-filter button { white-space: nowrap; flex: 0 0 auto; }

  .nav-tabs-line { padding: 0 14px; }

  /* Agenda rows: time and status share the first line, details take the
     second, so the detail text is not squeezed into a narrow middle column. */
  .agenda-item { flex-wrap: wrap; gap: 6px 12px; }
  .agenda-time { width: auto; order: 1; }
  .agenda-item > div:last-child { order: 2; margin-left: auto; }
  .agenda-body { order: 3; flex: 1 1 100%; }

  /* Usage rows: the value drops under its label rather than being squeezed. */
  .usage-row .u-top { flex-wrap: wrap; gap: 2px 10px; }

  .card-footer { padding: 11px 14px; }
  .table-foot .range-info { width: 100%; text-align: center; }
  .wizard-steps { padding: 13px 16px; }
  .wizard-steps .ws { min-width: 74px; }
  .cal-cell { min-height: 66px; }
  .timeline { padding-left: 22px; }
  .key-list { gap: 8px 14px; }

  .doc-preview { padding: 16px 14px; }
  .doc-preview .doc-title { font-size: 15px; }
  .doc-preview .doc-head { gap: 12px; }

  /* Booking wizard, customer picker: the history pill drops onto its own line
     under the name rather than squeezing it into a narrow two-line column.
     44px (28px avatar + the 16px gap-3) keeps it aligned with the text. */
  .js-customer-result > .d-flex { flex-wrap: wrap; }
  .js-customer-result > .d-flex > .me-auto { flex: 1 1 calc(100% - 44px); }
  .js-customer-result > .d-flex > .pill-soft { margin-left: 44px; }

  /* Wizard footer: Discard stays on the left, Back/Continue keep their pair. */
  .card-footer .js-wizard-back { margin-left: auto; }

  .empty-state { padding: 32px 14px; }
  .empty-state .es-icon { width: 50px; height: 50px; font-size: 22px; }
}

/* --- Small phones (360px and under) -------------------------------------- */
@media (max-width: 400px) {
  .app-content { padding: 10px; }
  .app-header { gap: 6px; }
  .page-heading h1 { font-size: 14.5px; }
  .stat-card .stat-value { font-size: 20px; }
  .seg-filter button { padding: 5px 9px; font-size: 12px; }
  .btn { padding: 7px 11px; }
  .btn-lg { font-size: 14px; padding: 9px 16px; }
  .card-header { padding: 11px 12px; gap: 8px; }
  .card-body { padding: 12px; }
  .table-toolbar { padding: 10px 12px; }
  .thumb { width: 76px; height: 76px; }
}

/* --------------------------------------------------------------------------
   19. Print
   -------------------------------------------------------------------------- */
@media print {
  .app-sidebar, .app-header, .app-footer, .table-toolbar, .table-foot, .no-print { display: none !important; }
  .app-main { margin-left: 0; }
  .app-content { padding: 0; }
  .card { border: 0; box-shadow: none; }
}
