/* =============================================================
   osTicket Modern Theme System
   Light / Dark / System modes + full responsive layout
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── 1. Design Tokens (CSS Variables) ─────────────────────── */
:root {
  /* Brand palette */
  --brand-50:  #eef5ff;
  --brand-100: #d9e9ff;
  --brand-200: #bcd4ff;
  --brand-300: #8ab6ff;
  --brand-400: #528dff;
  --brand-500: #2563eb;
  --brand-600: #1d4ed8;
  --brand-700: #1e40af;
  --brand-800: #1e3a8a;
  --brand-900: #172554;

  /* Accent */
  --accent-500: #f97316;
  --accent-600: #ea580c;

  /* Status */
  --success-bg: #f0fdf4; --success-border: #86efac; --success-text: #166534;
  --warning-bg: #fffbeb; --warning-border: #fcd34d; --warning-text: #92400e;
  --error-bg:   #fef2f2; --error-border:   #fca5a5; --error-text:   #991b1b;
  --info-bg:    #eff6ff; --info-border:    #93c5fd; --info-text:    #1e40af;

  /* Spacing & shape */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.16);

  /* Typography */
  --font-sans: "Inter", "Lato", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Courier New", monospace;

  /* Staff layout (Stitch spec) */
  --sidebar-width: 108px;
  --sidebar-width-lg: 132px;
  --separator-width: 3px;
  --header-height: 64px;
  --chip-gap: 0.5rem;
  --nav-box-min-height: 80px;
  --gutter: 24px;
  --container-padding: 32px;
  --shadow-nav-active: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ── 2. Light Theme (default) ──────────────────────────────── */
[data-theme="light"],
:root {
  --bg-page:      #f0f4f8;
  --bg-surface:   #ffffff;
  --bg-surface2:  #f8fafc;
  --bg-surface3:  #f1f5f9;
  --bg-header:    #ffffff;
  --bg-nav:       #1e3a8a;
  --bg-nav-hover: #1d4ed8;
  --bg-nav-active:#2563eb;

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;
  --text-link:      #2563eb;
  --text-link-hover:#1d4ed8;
  --text-nav:       rgba(255,255,255,0.85);
  --text-nav-active:#ffffff;

  --border-color:   #e2e8f0;
  --border-strong:  #cbd5e1;
  --border-focus:   #2563eb;

  --input-bg:       #ffffff;
  --input-border:   #d1d5db;
  --input-focus-bg: #ffffff;

  --btn-primary-bg:   #2563eb;
  --btn-primary-text: #ffffff;
  --btn-primary-hover:#1d4ed8;

  --table-head-bg:  #f1f5f9;
  --table-row-alt:  #f8fafc;
  --table-row-hover:#eff6ff;

  --badge-open-bg:    #dbeafe; --badge-open-text:    #1e40af;
  --badge-closed-bg:  #dcfce7; --badge-closed-text:  #166534;
  --badge-pending-bg: #fef9c3; --badge-pending-text: #854d0e;
  --badge-urgent-bg:  #fee2e2; --badge-urgent-text:  #991b1b;

  --scrollbar-thumb: #cbd5e1;
  --scrollbar-track: #f1f5f9;

  --overlay-bg: rgba(15,23,42,0.5);
  --loading-bg: rgba(255,255,255,0.9);

  --sidebar-bg:              #ffffff;
  --sidebar-accent:          #2563eb;
  --sidebar-shadow:          2px 0 8px rgba(0, 0, 0, 0.06);
  --sidebar-link:            #64748b;
  --sidebar-link-hover-bg:   #eff6ff;
  --sidebar-link-hover-color:#2563eb;
}

/* ── 3. Dark Theme ─────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-page:      #0f172a;
  --bg-surface:   #1e293b;
  --bg-surface2:  #162032;
  --bg-surface3:  #253347;
  --bg-header:    #1e293b;
  --bg-nav:       #0f172a;
  --bg-nav-hover: #1e3a8a;
  --bg-nav-active:#2563eb;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-inverse:   #0f172a;
  --text-link:      #60a5fa;
  --text-link-hover:#93c5fd;
  --text-nav:       rgba(255,255,255,0.75);
  --text-nav-active:#ffffff;

  --border-color:   #1e3a8a;
  --border-strong:  #2563eb33;
  --border-focus:   #3b82f6;

  --input-bg:       #1e293b;
  --input-border:   #334155;
  --input-focus-bg: #253347;

  --btn-primary-bg:   #2563eb;
  --btn-primary-text: #ffffff;
  --btn-primary-hover:#3b82f6;

  --table-head-bg:  #162032;
  --table-row-alt:  #162032;
  --table-row-hover:#1e3a8a33;

  --badge-open-bg:    #1e3a8a; --badge-open-text:    #93c5fd;
  --badge-closed-bg:  #14532d; --badge-closed-text:  #86efac;
  --badge-pending-bg: #713f12; --badge-pending-text: #fde68a;
  --badge-urgent-bg:  #7f1d1d; --badge-urgent-text:  #fca5a5;

  --scrollbar-thumb: #334155;
  --scrollbar-track: #1e293b;

  --overlay-bg: rgba(0,0,0,0.7);
  --loading-bg: rgba(15,23,42,0.9);

  --sidebar-bg:              #0f172a;
  --sidebar-accent:          #2563eb;
  --sidebar-shadow:          2px 0 12px rgba(0, 0, 0, 0.35);
  --sidebar-link:            #94a3b8;
  --sidebar-link-hover-bg:   rgba(255, 255, 255, 0.08);
  --sidebar-link-hover-color:#93c5fd;
}

/* System preference fallback when no data-theme is set */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg-page:      #0f172a;
    --bg-surface:   #1e293b;
    --bg-surface2:  #162032;
    --bg-surface3:  #253347;
    --bg-header:    #1e293b;
    --bg-nav:       #0f172a;
    --bg-nav-hover: #1e3a8a;
    --bg-nav-active:#2563eb;

    --text-primary:   #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted:     #64748b;
    --text-inverse:   #0f172a;
    --text-link:      #60a5fa;
    --text-link-hover:#93c5fd;
    --text-nav:       rgba(255,255,255,0.75);
    --text-nav-active:#ffffff;

    --border-color:   #1e3a8a;
    --border-strong:  #2563eb33;
    --border-focus:   #3b82f6;

    --input-bg:       #1e293b;
    --input-border:   #334155;
    --input-focus-bg: #253347;

    --btn-primary-bg:   #2563eb;
    --btn-primary-text: #ffffff;
    --btn-primary-hover:#3b82f6;

    --table-head-bg:  #162032;
    --table-row-alt:  #162032;
    --table-row-hover:#1e3a8a33;

    --badge-open-bg:    #1e3a8a; --badge-open-text:    #93c5fd;
    --badge-closed-bg:  #14532d; --badge-closed-text:  #86efac;
    --badge-pending-bg: #713f12; --badge-pending-text: #fde68a;
    --badge-urgent-bg:  #7f1d1d; --badge-urgent-text:  #fca5a5;

    --scrollbar-thumb: #334155;
    --scrollbar-track: #1e293b;

    --overlay-bg: rgba(0,0,0,0.7);
    --loading-bg: rgba(15,23,42,0.9);

    --sidebar-bg:              #0f172a;
    --sidebar-accent:          #2563eb;
    --sidebar-shadow:          2px 0 12px rgba(0, 0, 0, 0.35);
    --sidebar-link:            #94a3b8;
    --sidebar-link-hover-bg:   rgba(255, 255, 255, 0.08);
    --sidebar-link-hover-color:#93c5fd;
  }
}

/* ── 4. Global Base Resets ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

/* Full-height page so container fills viewport */
html, body { min-height: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 0.933rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  margin: 0;
  padding: 0;
  transition: background 0.2s ease, color 0.2s ease;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--text-link-hover); text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }

/* ── 5. Layout Container ───────────────────────────────────── */
#container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg-surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── 6. Header ─────────────────────────────────────────────── */
#header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  position: sticky;
  top: var(--alert-bar-height, 0px);
  z-index: 200;
  box-shadow: var(--shadow-sm);
}

#logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  outline: none;
  flex-shrink: 0;
  max-height: 64px;
}
#logo img {
  display: block;
  width: auto;
  height: auto;
  max-height: 32px;
  max-width: 140px;
  object-fit: contain;
}
.valign-helper { display: none; }

/* ── Header: Stitch layout ─────────────────────────────────── */

/* Right cluster */
body.staff-panel .hdr-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  flex-shrink: 0;
}

/* Icon buttons (theme toggle, logout) */
body.staff-panel .hdr-icon-btn,
body.staff-panel .hdr-right #theme-toggle,
body.staff-panel .theme-toggle-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
body.staff-panel .hdr-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
body.staff-panel .hdr-icon-btn:hover {
  background: var(--bg-surface3);
  color: var(--text-primary);
  text-decoration: none;
}

/* Override theme-toggle pill style inside staff header */
body.staff-panel #header #theme-toggle {
  background: none;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  padding: 0;
  min-height: unset;
  color: var(--text-secondary);
  font-size: 1rem;
  gap: 0;
}
body.staff-panel #header #theme-toggle:hover {
  background: var(--bg-surface3);
}
body.staff-panel #header #theme-toggle span[style] {
  font-size: 0 !important; /* hide label text, keep icon */
}
body.staff-panel #header #theme-toggle .theme-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}
body.staff-panel #header #theme-toggle .theme-icon span {
  display: none; /* hide "Light/Dark/System" text label */
}

/* Admin/Agent panel switcher link */
body.staff-panel .hdr-panel-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--border-color);
  transition: background 0.15s, color 0.15s;
}
body.staff-panel .hdr-panel-link:hover {
  background: var(--bg-surface3);
  color: var(--brand-500);
  text-decoration: none;
}

/* Vertical divider */
body.staff-panel .hdr-divider {
  width: 1px;
  height: 28px;
  background: var(--border-color);
  margin: 0 6px;
  flex-shrink: 0;
}

/* Agent info group */
body.staff-panel .hdr-agent {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: background 0.15s;
  cursor: pointer;
}
body.staff-panel .hdr-agent:hover {
  background: var(--bg-surface3);
  text-decoration: none;
}
body.staff-panel .hdr-agent-text {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
body.staff-panel .hdr-agent-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
}
body.staff-panel .hdr-agent-role {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
}
body.staff-panel .hdr-agent-avatar {
  font-size: 1.6rem;
  color: var(--text-secondary);
  line-height: 1;
}

/* Hide old p#info text style on staff panel */
body.staff-panel #header #info {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  float: none;
  background: none;
  border: none;
}

/* ── 7. Primary Navigation ─────────────────────────────────── */
#nav {
  background: var(--bg-nav);
  padding: 0 16px;
  margin: 0;
  list-style: none;
  display: flex;
  align-items: stretch;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  border: none;
  border-bottom: 3px solid var(--bg-nav-active);
  position: sticky;
  top: 64px;
  z-index: 99;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -ms-overflow-style: none;
  box-sizing: border-box;
}
#nav::-webkit-scrollbar { display: none; }

#nav li,
#nav li.active,
#nav li.inactive {
  display: flex;
  align-items: stretch;
  list-style: none;
  border-radius: 0;
  border: none;
  margin: 0;
  padding: 0;
  position: relative;
  align-self: stretch;
  height: auto;
}

#nav li a,
#nav li.active > a,
#nav li.inactive > a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  height: 100%;
  min-height: 44px;
  max-height: 44px;
  color: var(--text-nav);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  border: none;
  border-bottom: 3px solid transparent;
  margin: 0;
  box-sizing: border-box;
  align-self: stretch;
  background-color: transparent;
  background-image: none;
  box-shadow: none;
}

#nav li a.active,
#nav li.active > a {
  color: var(--text-nav-active);
  font-weight: 600;
  background-color: var(--bg-nav-active);
  border-bottom-color: #60a5fa;
  box-shadow: none;
}

#nav li.inactive:hover > a,
#nav li:hover > a:not(.active) {
  background-color: var(--bg-nav-hover);
  color: #fff;
  text-decoration: none;
}

/* Client portal: prevent flex-shrink text wrap that tiles nav icons */
body:not(.staff-panel) #nav {
  justify-content: flex-start;
  gap: 2px;
  align-items: stretch;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  padding: 0 12px;
  box-sizing: border-box;
}
body:not(.staff-panel) #nav li {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  align-items: stretch;
  height: auto;
  align-self: stretch;
}
body:not(.staff-panel) #nav li a {
  flex-shrink: 0;
  white-space: nowrap;
  background-repeat: no-repeat;
  background-size: 16px 16px;
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  height: 100%;
  min-height: 44px;
  max-height: 44px;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  background-color: transparent;
  border-bottom: 3px solid transparent;
  box-shadow: none;
}
body:not(.staff-panel) #nav li a.active {
  background-color: var(--bg-nav-active);
  border-bottom-color: #60a5fa;
  box-shadow: none;
}
body:not(.staff-panel) #nav li a:hover:not(.active) {
  background-color: var(--bg-nav-hover);
}

/* Dropdown in nav — disabled; sub-pages use #sub_nav */
#nav li.inactive > ul {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none;
}

/* Sub-navigation */
#sub_nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  margin: 0;
  height: auto;
  min-height: 38px;
  display: flex;
  align-items: center;
  list-style: none;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
#sub_nav::-webkit-scrollbar { display: none; }
#sub_nav > li {
  display: inline-flex;
  align-items: center;
  list-style: none;
}
#sub_nav > li > a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
#sub_nav > li > a:hover,
#sub_nav > li.active > a {
  background: var(--bg-surface3);
  color: var(--text-link);
  text-decoration: none;
}

/* Client portal nav */
ul#nav.flush-left {
  position: sticky;
  top: var(--header-height, 64px);
}

/* ── 8. Content Area ───────────────────────────────────────── */
#content {
  background: var(--bg-surface);
  padding: 28px 32px;
  flex: 1;
  border: none;
  border-bottom: none;
}

/* ── 9. Cards & Surfaces ───────────────────────────────────── */
.card,
.box,
.sidebar,
.widget {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* ── 10. Forms ─────────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
select,
textarea {
  background: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
  background: var(--input-focus-bg);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  accent-color: var(--brand-500);
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  cursor: pointer;
}

/* Buttons */
input[type="submit"],
input[type="button"],
input[type="reset"] {
  display: inline-block;
  vertical-align: middle;
  text-align: center;
  padding: 8px 18px;
  min-height: 38px;
  min-width: 44px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.25;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

button,
.btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  min-height: 38px;
  min-width: 44px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

input[type="submit"],
.btn,
a.btn {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text) !important;
  border-color: var(--btn-primary-bg);
}
input[type="submit"]:hover,
.btn:hover,
a.btn:hover {
  background: var(--btn-primary-hover);
  border-color: var(--btn-primary-hover);
  text-decoration: none;
}

input[type="button"],
input[type="reset"],
.btn-secondary {
  background: var(--bg-surface3);
  color: var(--text-primary) !important;
  border-color: var(--border-strong);
}
input[type="button"]:hover,
input[type="reset"]:hover,
.btn-secondary:hover {
  background: var(--bg-surface2);
}

/* ── 11. Tables ────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 0.9rem;
}

th {
  background: var(--table-head-bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: var(--table-row-alt); }
tr:hover td { background: var(--table-row-hover); }

/* Responsive table wrapper */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

/* ── 12. Badges & Status Pills ─────────────────────────────── */
.badge,
.label,
span.label {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-open,
.label-info    { background: var(--badge-open-bg);    color: var(--badge-open-text); }
.badge-closed,
.label-success { background: var(--badge-closed-bg);  color: var(--badge-closed-text); }
.badge-pending,
.label-warning { background: var(--badge-pending-bg); color: var(--badge-pending-text); }
.badge-urgent,
.label-danger  { background: var(--badge-urgent-bg);  color: var(--badge-urgent-text); }

/* Priority colours */
.low    { color: var(--badge-closed-text); }
.normal { color: var(--badge-open-text); }
.high   { color: var(--badge-pending-text); font-weight: 600; }
.urgent,
.emergency { color: var(--badge-urgent-text); font-weight: 700; }

/* ── 13. Alert / Message Bars ──────────────────────────────── */
#msg_error, .error-banner, #error_bar {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  height: auto;
  min-height: 0;
  box-sizing: border-box;
}
#msg_notice, .notice-banner, .success-banner {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  height: auto;
  min-height: 0;
  box-sizing: border-box;
}
#msg_info, .info-banner, #notice_bar {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info-text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  height: auto;
  min-height: 0;
}
#msg_warning, .warning-banner, #warning_bar {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  height: auto;
  min-height: 0;
  box-sizing: border-box;
}

/* System alerts (above header) — always visible, never clipped */
:root {
  --alert-bar-height: 0px;
  --header-height: 64px;
  --chrome-top: calc(var(--alert-bar-height) + var(--header-height));
}

#notice_bar,
#warning_bar,
#error_bar {
  position: sticky;
  top: 0;
  z-index: 300;
  width: 100%;
  box-sizing: border-box;
  height: auto !important;
  min-height: 0;
  line-height: 1.5 !important;
  padding: 10px 20px !important;
  margin: 0 !important;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  background-image: none !important;
  padding-left: 20px !important;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}

body.staff-panel #staff-sidebar {
  top: var(--chrome-top, 64px);
}

body.staff-panel .staff-subnav {
  position: sticky;
  top: var(--chrome-top, 64px);
  z-index: 150;
  overflow: visible !important;
}

/* ── 14. Footer ────────────────────────────────────────────── */
#footer {
  background: var(--bg-surface2);
  border-top: 1px solid var(--border-color);
  padding: 16px 24px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  clear: both;
}
#footer a { color: var(--text-muted); }
#footer a:hover { color: var(--text-link); }
#poweredBy { font-size: 0.78rem; }

/* ── 15. Loading Overlay ───────────────────────────────────── */
#overlay {
  background: var(--overlay-bg);
}
#loading {
  background: var(--loading-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
}
#loading h1, #loading h4 {
  color: var(--text-primary);
}

/* ── 16. Theme Toggle Button ───────────────────────────────── */
#theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface3);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 30px;
}
#theme-toggle:hover {
  background: var(--bg-surface2);
  border-color: var(--border-focus);
  color: var(--text-link);
}
#theme-toggle .theme-icon { font-size: 1rem; line-height: 1; }

/* Theme menu popup */
#theme-menu {
  position: fixed;
  min-width: 160px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 99999;
  overflow: hidden;
  display: none;
}
#theme-menu.open { display: block; }
#theme-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.1s;
  min-height: unset;
  border-radius: 0;
  text-align: left;
}
#theme-menu button:hover { background: var(--bg-surface3); }
#theme-menu button.active { color: var(--brand-500); font-weight: 600; }
#theme-menu button .menu-icon { font-size: 1rem; }

.theme-toggle-wrapper {
  position: relative;
  display: inline-block;
}

/* ── 17. Mobile Hamburger Menu ─────────────────────────────── */
#nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 28px;
  height: 20px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  flex-shrink: 0;
}
#nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.25s;
}
#nav-toggle.open span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
#nav-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
#nav-toggle.open span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

/* ── 18. Breadcrumbs ───────────────────────────────────────── */
#breadcrumbs {
  background: var(--bg-surface2);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
#breadcrumbs a { color: var(--text-secondary); }
#breadcrumbs a:hover { color: var(--text-link); }

/* ── 19. Ticket Thread ─────────────────────────────────────── */
.thread-entry {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
}
.thread-entry .header {
  background: var(--bg-surface2);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.thread-entry .body {
  padding: 16px;
  color: var(--text-primary);
  line-height: 1.7;
}

/* ── 20. Dashboard Stats ───────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand-500);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── 21. Login Page ────────────────────────────────────────── */
body.login-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-page);
}
body.login-page .login-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 420px;
  margin: auto;
  box-shadow: var(--shadow-md);
}
body.login-page .login-box input[type="text"],
body.login-page .login-box input[type="email"],
body.login-page .login-box input[type="password"] {
  margin-bottom: 12px;
}

/* ── 22. Search Form (Client Homepage) ─────────────────────── */
.search-form {
  background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-500) 100%);
  padding: 40px 32px;
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  text-align: center;
}
.search-form h2, .search-form h1 {
  color: #fff;
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.5rem;
  font-weight: 700;
}
.search-form input[type="text"],
.search-form input[type="search"] {
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 1rem;
  max-width: 520px;
  border: 2px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.95);
  color: #1e293b;
}
.search-form input[type="submit"] {
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 1rem;
  margin-top: 8px;
}

/* ── 23. Sidebar (client portal) ───────────────────────────── */
.sidebar {
  width: 260px;
  float: right;
  margin-left: 24px;
  background: var(--bg-surface2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 0.875rem;
}
.sidebar h3 {
  color: var(--text-link);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 10px;
  padding: 0;
  background: none;
}
.sidebar ul { margin: 0; padding-left: 16px; }
.sidebar li { margin-bottom: 4px; }
.sidebar a { color: var(--text-link); font-size: 0.875rem; }

/* ── 24. Select2 Dark Theme Adaptation ─────────────────────── */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
  background: var(--input-bg) !important;
  border: 1px solid var(--input-border) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-primary) !important;
  min-height: 36px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text-primary) !important;
  line-height: 34px;
}
.select2-dropdown {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-md) !important;
}
.select2-container--default .select2-results__option--highlighted {
  background: var(--brand-500) !important;
  color: #fff !important;
}
.select2-results__option { color: var(--text-primary) !important; }
.select2-search--dropdown .select2-search__field {
  background: var(--input-bg) !important;
  border: 1px solid var(--input-border) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
}

/* ── 25. jQuery UI Dialog overrides ────────────────────────── */
.ui-dialog, .dialog {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--text-primary) !important;
}
.ui-dialog-titlebar, .dialog > h3 {
  background: var(--bg-surface2) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}

/* ── 26. Redactor editor in dark mode ──────────────────────── */
[data-theme="dark"] .redactor-box.redactor-styles-on,
[data-theme="dark"] .redactor-toolbar,
[data-theme="dark"] .redactor-box {
  background: var(--bg-surface2) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .redactor-in,
[data-theme="dark"] .redactor-editor {
  background: var(--input-bg) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .redactor-focus.redactor-styles-on,
[data-theme="dark"] .redactor-focus:focus.redactor-styles-on {
  border-color: var(--border-focus) !important;
}

[data-theme="dark"] .redactor-placeholder:before,
[data-theme="dark"] .redactor-in figcaption[placeholder]:empty:before {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .redactor-toolbar a,
[data-theme="dark"] .redactor-air a {
  background: var(--bg-surface3) !important;
  color: var(--text-secondary) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25) !important;
}

[data-theme="dark"] .redactor-toolbar a:hover,
[data-theme="dark"] .redactor-air a:hover {
  background: var(--brand-500) !important;
  color: #fff !important;
}

[data-theme="dark"] .redactor-toolbar a.redactor-button-active,
[data-theme="dark"] .redactor-air a.redactor-button-active {
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .redactor-statusbar {
  background: var(--bg-surface2) !important;
  border-top: 1px solid var(--border-color) !important;
}

[data-theme="dark"] .redactor-statusbar li {
  color: var(--text-muted) !important;
  border-right-color: var(--border-color) !important;
}

[data-theme="dark"] .redactor-statusbar a {
  color: var(--text-link) !important;
}

[data-theme="dark"] .redactor-statusbar a:hover {
  color: var(--text-link-hover) !important;
}

[data-theme="dark"] .redactor-dropdown {
  background: var(--bg-surface) !important;
  border-color: var(--border-color) !important;
  box-shadow: var(--shadow-lg) !important;
}

[data-theme="dark"] .redactor-dropdown a {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .redactor-dropdown a:hover {
  background: var(--bg-surface3) !important;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .redactor-box.redactor-styles-on,
  :root:not([data-theme="light"]) .redactor-toolbar,
  :root:not([data-theme="light"]) .redactor-box {
    background: var(--bg-surface2) !important;
    border-color: var(--border-color) !important;
  }

  :root:not([data-theme="light"]) .redactor-in,
  :root:not([data-theme="light"]) .redactor-editor {
    background: var(--input-bg) !important;
    color: var(--text-primary) !important;
  }

  :root:not([data-theme="light"]) .redactor-focus.redactor-styles-on,
  :root:not([data-theme="light"]) .redactor-focus:focus.redactor-styles-on {
    border-color: var(--border-focus) !important;
  }

  :root:not([data-theme="light"]) .redactor-placeholder:before,
  :root:not([data-theme="light"]) .redactor-in figcaption[placeholder]:empty:before {
    color: var(--text-muted) !important;
  }

  :root:not([data-theme="light"]) .redactor-toolbar a,
  :root:not([data-theme="light"]) .redactor-air a {
    background: var(--bg-surface3) !important;
    color: var(--text-secondary) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25) !important;
  }

  :root:not([data-theme="light"]) .redactor-toolbar a:hover,
  :root:not([data-theme="light"]) .redactor-air a:hover {
    background: var(--brand-500) !important;
    color: #fff !important;
  }

  :root:not([data-theme="light"]) .redactor-toolbar a.redactor-button-active,
  :root:not([data-theme="light"]) .redactor-air a.redactor-button-active {
    background: var(--bg-surface) !important;
    color: var(--text-primary) !important;
  }

  :root:not([data-theme="light"]) .redactor-statusbar {
    background: var(--bg-surface2) !important;
    border-top: 1px solid var(--border-color) !important;
  }

  :root:not([data-theme="light"]) .redactor-statusbar li {
    color: var(--text-muted) !important;
    border-right-color: var(--border-color) !important;
  }

  :root:not([data-theme="light"]) .redactor-statusbar a {
    color: var(--text-link) !important;
  }

  :root:not([data-theme="light"]) .redactor-statusbar a:hover {
    color: var(--text-link-hover) !important;
  }
}

/* ── 27. Popup dialog ──────────────────────────────────────── */
#popup {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
}
#popup .body { color: var(--text-primary); }

/* ── 28. Misc utility ──────────────────────────────────────── */
.clear { clear: both; }
.pull-right { float: right; }
.pull-left  { float: left; }
.flush-right { margin-right: 0; }
.flush-left  { margin-left: 0; }
.faded { color: var(--text-muted); }
.faded-more { color: var(--text-muted); opacity: 0.6; }
.centered { text-align: center; }
.full-width { width: 100%; box-sizing: border-box; }
.fluid-table { width: 100%; max-width: 100%; }

/* Focus visibility for keyboard users */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.action-button:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 16px 0;
}

/* ── 29. Tooltips ──────────────────────────────────────────── */
.tooltip,
.tipsy-inner {
  background: var(--bg-nav) !important;
  color: #fff !important;
  border-radius: var(--radius-sm) !important;
  font-size: 0.8rem !important;
}

/* ── 30. Settings / Admin Tables ───────────────────────────── */
.settings_table th,
.settings-table th {
  background: var(--bg-surface2);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}
.settings_table td,
.settings-table td {
  border-bottom: 1px solid var(--border-color);
}

/* ── 31. Fluid layout & usability ──────────────────────────── */
#content table,
.main-content table,
#pjax-container table {
  width: 100% !important;
  max-width: 100%;
}

#content input[type="text"],
#content input[type="email"],
#content input[type="password"],
#content input[type="search"],
#content input[type="tel"],
#content input[type="url"],
#content input[type="number"],
#content select,
#content textarea,
.main-content input,
.main-content select,
.main-content textarea {
  max-width: 100%;
}

/* Attached search bars: input + button inline */
.input.attached,
.attached.input {
  display: inline-flex;
  align-items: stretch;
  flex-direction: row;
  flex-wrap: nowrap;
  vertical-align: middle;
  width: auto;
  max-width: 100%;
  height: auto;
  min-height: 32px;
  margin-right: 5px;
  box-sizing: border-box;
}
.input.attached input,
.attached.input input {
  flex: 1 1 12rem;
  width: auto;
  min-width: 8rem;
  max-width: none;
  height: 32px;
  line-height: normal;
  margin: 0;
  display: block;
  box-sizing: border-box;
}
.input.attached .button.attached,
.attached.input .button.attached,
.input.attached button.attached {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-height: 32px;
  width: auto;
  margin: 0;
  padding: 0 12px;
  box-sizing: border-box;
}
#basic_search form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
#basic_search .input.attached,
#basic_search .attached.input {
  flex: 1 1 280px;
  max-width: 420px;
}

#content h1,
#content h2.page-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  margin: 12px 0 16px;
  line-height: 1.35;
}
#content h1 .pull-right,
#content h2 .pull-right {
  float: none;
  margin-left: auto;
}

.search.well {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-surface2);
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
}
.search.well form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}
.search.well .flush-left { width: 100%; }
.search.well .pull-right {
  float: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.search.well input[type="text"],
.search.well input[type="search"] {
  flex: 1 1 180px;
  min-width: 0;
}
.search.well select {
  min-width: 0;
  max-width: 100%;
}

.action-button,
.button,
input[type="submit"],
input[type="button"],
button.btn {
  touch-action: manipulation;
}

/* Standalone buttons only — not split dropdown wrappers */
a.action-button,
button.action-button,
input.action-button,
a.button.action-button,
.green.button.action-button,
.red.button.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  height: auto;
  min-height: 32px;
  line-height: 1.35;
  box-sizing: border-box;
  vertical-align: middle;
}

.tickets-table-wrap,
.list-table-wrap,
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  border-radius: var(--radius-md);
}

.tickets-table-wrap > table,
.list-table-wrap > table {
  margin-bottom: 0;
}

.sticky.bar {
  padding: 10px 0;
  overflow: visible;
}
.sticky.bar > .content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  width: 100%;
}
.sticky.bar .pull-left,
.sticky.bar .pull-right,
.sticky.bar .flush-left,
.sticky.bar .flush-right {
  float: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.sticky.bar .pull-right,
.sticky.bar .flush-right {
  margin-left: auto;
}
.sticky.bar h2 {
  margin: 0;
  line-height: 1.35;
}
.sticky.bar h2 a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.sticky.bar .configureQ {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
}

table.ticket_info > tbody > tr {
  vertical-align: top;
}

/* ── Tablet (≤ 1024px) ─────────────────────────────────────── */
@media (max-width: 1024px) {
  #container {
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  #nav li a,
  #nav li.active > a,
  #nav li.inactive > a {
    padding: 0 12px;
    font-size: 0.83rem;
    height: 100%;
    min-height: 44px;
    max-height: 44px;
  }

  #content {
    padding: 20px 16px;
  }

  .sidebar {
    width: 220px;
  }
}

/* ── Mobile (≤ 768px) ──────────────────────────────────────── */
@media (max-width: 768px) {
  html { font-size: 14px; }

  /* Header */
  #header {
    padding: 0 14px;
    min-height: 56px;
    position: sticky;
    top: 0;
  }

  #logo img { max-height: 38px; max-width: 160px; }

  /* Sub-nav */
  #sub_nav {
    padding: 6px 12px;
    gap: 4px;
    flex-wrap: wrap;
    min-height: unset;
    height: auto;
  }

  /* Content */
  #content {
    padding: 16px 12px;
  }

  /* Tables: scroll on mobile */
  table {
    font-size: 0.82rem;
  }
  /* Auto-wrap ticket list table */
  .tickets-table-wrap,
  .list-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
  }

  /* Search / filter toolbar */
  .search.well form {
    flex-direction: column;
    align-items: stretch;
  }
  .search.well .pull-right {
    margin-left: 0;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .search.well input[type="text"],
  .search.well input[type="search"],
  .search.well select,
  .search.well input[type="submit"] {
    width: 100%;
  }

  /* Page title actions */
  #content h1 .pull-right,
  #content h2 .pull-right {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }
  #content h1 .pull-right.states {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Ticket metadata stacks on small screens */
  table.ticket_info > tbody > tr {
    display: flex;
    flex-direction: column;
  }
  table.ticket_info > tbody > tr > td {
    width: 100% !important;
    display: block;
  }

  /* Action buttons easier to tap */
  a.action-button,
  button.action-button {
    min-height: 36px;
    padding: 8px 12px;
  }

  .sticky.bar > .content {
    flex-direction: column;
    align-items: stretch;
  }
  .sticky.bar .pull-right,
  .sticky.bar .flush-right {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  /* Sidebar collapses below content */
  .sidebar {
    float: none;
    width: 100%;
    margin-left: 0;
    margin-top: 16px;
  }

  /* Search form */
  .search-form {
    padding: 24px 16px;
    border-radius: var(--radius-md);
  }
  .search-form h2, .search-form h1 { font-size: 1.2rem; }

  /* Login */
  body.login-page .login-box { padding: 24px 16px; max-width: 100%; margin: 16px; }
  #clientLogin .login-box { flex: 1 1 100%; max-width: 100%; padding: 20px 16px; }
  #clientLogin input.btn[type=submit],
  #clientLogin input[type=submit] { width: 100% !important; min-width: 0; }

  /* Buttons full-width in forms on mobile */
  .form-actions input[type="submit"],
  .form-actions .btn {
    width: 100%;
  }

  /* Stats grid */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 10px; }
  .stat-card .stat-value { font-size: 1.6rem; }

  /* Thread entries */
  .thread-entry .header { padding: 8px 12px; }
  .thread-entry .body  { padding: 12px; }

  /* Header user links */
  #header .pull-right,
  #header p#info {
    font-size: 0.78rem;
    gap: 8px;
  }

  /* Footer */
  #footer { padding: 12px; font-size: 0.78rem; }
}

/* ── Small Mobile (≤ 480px) ────────────────────────────────── */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }

  th { font-size: 0.72rem; padding: 8px 8px; }
  td { padding: 8px 8px; font-size: 0.82rem; }

  #content { padding: 12px 10px; }

  #nav li a,
  #nav li.active > a,
  #nav li.inactive > a {
    font-size: 0.95rem;
    padding: 0 16px;
    height: 100%;
    min-height: 44px;
    max-height: 44px;
  }
}

/* ── Staff panel: left sidebar navigation (Stitch spec) ───── */
body.staff-panel {
  background: var(--bg-page);
}

body.staff-panel #container {
  background: var(--bg-page);
}

body.staff-panel #pjax-container {
  display: block;
  flex: 1;
  background: var(--bg-page);
  overflow: visible;
}

body.staff-panel .staff-shell {
  display: flex;
  align-items: flex-start;
  gap: 0;
  min-height: calc(100vh - 64px);
  position: relative;
  margin-top: 64px;
}

body.staff-panel .staff-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  overflow: visible;
}

/* Fixed sidebar — full-height, Stitch spec */
body.staff-panel #staff-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 3px solid var(--sidebar-accent);
  position: fixed;
  left: 0;
  top: 64px;
  bottom: 0;
  height: auto;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 50;
  box-shadow: var(--sidebar-shadow);
}

body.staff-panel #staff-sidebar #nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  background: transparent;
  border: none;
  position: static;
  top: auto;
  min-height: unset;
  overflow: visible;
  white-space: normal;
}

body.staff-panel #staff-sidebar #nav li,
body.staff-panel #staff-sidebar #nav .active,
body.staff-panel #staff-sidebar #nav .inactive {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
  overflow: visible;
}

body.staff-panel #staff-sidebar #nav li {
  position: relative;
}

body.staff-panel #staff-sidebar #nav li a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  min-height: 72px;
  padding: 14px 8px;
  margin: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--sidebar-link);
  font-size: 0.70rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  box-shadow: none;
  transition: background 0.15s, color 0.15s;
}

body.staff-panel #staff-sidebar #nav li a:hover {
  color: var(--sidebar-link-hover-color);
  background: var(--sidebar-link-hover-bg);
  text-decoration: none;
  transform: none;
  border: none;
}

body.staff-panel #staff-sidebar #nav li.active > a,
body.staff-panel #staff-sidebar #nav .active a {
  color: #ffffff;
  background: var(--sidebar-accent);
  border: none;
  border-radius: 0;
  box-shadow: none;
  z-index: 2;
  margin: 0;
  width: 100%;
}

body.staff-panel #staff-sidebar #nav .nav-icon {
  font-size: 1.3rem;
  line-height: 1;
  opacity: 1;
}

body.staff-panel #staff-sidebar #nav li.active > a .nav-icon,
body.staff-panel #staff-sidebar #nav .active a .nav-icon {
  opacity: 1;
}

body.staff-panel #staff-sidebar #nav .nav-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.68rem;
  letter-spacing: 0.01em;
}

body.staff-panel #staff-sidebar #nav li.inactive > ul {
  display: none !important;
}

body.staff-panel #sub_nav {
  z-index: 40;
}

body.staff-panel .staff-subnav {
  padding: 10px var(--gutter);
  background: var(--bg-page);
  border-bottom: 1px solid var(--border-color);
  overflow: visible;
  clip-path: none;
}

body.staff-panel .staff-subnav #sub_nav,
body.staff-panel #customQ_nav.staff-subnav #sub_nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--chip-gap);
  margin: 0;
  padding: 4px 0 6px;
  list-style: none;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  min-height: unset;
  height: auto;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body.staff-panel .staff-subnav #sub_nav::-webkit-scrollbar,
body.staff-panel #customQ_nav.staff-subnav #sub_nav::-webkit-scrollbar {
  display: none;
}

body.staff-panel #sub_nav > li,
body.staff-panel #customQ_nav #sub_nav > li {
  display: flex;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
}

body.staff-panel #sub_nav > li > a,
body.staff-panel #customQ_nav #sub_nav > li > a,
body.staff-panel #customQ_nav .jb-overflowmenu-menu-primary > li.item > a {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  max-width: none;
  min-height: 0;
  height: auto;
  padding: 8px 16px !important;
  margin: 0 !important;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  background-image: none !important;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.33;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

body.staff-panel #sub_nav > li > a:hover,
body.staff-panel #customQ_nav #sub_nav > li > a:hover,
body.staff-panel #customQ_nav .jb-overflowmenu-menu-primary > li.item > a:hover {
  color: var(--text-primary);
  background: var(--bg-surface3);
  border-color: var(--border-strong);
  text-decoration: none;
  transform: none;
}

body.staff-panel #sub_nav > li > a.active,
body.staff-panel #sub_nav a.active,
body.staff-panel #sub_nav li.active > a,
body.staff-panel #sub_nav li.child.active > a,
body.staff-panel #customQ_nav #sub_nav > li > a.active,
body.staff-panel #customQ_nav #sub_nav a.active,
body.staff-panel #customQ_nav #sub_nav li.active > a,
body.staff-panel #customQ_nav #sub_nav li.child.active > a,
body.staff-panel #customQ_nav .jb-overflowmenu-menu-primary > li.item > a.active,
body.staff-panel #customQ_nav .queue-nav-trigger.active {
  color: #fff;
  background: var(--brand-500);
  border-color: var(--brand-600);
  box-shadow: var(--shadow-nav-active);
  font-weight: 500;
}

body.staff-panel #sub_nav .subnav-icon {
  font-size: 1rem;
  line-height: 1;
  opacity: 0.88;
  flex-shrink: 0;
}

body.staff-panel #sub_nav > li > a.active .subnav-icon,
body.staff-panel #sub_nav li.active > a .subnav-icon,
body.staff-panel #customQ_nav #sub_nav > li > a.active .subnav-icon,
body.staff-panel #customQ_nav #sub_nav li.active > a .subnav-icon {
  opacity: 1;
}

body.staff-panel #sub_nav .subnav-label {
  display: inline;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}

body.staff-panel #sub_nav > li.top-queue > a {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  max-width: none;
  min-height: 0;
  padding: 8px 16px !important;
  font-size: 0.75rem;
  text-align: left;
  white-space: nowrap;
}

body.staff-panel #content {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding: 28px 32px;
  background: var(--bg-page);
  overflow-x: hidden;
}

body.staff-panel #content form {
  min-width: 0;
  max-width: 100%;
}

body.staff-panel #content h1,
body.staff-panel #content h2.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.33;
  color: var(--text-primary);
  margin: 0 0 8px;
}

body.staff-panel #content table.list,
body.staff-panel #content table.dashboard-stats,
body.staff-panel #content table.queue {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
  box-shadow: none;
}

body.staff-panel #content table.list th,
body.staff-panel #content table.dashboard-stats th,
body.staff-panel #content table.queue th {
  background: var(--table-head-bg);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

body.staff-panel #content table.list td,
body.staff-panel #content table.dashboard-stats td,
body.staff-panel #content table.queue td {
  font-size: 0.8125rem;
  border-color: var(--border-color);
}

body.staff-panel #content table.list tbody tr:hover td,
body.staff-panel #content table.queue tbody tr:hover td {
  background: var(--table-row-hover);
}

body.staff-panel .sticky.bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: var(--gutter);
}

body.staff-panel #header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: none;
  height: 64px;
  min-height: 64px;
  max-height: 64px;
  flex-wrap: nowrap;
  overflow: visible;
  position: fixed;
  top: var(--alert-bar-height, 0px);
  left: 0;
  right: 0;
  width: 100%;
  z-index: 200;
  padding: 0;
  display: flex;
  align-items: center;
}

/* Logo zone matches sidebar width — looks like part of the sidebar */
body.staff-panel #logo {
  width: var(--sidebar-width);
  flex-shrink: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border-right: 3px solid var(--sidebar-accent);
  background: var(--sidebar-bg);
  overflow: hidden;
  text-decoration: none;
}

body.staff-panel #logo .valign-helper { display: none; }

body.staff-panel #logo img {
  height: 30px !important;
  max-height: 30px !important;
  width: auto !important;
  max-width: 100px !important;
  object-fit: contain;
  display: block;
}

/* Right side of header fills remaining space */
body.staff-panel #header #info.hdr-right {
  flex: 1;
  padding: 0 20px;
  justify-content: flex-end;
}

@media (min-width: 1024px) {
  body.staff-panel #staff-sidebar {
    width: var(--sidebar-width-lg);
  }

  body.staff-panel #logo {
    width: var(--sidebar-width-lg);
  }

  body.staff-panel .staff-main {
    margin-left: var(--sidebar-width-lg);
    width: calc(100% - var(--sidebar-width-lg));
  }

  body.staff-panel #staff-sidebar #nav li a {
    min-height: 84px;
    font-size: 0.75rem;
  }
}

@media (min-width: 769px) {
  body.staff-panel .staff-subnav #sub_nav,
  body.staff-panel #customQ_nav.staff-subnav #sub_nav {
    flex-wrap: wrap;
    overflow-x: auto;
  }
}

@media (max-width: 900px) {
  body.staff-panel #nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 9px 7px;
    margin: 0 8px 0 12px;
    flex-shrink: 0;
    background: var(--bg-surface2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
  }

  body.staff-panel #logo {
    width: auto;
    flex: 1;
    min-width: 0;
    border-right: none;
    justify-content: flex-start;
    padding: 0 12px 0 0;
    height: 56px;
  }

  body.staff-panel .staff-shell {
    flex-direction: column;
    min-height: unset;
  }

  body.staff-panel #staff-sidebar {
    position: fixed;
    left: 0;
    top: var(--chrome-top, 56px);
    bottom: 0;
    width: min(280px, 88vw);
    max-height: none;
    min-height: 0;
    margin-left: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 260;
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 3px solid var(--sidebar-accent);
    border-bottom: none;
    -webkit-overflow-scrolling: touch;
  }

  body.staff-panel #staff-sidebar.nav-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.18);
  }

  body.staff-panel .staff-main {
    margin-left: 0;
    width: 100%;
  }

  body.staff-panel #staff-sidebar #nav {
    display: flex !important;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    padding: 8px 0 16px;
    width: 100%;
    min-width: 0;
  }

  body.staff-panel #staff-sidebar #nav li {
    width: 100%;
    flex: 0 0 auto;
  }

  body.staff-panel #staff-sidebar #nav li a {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    min-width: 0;
    min-height: 48px;
    padding: 12px 20px;
    font-size: 0.9rem;
    text-align: left;
  }

  body.staff-panel #staff-sidebar #nav .nav-icon {
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
  }

  body.staff-panel #staff-sidebar #nav .nav-label {
    font-size: 0.9rem;
    text-align: left;
  }

  body.staff-panel.staff-nav-menu-open::before {
    content: '';
    position: fixed;
    left: 0;
    right: 0;
    top: var(--chrome-top, 56px);
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 250;
    pointer-events: none;
  }
}

@media (max-width: 768px) {
  body.staff-panel .staff-shell {
    flex-direction: column;
    min-height: unset;
  }

  body.staff-panel #content {
    padding: 16px 12px;
  }

  body.staff-panel .staff-subnav {
    padding: 8px 12px;
  }

  body.staff-panel .staff-subnav #sub_nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: var(--chip-gap);
    scrollbar-width: none;
  }

  body.staff-panel .staff-subnav #sub_nav::-webkit-scrollbar {
    display: none;
  }

  body.staff-panel #sub_nav > li > a {
    padding: 6px 12px !important;
    font-size: 0.7rem;
  }
}

/* ── Desktop: hide hamburger on staff panel ───────────────── */
@media (min-width: 901px) {
  body.staff-panel #nav-toggle {
    display: none !important;
  }
}

/* ── Print ─────────────────────────────────────────────────── */
@media print {
  #nav, #sub_nav, #header, #footer, #staff-sidebar,
  #nav-toggle, #theme-toggle, .theme-toggle-wrapper,
  #overlay, #loading { display: none !important; }

  #container { max-width: 100%; box-shadow: none; }
  #content { padding: 0; border: none; }
  body { background: #fff; color: #000; }
}
/* =============================================================
   Dashboard Stitch Redesign — scoped to body.staff-panel
   Tokens from ost-theme.css; Signal Blue #2563eb
   ============================================================= */

/* ── Page header ────────────────────────────────────────────── */
body.staff-panel .dash-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin: 0 0 28px;
  gap: 12px;
}

body.staff-panel .dash-page-title {
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em;
  color: var(--text-primary) !important;
  margin: 0 0 4px !important;
}

body.staff-panel .dash-page-sub {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
}

/* ── KPI bento grid ─────────────────────────────────────────── */
body.staff-panel .dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gutter, 24px);
  margin-bottom: var(--gutter, 24px);
}

@media (max-width: 1024px) {
  body.staff-panel .dash-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  body.staff-panel .dash-kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
}

/* ── KPI card base ──────────────────────────────────────────── */
body.staff-panel .kpi-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 12px);
  padding: 22px 24px 20px;
  min-height: 110px;
  text-decoration: none !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s, transform 0.12s;
  cursor: pointer;
}

body.staff-panel .kpi-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  transform: translateY(-2px);
  border-color: var(--border-color);
  text-decoration: none !important;
}

body.staff-panel .kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

body.staff-panel .kpi-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0;
}

body.staff-panel .kpi-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface3);
  border-radius: var(--radius-md, 8px);
  color: var(--brand-500);
  font-size: 1.15rem;
}

body.staff-panel .kpi-icon--danger {
  background: #fef2f2;
  color: #dc2626;
}

body.staff-panel .kpi-bottom {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

body.staff-panel .kpi-value {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

body.staff-panel .kpi-value--danger {
  color: #dc2626;
}

body.staff-panel .kpi-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 400;
  line-height: 1.3;
}

body.staff-panel .kpi-sub--danger {
  color: #dc2626;
  font-weight: 500;
}

/* ── Recent Activity card ───────────────────────────────────── */
body.staff-panel .dash-activity-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  margin-bottom: var(--gutter, 24px);
}

body.staff-panel .dash-activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
}

body.staff-panel .dash-activity-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  background: none;
  border: none;
}

body.staff-panel .dash-view-all {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--brand-500);
  text-decoration: none;
}

body.staff-panel .dash-view-all:hover {
  text-decoration: underline;
}

/* ── Recent table ───────────────────────────────────────────── */
body.staff-panel .dash-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

body.staff-panel .dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

body.staff-panel .dash-table thead tr {
  background: var(--table-head-bg);
}

body.staff-panel .dash-table thead th {
  padding: 10px 20px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  background: var(--table-head-bg);
  white-space: nowrap;
}

body.staff-panel .dash-table tbody .dash-row td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

body.staff-panel .dash-table tbody .dash-row:last-child td {
  border-bottom: none;
}

body.staff-panel .dash-table tbody .dash-row:hover td {
  background: var(--table-row-hover);
}

/* Ticket ID column */
body.staff-panel .dash-ticket-id {
  font-weight: 700;
  white-space: nowrap;
}

body.staff-panel .dash-ticket-id a {
  color: var(--brand-500);
  text-decoration: none;
}

body.staff-panel .dash-ticket-id a:hover {
  text-decoration: underline;
}

/* Subject */
body.staff-panel .dash-subject-cell {
  max-width: 280px;
}

body.staff-panel .dash-subject {
  display: block;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}

/* Agent avatar + name */
body.staff-panel .dash-agent-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

body.staff-panel .dash-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.12);
  color: var(--brand-600, #1d4ed8);
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0;
}

body.staff-panel .dash-unassigned {
  color: var(--text-muted);
  font-style: italic;
}

/* Status badges */
body.staff-panel .dash-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

body.staff-panel .dash-badge--open {
  background: var(--badge-open-bg);
  color: var(--badge-open-text);
}

body.staff-panel .dash-badge--closed {
  background: var(--badge-closed-bg);
  color: var(--badge-closed-text);
}

body.staff-panel .dash-badge--pending {
  background: var(--badge-pending-bg);
  color: var(--badge-pending-text);
}

body.staff-panel .dash-badge--overdue {
  background: var(--badge-urgent-bg);
  color: var(--badge-urgent-text);
}

/* Updated column */
body.staff-panel .dash-col-right {
  text-align: right;
  white-space: nowrap;
}

body.staff-panel .dash-updated {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Show More footer */
body.staff-panel .dash-show-more {
  padding: 12px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface2);
  text-align: center;
}

body.staff-panel .dash-show-more-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
}

body.staff-panel .dash-show-more-link:hover {
  color: var(--brand-500);
  text-decoration: none;
}

/* Empty state */
body.staff-panel .dash-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

body.staff-panel .dash-empty i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ── Reports accordion ──────────────────────────────────────── */
body.staff-panel .dash-reports-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  margin-bottom: var(--gutter, 24px);
}

body.staff-panel .dash-reports-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  list-style: none;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: background 0.15s;
}

body.staff-panel .dash-reports-section[open] > .dash-reports-toggle {
  border-bottom-color: var(--border-color);
}

body.staff-panel .dash-reports-toggle:hover {
  background: var(--bg-surface2);
}

body.staff-panel .dash-reports-toggle::-webkit-details-marker {
  display: none;
}

body.staff-panel .dash-chevron {
  margin-left: auto;
  transition: transform 0.2s;
}

body.staff-panel .dash-reports-section[open] .dash-chevron {
  transform: rotate(180deg);
}

body.staff-panel .dash-reports-body {
  padding: 24px;
}

body.staff-panel .dash-report-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

body.staff-panel .dash-chart-wrap {
  position: relative;
  margin-bottom: 16px;
}

/* Clean up legacy chart gradient in staff panel */
body.staff-panel #line-chart-here {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color) !important;
  background: var(--bg-surface2) !important;
  background-image: none !important;
  filter: none !important;
  padding: 8px;
}

/* ── Dark mode overrides ────────────────────────────────────── */
[data-theme="dark"] body.staff-panel .kpi-card,
[data-theme="dark"].staff-panel .kpi-card {
  background: var(--bg-surface);
  border-color: var(--border-color);
}

[data-theme="dark"] body.staff-panel .dash-activity-card,
[data-theme="dark"].staff-panel .dash-activity-card {
  background: var(--bg-surface);
}

[data-theme="dark"] body.staff-panel .dash-table thead tr,
[data-theme="dark"].staff-panel .dash-table thead tr {
  background: var(--bg-surface2);
}

[data-theme="dark"] body.staff-panel .dash-table thead th {
  background: var(--bg-surface2);
}

/* Staff sidebar + logo — dark theme (beats legacy hardcoded light chrome) */
[data-theme="dark"] body.staff-panel #staff-sidebar,
[data-theme="dark"] body.staff-panel #logo {
  background: var(--sidebar-bg) !important;
  border-right-color: var(--sidebar-accent) !important;
  box-shadow: var(--sidebar-shadow);
}

[data-theme="dark"] body.staff-panel #staff-sidebar #nav li a,
[data-theme="dark"] body.staff-panel #staff-sidebar #nav .inactive a {
  color: var(--sidebar-link) !important;
}

[data-theme="dark"] body.staff-panel #staff-sidebar #nav li a:hover,
[data-theme="dark"] body.staff-panel #staff-sidebar #nav li.inactive:hover > a {
  color: var(--sidebar-link-hover-color) !important;
  background: var(--sidebar-link-hover-bg) !important;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body.staff-panel #staff-sidebar,
  :root:not([data-theme="light"]) body.staff-panel #logo {
    background: var(--sidebar-bg) !important;
    border-right-color: var(--sidebar-accent) !important;
    box-shadow: var(--sidebar-shadow);
  }

  :root:not([data-theme="light"]) body.staff-panel #staff-sidebar #nav li a,
  :root:not([data-theme="light"]) body.staff-panel #staff-sidebar #nav .inactive a {
    color: var(--sidebar-link) !important;
  }

  :root:not([data-theme="light"]) body.staff-panel #staff-sidebar #nav li a:hover,
  :root:not([data-theme="light"]) body.staff-panel #staff-sidebar #nav li.inactive:hover > a {
    color: var(--sidebar-link-hover-color) !important;
    background: var(--sidebar-link-hover-bg) !important;
  }
}

/* ── Sub-nav pill chips (rounded-full) ───────────────────────── */
body.staff-panel #sub_nav > li > a,
body.staff-panel #customQ_nav #sub_nav > li > a,
body.staff-panel #customQ_nav .jb-overflowmenu-menu-primary > li.item > a,
body.staff-panel #customQ_nav .queue-nav-trigger {
  border-radius: 999px !important;
}
