/* ═══════════════════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════════════════ */
:root {
  /* Brand */
  --indigo:        #6366f1;
  --indigo-dark:   #4f46e5;
  --indigo-light:  #eef2ff;
  --indigo-subtle: #e0e7ff;
  --indigo-dim:    rgba(99,102,241,.12);

  /* Semantic */
  --green:         #10b981;
  --green-light:   #d1fae5;
  --green-dark:    #059669;
  --red:           #ef4444;
  --red-light:     #fee2e2;
  --amber:         #f59e0b;
  --amber-light:   #fef3c7;
  --amber-dark:    #d97706;
  --purple:        #8b5cf6;
  --purple-light:  #ede9fe;

  /* Text */
  --text:           #0f172a;
  --text-secondary: #334155;
  --text-light:     #64748b;
  --text-muted:     #94a3b8;

  /* Borders */
  --border:         #e8edf2;
  --border-strong:  #d0d7df;

  /* Surfaces */
  --surface:        #ffffff;
  --surface-alt:    #f8fafc;
  --surface-hover:  #f1f5f9;
  --bg:             #f0f2f7;

  /* Sidebar */
  --sb-bg:          #0d1117;
  --sb-bg-2:        #161b24;
  --sb-border:      rgba(255,255,255,.06);
  --sb-hover:       rgba(255,255,255,.05);
  --sb-muted:       #4b5563;
  --sb-text:        #9ca3af;
  --sidebar-width:  244px;

  /* Radii */
  --r-sm:   6px;
  --r:      10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 4px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow:    0 2px 8px rgba(15,23,42,.07), 0 1px 3px rgba(15,23,42,.04);
  --shadow-md: 0 8px 24px rgba(15,23,42,.09), 0 2px 6px rgba(15,23,42,.05);
  --shadow-lg: 0 20px 48px rgba(15,23,42,.13), 0 4px 10px rgba(15,23,42,.06);

  --transition: .13s ease;
}

/* ═══════════════════════════════════════════════════════
   RESET + BASE
═══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════ */
header {
  background: var(--sb-bg);
  width: var(--sidebar-width);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 0 0 20px;
  overflow-y: auto;
  border-right: 1px solid var(--sb-border);
}

/* Brand */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--sb-border);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-copy { overflow: hidden; }
header h1 {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-subtitle {
  font-size: 10px;
  color: var(--sb-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Search */
.sidebar-search {
  padding: 14px 12px 12px;
  border-bottom: 1px solid var(--sb-border);
}
.sidebar-search-wrap { position: relative; }
.sidebar-search-wrap input {
  width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.07);
  color: #e2e8f0;
  padding: 7px 10px 7px 30px;
  border-radius: var(--r-sm);
  font-size: 12px;
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition), background var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 9px center;
}
.sidebar-search-wrap input::placeholder { color: #374151; }
.sidebar-search-wrap input:focus {
  border-color: rgba(99,102,241,.45);
  background-color: rgba(255,255,255,.07);
}
.sidebar-search-clear {
  position: absolute;
  right: 7px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: #4b5563; cursor: pointer;
  font-size: 14px; line-height: 1;
  width: 18px; height: 18px;
  display: none; align-items: center; justify-content: center;
  border-radius: 3px; padding: 0;
}
.sidebar-search-clear:hover { color: #6b7280; }

/* Nav */
nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 10px;
  flex: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sb-muted);
  padding: 10px 8px 4px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--sb-text);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: inherit;
  line-height: 1;
  width: 100%;
  position: relative;
}
.nav-btn svg { flex-shrink: 0; opacity: .5; transition: opacity var(--transition); }
.nav-btn:hover { background: var(--sb-hover); color: #d1d5db; }
.nav-btn:hover svg { opacity: .8; }
.nav-btn.active {
  background: var(--indigo-dim);
  color: #a5b4fc;
  font-weight: 600;
}
.nav-btn.active svg { opacity: 1; color: #818cf8; }
/* Tickets submenu */
.nav-subgroup {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: -2px;
  margin-bottom: 2px;
  padding-left: 30px;
  position: relative;
}
.nav-sub-btn {
  background: transparent;
  border: none;
  color: #6b7280;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  width: 100%;
  transition: background var(--transition), color var(--transition);
  position: relative;
  line-height: 1;
}
.nav-sub-btn:hover { background: var(--sb-hover); color: #d1d5db; }
.nav-sub-btn.active { color: #a5b4fc; font-weight: 600; }

.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 14px 12px 0;
  border-top: 1px solid var(--sb-border);
  margin-top: auto;
}

#status-dot {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: #4b5563;
  padding: 6px 12px 8px;
  background: none;
  border: none;
}
#status-dot .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #374151;
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}
#status-dot.ok  .dot { background: #34d399; box-shadow: 0 0 0 2px rgba(52,211,153,.18); }
#status-dot.err .dot { background: #f87171; box-shadow: 0 0 0 2px rgba(248,113,113,.18); }

/* ═══════════════════════════════════════════════════════
   PAGE LAYOUT
═══════════════════════════════════════════════════════ */
.page { display: none; margin-left: var(--sidebar-width); min-height: 100vh; }
.page.active { display: block; }

main {
  max-width: none;
  margin: 0 auto;
  padding: 16px 16px 72px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Page header row */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0;
  max-width: none;
  margin: 0 auto;
  width: 100%;
}
.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.025em;
}
.page-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  letter-spacing: -.005em;
}

.card-body { padding: 20px; }
.card-header-actions { display: flex; align-items: center; gap: 8px; }
.toggle-btn.icon-only {
  width: 30px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

/* ═══════════════════════════════════════════════════════
   TYPOGRAPHY / LABELS
═══════════════════════════════════════════════════════ */
label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: .005em;
}

/* ═══════════════════════════════════════════════════════
   FORM FIELDS
═══════════════════════════════════════════════════════ */
input[type=text], input[type=email], input[type=tel],
input[type=number], input[type=date], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
  line-height: 1.5;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
input:hover:not(:focus), textarea:hover:not(:focus), select:hover:not(:focus) {
  border-color: var(--border-strong);
}
input::placeholder, textarea::placeholder { color: #c0cad6; }
textarea { resize: vertical; min-height: 80px; }

select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* ═══════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), box-shadow var(--transition), transform 60ms ease;
  font-family: inherit;
  white-space: nowrap;
  line-height: 1.5;
  letter-spacing: -.01em;
}
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn-primary {
  background: var(--indigo);
  color: #fff;
  box-shadow: 0 1px 3px rgba(99,102,241,.3), 0 1px 2px rgba(99,102,241,.2);
}
.btn-primary:hover:not(:disabled) {
  background: var(--indigo-dark);
  box-shadow: 0 4px 12px rgba(99,102,241,.3);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--border-strong);
}

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-quote {
  background: var(--amber-dark);
  color: #fff;
  box-shadow: 0 1px 3px rgba(217,119,6,.28);
}
.btn-quote:hover:not(:disabled) { background: #b45309; }

.btn-sm  { padding: 5px 12px; font-size: 11.5px; border-radius: var(--r-sm); }
.btn-lg  { padding: 10px 26px; font-size: 14px; border-radius: var(--r); font-weight: 700; }
.btn-icon {
  padding: 7px;
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  font-family: inherit;
}
.btn-icon:hover { background: var(--surface); border-color: var(--border-strong); color: var(--text); }

/* ═══════════════════════════════════════════════════════
   GRID
═══════════════════════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.field-group { margin-bottom: 14px; }
.field-hint { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* ═══════════════════════════════════════════════════════
   SEARCH + DROPDOWN
═══════════════════════════════════════════════════════ */
.search-wrap { position: relative; }
.search-wrap > input {
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 11px center;
}
.search-hint   { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }
.search-status { font-size: 12px; color: var(--text-light); margin-top: 5px; height: 18px; }
.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 320px;
  overflow-y: auto;
  display: none;
}
.dropdown.open { display: block; }
.dropdown-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--surface-alt);
  transition: background var(--transition);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--indigo-light); }
.dropdown-item .primary   { font-weight: 600; font-size: 13px; color: var(--text); }
.dropdown-item .secondary { font-size: 11.5px; color: var(--text-light); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.dropdown-item.empty { color: var(--text-muted); font-style: italic; cursor: default; text-align: center; padding: 20px; font-size: 13px; }
.dropdown-item.empty:hover { background: none; }

/* ═══════════════════════════════════════════════════════
   CUSTOMER CHIP
═══════════════════════════════════════════════════════ */
#customer-selected {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  background: var(--indigo-light);
  border: 1.5px solid var(--indigo-subtle);
  border-radius: var(--r-sm);
  margin-bottom: 16px;
}
#customer-selected .cs-name { font-weight: 700; font-size: 13.5px; color: var(--indigo-dark); }
#customer-selected .cs-meta { font-size: 12px; color: var(--text-light); margin-top: 2px; }
#clear-customer {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 18px; line-height: 1;
  padding: 3px 6px; border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}
#clear-customer:hover { color: var(--red); background: var(--red-light); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
  font-weight: 400;
}
.checkbox-row input[type=checkbox] { width: auto; cursor: pointer; accent-color: var(--indigo); }

/* ═══════════════════════════════════════════════════════
   LINE ITEMS TABLE
═══════════════════════════════════════════════════════ */
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 16px;
}
.items-table th {
  text-align: left;
  padding: 9px 12px;
  background: var(--surface-alt);
  border-bottom: 1.5px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.items-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.items-table tr:last-child td { border-bottom: none; }
.items-table tbody tr:hover td { background: #fafbff; }
.items-table .product-name { font-weight: 600; color: var(--text); }
.items-table .item-row { display: flex; align-items: center; gap: 10px; }
.items-table .item-thumb { width: 38px; height: 38px; flex-shrink: 0; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--border); }
.items-table .item-thumb-empty { width: 38px; height: 38px; flex-shrink: 0; border-radius: var(--r-sm); background: var(--surface-alt); border: 1px solid var(--border); }
.items-table .variation-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.items-table .item-sku { font-size: 11px; color: var(--text-muted); margin-top: 1px; font-family: monospace; }
.stock-note { font-size: 11px; color: var(--text-muted); margin-top: 4px; white-space: nowrap; }
.qty-input { width: 60px; text-align: center; padding: 5px 6px; }
.remove-btn {
  background: none; border: none;
  color: var(--text-muted); font-size: 15px; cursor: pointer;
  line-height: 1; padding: 4px 8px; border-radius: 4px;
  transition: color var(--transition), background var(--transition);
  display: inline-flex; align-items: center; justify-content: center;
}
.remove-btn:hover { color: var(--red); background: var(--red-light); }

.empty-items {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-muted);
  font-size: 13px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r);
  margin-top: 16px;
  background: var(--surface-alt);
}

/* ═══════════════════════════════════════════════════════
   ORDER DETAILS SECTIONS
═══════════════════════════════════════════════════════ */
.od-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.od-section-last { border-bottom: none; }
.od-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.od-shipping-row { display: flex; gap: 10px; align-items: flex-start; }
.od-shipping-row > input:first-child { flex: 1; }
.od-amount-wrap { position: relative; width: 120px; flex-shrink: 0; }
.od-currency { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--text-muted); pointer-events: none; }
.od-amount-wrap input { padding-left: 22px; }
.shipping-presets { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.shipping-preset-btn {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 2px; padding: 7px 11px;
  border: 1.5px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface-alt); cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  font-family: inherit; text-align: left;
}
.shipping-preset-btn:hover { border-color: var(--indigo); background: var(--indigo-light); }
.shipping-preset-btn.selected { border-color: var(--indigo); background: var(--indigo-light); box-shadow: 0 0 0 2px var(--indigo-dim); }
.sp-label { font-size: 11.5px; font-weight: 500; color: var(--text-secondary); line-height: 1.2; }
.sp-price { font-size: 12.5px; font-weight: 600; color: var(--indigo-dark); line-height: 1.2; }
.sp-stepper { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.sp-minus {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--indigo); background: var(--surface);
  color: var(--indigo-dark); font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; font-family: inherit;
  transition: background var(--transition), color var(--transition);
}
.sp-minus:hover { background: var(--indigo); color: #fff; }
.sp-qty { font-size: 12px; font-weight: 700; color: var(--indigo-dark); min-width: 12px; text-align: center; }
.od-coupon-row { display: flex; gap: 8px; }
.od-coupon-input { flex: 1; text-transform: uppercase; font-family: monospace; letter-spacing: 1px; }
.od-paid-row { margin-top: 12px; padding: 10px 12px; background: var(--surface-alt); border: 1.5px solid var(--border); border-radius: var(--r-sm); }

/* ═══════════════════════════════════════════════════════
   COUPON CHIPS
═══════════════════════════════════════════════════════ */
.coupon-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.coupon-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fefce8;
  border: 1.5px solid #fde047;
  border-radius: var(--r-full);
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #854d0e;
  letter-spacing: .3px;
}
.coupon-chip button { background: none; border: none; cursor: pointer; color: #a16207; font-size: 13px; line-height: 1; padding: 0 2px; }
.coupon-chip.not-found { background: var(--red-light); border-color: #fca5a5; color: #991b1b; }

.coupon-inline-card { overflow: hidden; }
.collapsible-card-header {
  width: 100%;
  min-height: 48px;
  padding: 14px 20px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  cursor: pointer;
}
.collapsible-card-header:hover { background: var(--surface-alt); }
.collapse-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: transform var(--transition), color var(--transition), border-color var(--transition);
}
.collapse-arrow.open { transform: rotate(180deg); color: var(--indigo); border-color: var(--indigo-subtle); }
.collapsible-card-body { padding: 18px 20px; }
.coupon-inline-grid { display: flex; flex-direction: column; gap: 16px; }
.coupon-inline-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.coupon-apply-panel {
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  padding: 14px;
}
.coupon-inline-divider {
  height: 1px;
  background: var(--border);
}

/* ═══════════════════════════════════════════════════════
   TOTALS
═══════════════════════════════════════════════════════ */
.totals { display: flex; flex-direction: column; font-size: 13.5px; }
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.totals-row:last-of-type { border-bottom: none; }
.totals-row.discount { color: var(--green-dark); font-weight: 500; }
.totals-row.total {
  font-size: 17px;
  font-weight: 800;
  border-top: 2px solid var(--border);
  border-bottom: none;
  padding-top: 14px;
  margin-top: 8px;
  color: var(--text);
}
.totals-note { font-size: 11px; color: var(--text-muted); margin-top: 8px; }
.submit-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ═══════════════════════════════════════════════════════
   STATUS BADGES
═══════════════════════════════════════════════════════ */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.status-pending    { background: #fef9ec; border: 1px solid #fde68a; color: #92400e; }
.status-processing { background: #eef2ff; border: 1px solid #c7d2fe; color: #3730a3; }
.status-on-hold    { background: #f8fafc; border: 1px solid var(--border); color: #475569; }
.status-completed  { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.status-cancelled  { background: var(--red-light); border: 1px solid #fca5a5; color: #991b1b; }
.status-refunded   { background: var(--purple-light); border: 1px solid #c4b5fd; color: #5b21b6; }

/* ═══════════════════════════════════════════════════════
   ORDERS TABLE
═══════════════════════════════════════════════════════ */
.orders-history-card { margin-top: 16px; }
.orders-filter-row {
  display: flex;
  flex: 1 1 100%;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.orders-filter-row input {
  width: auto;
  min-width: 145px;
  flex: 1 1 145px;
}
.orders-filter-row input[type="text"] { flex-basis: 220px; }
.order-date-group + .order-date-group { border-top: 1px solid var(--border); }
.order-date-heading {
  padding: 12px 18px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  background: var(--surface-alt);
}
.order-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 13px;
}
.order-search-row:last-child { border-bottom: none; }
.order-search-row:hover { background: #f9faff; }
.order-search-row .osr-left  { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; overflow: hidden; }
.order-search-row .osr-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.osr-num    { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; min-width: 56px; }
.osr-name   { font-weight: 600; color: var(--text); }
.osr-company { font-size: 12px; color: var(--text-muted); }
.osr-email  { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.osr-date   { font-size: 11.5px; color: var(--text-muted); }
.osr-total  { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.osr-arrow  { color: var(--border-strong); font-size: 14px; }
.orders-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  flex-wrap: wrap;
}
.orders-page-summary {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
.orders-per-page {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  margin-left: auto;
}
.orders-per-page select {
  width: 76px;
  min-height: 34px;
  padding: 6px 28px 6px 10px;
  font-size: 13px;
}
.orders-page-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.orders-page-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.orders-page-btn:hover:not(:disabled),
.orders-page-btn.active {
  border-color: var(--indigo);
  background: var(--indigo);
  color: #fff;
}
.orders-page-btn:disabled {
  cursor: not-allowed;
  opacity: .45;
}

/* ═══════════════════════════════════════════════════════
   STATS GRID
═══════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 10px; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }

/* ═══════════════════════════════════════════════════════
   TICKET
═══════════════════════════════════════════════════════ */
#tickets-page { padding: 0; }
.tickets-split {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  background: var(--surface);
  border-radius: 0;
  overflow: hidden;
}
.tickets-sidebar {
  min-width: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}
.tickets-sidebar-header {
  border-bottom: 1px solid var(--border);
}
.tickets-header-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  gap: 8px;
}
.tickets-header-toggle:hover {
  background: var(--surface-alt);
}
.tickets-header-toggle .section-title {
  margin: 0;
}
.tickets-collapse-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.tickets-header-toggle[aria-expanded="false"] .tickets-collapse-icon {
  transform: rotate(180deg);
}
.tickets-header-body {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.2s ease;
  max-height: 400px;
  opacity: 1;
}
.tickets-header-body.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}
#tickets-filter-bar {
  transition: max-height 0.25s ease, opacity 0.2s ease;
}
#tickets-filter-bar.collapsed {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0;
  border: none;
}
.ticket-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.ticket-stat-tile {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 11px;
}
.ticket-stat-tile .stat-label {
  margin-bottom: 6px;
  font-size: 10px;
}
.ticket-stat-tile .stat-value {
  font-size: 22px;
}
.ticket-filter-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.ticket-detail-pane {
  min-width: 0;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg);
}
.ticket-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.ticket-detail-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
  overflow-wrap: anywhere;
  margin: 0 0 6px;
}
.ticket-filter-sidebar {
  position: sticky;
  top: 18px;
  border-right: 1px solid var(--border);
  padding: 2px 18px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ticket-sidebar-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.ticket-filter-group { display: flex; flex-direction: column; gap: 6px; }
.ticket-workboard { min-width: 0; }
.ticket-list   { display: flex; flex-direction: column; gap: 0; overflow-y: auto; min-height: 0; }
.ticket-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 14px 16px;
  background: var(--surface);
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: none;
  transition: background var(--transition), border-color var(--transition);
  position: relative;
}
.ticket-item:hover { background: var(--surface-alt); }
.ticket-item.active { background: var(--indigo-light); }
.ticket-item.is-new { border-left: 3px solid rgba(239,68,68,.7); padding-left: 13px; }
.ticket-item.is-claimed { border-left: 3px solid var(--indigo); }
.ticket-item.is-archived { opacity: .72; }
.ticket-item.is-new.is-claimed { border-left-color: var(--indigo); }
.ticket-topline  { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.ticket-title-row { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.ticket-title    { font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 5px; line-height: 1.35; overflow-wrap: anywhere; }
.ticket-new-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(239,68,68,.12);
  flex-shrink: 0;
  margin-top: 5px;
}
.ticket-meta     { font-size: 11.5px; color: var(--text-muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ticket-badges   { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.ticket-owner-pill { display: inline-flex; align-items: center; border-radius: var(--r-full); padding: 3px 10px; font-size: 10px; font-weight: 800; background: #ecfdf5; color: #065f46; white-space: nowrap; }
.ticket-source   { display: inline-flex; align-items: center; gap: 4px; border-radius: var(--r-full); padding: 3px 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; }
.ticket-source.whatsapp { background: #dcfce7; color: #14532d; }
.ticket-source.email    { background: var(--indigo-subtle); color: #3730a3; }
.ticket-source.other    { background: var(--purple-light); color: #4c1d95; }
.ticket-priority { display: inline-flex; align-items: center; border-radius: var(--r-full); padding: 3px 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.ticket-priority.high   { background: var(--red-light); color: #991b1b; }
.ticket-priority.medium { background: var(--amber-light); color: #92400e; }
.ticket-priority.low    { background: var(--indigo-light); color: #3730a3; }
.ticket-details  { font-size: 13px; line-height: 1.65; color: var(--text-secondary); white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; }

/* ── Order CTA ─────────────────────────────────── */
.ticket-order-cta {
  display: flex;
  justify-content: flex-start;
}
.btn-order {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--r);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  background: #0d9488;
  color: #fff;
  transition: background 0.15s;
}
.btn-order:hover:not(:disabled) { background: #0f766e; }
.btn-order:disabled { opacity: .5; cursor: not-allowed; }

/* ── Conversation thread ───────────────────────── */
.ticket-conversation {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg-row {
  display: flex;
}
.msg-inbound { justify-content: flex-start; }
.msg-outbound { justify-content: flex-end; }

.msg-bubble {
  max-width: 80%;
  min-width: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}
.msg-inbound .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-left-radius: 3px;
  color: var(--text);
}
.msg-outbound .msg-bubble {
  background: var(--indigo);
  color: #fff;
  border-top-right-radius: 3px;
}
.msg-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 5px;
}
.msg-sender {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  opacity: .75;
}
.msg-time {
  font-size: 10px;
  opacity: .55;
}
.msg-body { white-space: pre-wrap; }
.msg-quote-toggle {
  margin-top: 6px;
  font-size: 11px;
  opacity: .6;
  cursor: pointer;
}
.msg-quote-toggle summary { list-style: none; cursor: pointer; }
.msg-quote-toggle summary::before { content: '▸ '; }
.msg-quote-toggle[open] summary::before { content: '▾ '; }
.msg-quote {
  margin-top: 6px;
  padding: 8px 10px;
  border-left: 3px solid currentColor;
  opacity: .55;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg-img { max-width: 180px; max-height: 140px; border-radius: 6px; object-fit: cover; display: block; }
.msg-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  background: rgba(0,0,0,.06);
  text-decoration: none;
  color: inherit;
}
.msg-outbound .msg-file { background: rgba(255,255,255,.18); color: #fff; }
.ticket-actions  { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; padding-top: 4px; }
.ticket-action-left { display: flex; gap: 9px; flex-wrap: wrap; align-items: flex-end; }
.ticket-status-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 4px 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}
.ticket-status-control span { white-space: nowrap; }
.ticket-status-select {
  width: auto;
  min-width: 150px;
  height: 30px;
  padding: 4px 28px 4px 10px;
  border: 0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: none;
}
.ticket-status-select:focus { box-shadow: 0 0 0 3px rgba(99,102,241,.13); }
.ticket-status-new { background: var(--red-light); color: #991b1b; }
.ticket-status-in_progress { background: var(--indigo-light); color: #3730a3; }
.ticket-status-waiting_customer { background: var(--amber-light); color: #92400e; }
.ticket-status-done { background: #ecfdf5; color: #065f46; }
.ticket-claim-btn,
.ticket-detail-toggle {
  min-height: 34px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.ticket-claim-btn:hover,
.ticket-detail-toggle:hover { border-color: var(--indigo); background: var(--indigo-light); color: var(--indigo-dark); }
.ticket-claim-btn.is-mine { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.ticket-claimed-lock {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  color: var(--text-muted);
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 700;
}
.ticket-collapse { display: flex; flex-direction: column; gap: 10px; }
.ticket-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ticket-attachment-thumb {
  width: 96px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-alt);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 10.5px;
}
.ticket-attachment-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--surface);
}
.ticket-attachment-thumb span {
  display: block;
  padding: 5px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticket-attachment-file {
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ticket-empty { padding: 40px 24px; text-align: center; color: var(--text-muted); border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-alt); font-size: 13px; }
.ticket-intro { font-size: 12px; color: var(--text-light); line-height: 1.6; max-width: 640px; }
.ticket-form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.ticket-ai-preview,
.ticket-ai-box {
  border: 1.5px solid var(--indigo-subtle);
  border-radius: var(--r);
  background: var(--indigo-light);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ticket-ai-box { margin: 10px 0; background: var(--surface-alt); border-color: var(--border); }
.ticket-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--indigo-dark);
}
.ticket-ai-summary { font-size: 12.5px; color: var(--text-secondary); line-height: 1.55; }
.ticket-ai-action { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.45; }
.ticket-ai-review {
  border: 1px solid rgba(245,158,11,.35);
  background: var(--amber-light);
  color: var(--amber-dark);
  border-radius: var(--r-sm);
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.4;
}
.ticket-faq-hits {
  font-size: 11.5px;
  color: var(--text-light);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 9px;
  line-height: 1.45;
}
.ticket-ai-checklist { margin-left: 18px; color: var(--text-secondary); font-size: 12.5px; line-height: 1.6; }
.ticket-reply-draft {
  border-left: 3px solid var(--indigo);
  padding-left: 10px;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.ticket-ai-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}
.ticket-empty.compact { padding: 16px 12px; font-size: 12px; }

/* ── n8n-style settings ─────────────────────────────── */
.settings-main {
  max-width: 740px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px 20px 48px;
}

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.settings-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.settings-section-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  background: var(--indigo-dim);
  border: 1px solid var(--indigo-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--indigo);
  flex-shrink: 0;
}

.settings-section-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.settings-section-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.settings-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.settings-status-dot.ok   { background: #10b981; box-shadow: 0 0 0 2px rgba(16,185,129,.2); }
.settings-status-dot.warn { background: #f59e0b; box-shadow: 0 0 0 2px rgba(245,158,11,.2); }

.settings-rows { display: flex; flex-direction: column; }

.settings-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  min-height: 38px;
}
.settings-row:last-child { border-bottom: 0; }

.settings-row-label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 140px;
  flex-shrink: 0;
}

.settings-row-value {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.settings-code-val {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 10.5px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  line-height: 1.5;
}

.settings-copy-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .12s, color .12s, border-color .12s;
  padding: 0;
}
.settings-copy-btn:hover {
  background: var(--indigo-dim);
  color: var(--indigo);
  border-color: var(--indigo-subtle);
}

.provider-order {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.provider-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 20px;
  background: var(--indigo-dim);
  color: var(--indigo);
  border: 1px solid var(--indigo-subtle);
  line-height: 1.8;
}

.settings-actions-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
}

.settings-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
  line-height: 1.8;
}
.settings-badge.warn {
  background: rgba(245,158,11,.12);
  color: #b45309;
  border: 1px solid rgba(245,158,11,.3);
}
.settings-badge.ok {
  background: rgba(16,185,129,.1);
  color: #059669;
  border: 1px solid rgba(16,185,129,.25);
}

.settings-row-value input[type="text"],
.settings-row-value input[type="password"],
.settings-row-value input[type="number"] {
  font-size: 12.5px;
  padding: 5px 8px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.settings-row-value input[type="text"]:focus,
.settings-row-value input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99,102,241,.15);
}

.settings-sig-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.faq-suggestions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.faq-suggestion-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.faq-suggestion-title { font-size: 13px; font-weight: 800; color: var(--text); }
.faq-suggestion-meta,
.faq-suggestion-existing,
.faq-suggestion-reason {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}
.faq-suggestion-card {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px;
  background: #fff;
}
.faq-suggestion-main { min-width: 0; }
.faq-suggestion-kind {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: var(--r-full);
  background: var(--indigo-light);
  color: var(--indigo);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 7px;
}
.faq-suggestion-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
  background: var(--surface-alt);
}
.faq-item.disabled { opacity: .55; }
.faq-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.faq-icon-btn {
  width: 32px;
  height: 32px;
  color: var(--text-muted);
}
.faq-icon-btn:hover {
  color: var(--indigo);
  background: var(--indigo-light);
}
.faq-icon-btn.danger:hover {
  color: var(--red);
  background: var(--red-light);
}
.faq-question { font-size: 12.5px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.faq-answer { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 7px; }

.ticket-modal {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15,23,42,.45);
}
.ticket-modal.open { display: flex; }
.ticket-modal-panel {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ticket-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.ticket-modal-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}
.ticket-modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.ticket-modal-body {
  padding: 18px;
  overflow-y: auto;
}
.ticket-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}
.ticket-reply-editor {
  min-height: 260px;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════
   TOGGLE BTN
═══════════════════════════════════════════════════════ */
.toggle-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px 11px;
  font-size: 11px;
  color: var(--text-light);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: border-color var(--transition), color var(--transition);
}
.toggle-btn:hover { border-color: var(--indigo); color: var(--indigo); }

/* ═══════════════════════════════════════════════════════
   COUPON PAGE
═══════════════════════════════════════════════════════ */
.coupon-type-row { display: flex; gap: 8px; flex-wrap: wrap; }
.type-btn {
  padding: 7px 16px; border: 1.5px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  font-family: inherit; color: var(--text-secondary);
}
.type-btn:hover { border-color: var(--indigo); color: var(--indigo); }
.type-btn.selected { border-color: var(--indigo); background: var(--indigo-light); color: var(--indigo-dark); }

.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; font-family: monospace; font-size: 14px; letter-spacing: 2px; text-transform: uppercase; }
.prefix-select { width: auto; flex-shrink: 0; font-weight: 700; font-family: monospace; }
.amount-btns { display: flex; gap: 8px; margin-top: 8px; }
.btn-amount {
  padding: 7px 16px; border: 1.5px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); font-size: 13px; font-weight: 700; cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  font-family: inherit; color: var(--text-secondary);
}
.btn-amount:hover { border-color: var(--indigo); color: var(--indigo); background: var(--indigo-light); }

.coupon-list-ul { list-style: none; }
.coupon-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0; border-bottom: 1px solid var(--border); gap: 12px; font-size: 13px;
}
.coupon-item:last-child { border-bottom: none; }
.coupon-code {
  font-family: monospace; font-size: 13px; font-weight: 700; letter-spacing: 1.5px;
  background: var(--surface-alt); padding: 3px 11px; border-radius: var(--r-sm);
  cursor: pointer; user-select: all; transition: background var(--transition); color: var(--text);
}
.coupon-code:hover { background: var(--surface-hover); }
.coupon-meta { color: var(--text-light); display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; }
.coupon-actions { display: flex; gap: 6px; }

/* ═══════════════════════════════════════════════════════
   CUSTOMERS PAGE
═══════════════════════════════════════════════════════ */
#customers-page { display: none; padding: 0; }
#customers-page.active { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.cust-layout { display: flex; flex: 1; height: 100%; overflow: hidden; }
.cust-sidebar { width: 272px; min-width: 220px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); overflow: hidden; }
.cust-sidebar-header { padding: 14px 14px 8px; border-bottom: 1px solid var(--border); }
.cust-search-wrap input { width: 100%; }
.cust-count-wrap { font-size: 11px; color: var(--text-muted); margin-top: 6px; min-height: 16px; }
.cust-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.cust-pagination {
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  padding: 10px;
}
.cust-page-summary {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 8px;
}
.cust-per-page {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 8px;
}
.cust-per-page select {
  width: 74px;
  min-height: 32px;
  padding: 5px 26px 5px 9px;
  font-size: 12.5px;
}
.cust-page-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.cust-page-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.cust-page-btn:hover:not(:disabled),
.cust-page-btn.active {
  border-color: var(--indigo);
  background: var(--indigo);
  color: #fff;
}
.cust-page-btn:disabled {
  cursor: not-allowed;
  opacity: .45;
}
.cust-list-empty { padding: 20px 16px; font-size: 13px; color: var(--text-muted); }
.cust-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background var(--transition); }
.cust-item:hover { background: var(--surface-alt); }
.cust-item.active { background: var(--indigo-light); border-left: 3px solid var(--indigo); padding-left: 11px; }
.cust-item-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-item-sub  { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-main { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.cust-empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-muted); font-size: 14px; }
.cust-empty-state svg { opacity: 0.25; }
.detail-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.detail-col-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--text-muted); margin-bottom: 8px; }
.detail-col > div { font-size: 13px; line-height: 1.8; color: var(--text-secondary); }

/* Team page */
#team-page { display: none; }
#team-page.active { display: block; }
.team-page-body { display: flex; flex-direction: column; gap: 14px; }
.team-toolbar { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.team-toolbar .search-wrap { flex: 1; min-width: 240px; }
.team-toolbar-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; color: var(--text-muted); font-size: 11px; min-width: 180px; }
.team-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.team-member { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); box-shadow: var(--shadow-xs); min-width: 0; }
.team-avatar { width: 38px; height: 38px; border-radius: var(--r-sm); background: var(--indigo-light); color: var(--indigo-dark); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 800; flex-shrink: 0; }
.team-member-main { flex: 1; min-width: 0; }
.team-member-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.team-member-name { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-member-user { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.team-roles { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.team-role { font-size: 10px; font-weight: 700; color: var(--green-dark); background: var(--green-light); border-radius: 4px; padding: 2px 6px; white-space: nowrap; }
.team-member-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; font-size: 12px; color: var(--text-muted); }
.team-member-meta a { color: var(--indigo); text-decoration: none; }
.team-member-meta a:hover { text-decoration: underline; }
.team-auth-empty { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════
   SIDEBAR DROPDOWN
═══════════════════════════════════════════════════════ */
#sidebar-dropdown {
  position: fixed;
  left: var(--sidebar-width);
  width: 420px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 400;
  max-height: 560px;
  overflow-y: auto;
  display: none;
  margin-left: 8px;
}
#sidebar-dropdown.open { display: block; }
.sdrop-section { padding: 8px 14px 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--text-muted); background: var(--surface-alt); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; }
.sdrop-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--surface-alt); transition: background var(--transition); display: flex; gap: 10px; align-items: flex-start; }
.sdrop-item:last-child { border-bottom: none; }
.sdrop-item:hover { background: var(--indigo-light); }
.sdrop-icon { width: 30px; height: 30px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sdrop-icon.order    { background: var(--indigo-subtle); color: var(--indigo); }
.sdrop-icon.customer { background: var(--green-light); color: var(--green-dark); }
.sdrop-primary { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 3px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; line-height: 1.3; }
.sdrop-secondary { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }
.sdrop-empty, .sdrop-loading { padding: 24px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ═══════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════ */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 18px; border-radius: var(--r-lg);
  font-size: 13.5px; font-weight: 500;
  max-width: 380px; box-shadow: var(--shadow-lg); z-index: 500;
  opacity: 0; transform: translateY(12px) scale(.97);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
#toast.success { background: #022c22; color: #6ee7b7; }
#toast.error   { background: #450a0a; color: #fca5a5; }

/* ═══════════════════════════════════════════════════════
   SPINNER + MISC
═══════════════════════════════════════════════════════ */
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .55s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.phone-row { display: flex; gap: 6px; }
.phone-row .dial-select { width: 88px; flex-shrink: 0; }
.phone-row input { flex: 1; min-width: 0; }

.postcode-row { display: flex; gap: 6px; }
.postcode-row input:first-child { flex: 1; min-width: 0; }
.postcode-row .hnr-input { width: 68px; flex-shrink: 0; }

#variation-wrap { margin-top: 12px; display: none; }

.product-row { display: flex; align-items: center; gap: 10px; }
.product-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--border); flex-shrink: 0; background: var(--surface-alt); }
.product-thumb-placeholder { width: 40px; height: 40px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface-alt); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 16px; }

.shipping-address-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }

.section-title { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -.025em; margin-bottom: 6px; line-height: 1.2; }

.order-success-banner { display: flex; align-items: center; gap: 10px; padding: 11px 20px; background: #ecfdf5; border-bottom: 1px solid #6ee7b7; font-size: 13px; color: var(--text); position: sticky; top: 0; z-index: 10; }
.osb-check { font-size: 15px; font-weight: 700; color: var(--green); flex-shrink: 0; }
.osb-text  { flex: 1; }
.osb-open  { font-size: 12px; font-weight: 600; padding: 4px 12px; background: var(--green); color: #fff; border: none; border-radius: var(--r-sm); cursor: pointer; }
.osb-open:hover { opacity: .88; }
.osb-close { background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; color: var(--text-muted); padding: 0 2px; flex-shrink: 0; }
.osb-close:hover { color: var(--text); }
.order-success-banner.osb-quote { background: var(--amber-light); border-bottom-color: #fcd34d; }
.osb-quote .osb-check { color: var(--amber-dark); }
.osb-quote .osb-open  { background: var(--amber-dark); }
.osb-paylink { display: flex; align-items: center; gap: 6px; padding: 6px 12px 8px; border-top: 1px solid rgba(0,0,0,.07); margin-top: 4px; }
.osb-paylink-label { font-size: 12px; font-weight: 600; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.osb-paylink-input { flex: 1; font-size: 12px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg); color: var(--text); cursor: pointer; min-width: 0; }
.osb-paylink-input:focus { outline: none; border-color: var(--indigo); }
.osb-paylink-copy { background: none; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 4px 7px; cursor: pointer; display: flex; align-items: center; color: var(--text-muted); flex-shrink: 0; }
.osb-paylink-copy:hover { background: var(--bg-hover); color: var(--text); }
.osb-paylink-copy svg { width: 14px; height: 14px; }

.vat-field-wrap { display: flex; align-items: center; gap: 8px; }
.vat-field-wrap input { flex: 1; }
.vat-check-icon { width: 20px; text-align: center; font-size: 14px; font-weight: 700; flex-shrink: 0; line-height: 1; }
.vat-check-icon.vat-valid   { color: var(--green); }
.vat-check-icon.vat-invalid { color: var(--red); }
.vat-check-icon.vat-warn    { color: var(--amber); font-size: 12px; }
.vat-check-icon.vat-loading::after { content: ''; display: inline-block; width: 13px; height: 13px; border: 2px solid var(--border); border-top-color: var(--indigo); border-radius: 50%; animation: spin .65s linear infinite; }
.vat-fill-hint { margin-top: 7px; font-size: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vat-hint-name  { color: var(--text-muted); }
.vat-hint-valid { color: var(--green); font-weight: 600; }
.vat-hint-done  { color: var(--green); font-weight: 600; }
.vat-hint-warn  { color: var(--amber); font-weight: 500; }
.vat-fill-btn { font-size: 11px; font-weight: 600; padding: 3px 10px; background: var(--indigo); color: #fff; border: none; border-radius: 4px; cursor: pointer; line-height: 1.5; }
.vat-fill-btn:hover { background: var(--indigo-dark); }
.vat-row { color: var(--text-muted); font-size: 13px; }
.vat-badge { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .03em; padding: 1px 5px; border-radius: 3px; background: var(--indigo-light); color: var(--indigo-dark); vertical-align: middle; margin-left: 4px; }

.note-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.note-item:last-child { border-bottom: none; }
.note-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.note-type { font-size: 11px; font-weight: 600; }
.note-type.customer { color: var(--indigo); }
.note-type.internal { color: var(--text-muted); }
.note-date { font-size: 11px; color: var(--text-muted); }
.note-body { font-size: 13px; color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════
   CUSTOMERS DETAIL
═══════════════════════════════════════════════════════ */
.cust-detail-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.cust-detail-name    { font-size: 20px; font-weight: 700; color: var(--text); }
.cust-detail-company { font-size: 14px; color: var(--text-muted); margin-top: 2px; }
.cust-detail-id      { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.cust-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.cust-info-col { font-size: 13px; line-height: 1.6; }
.cust-stats-row { display: flex; gap: 12px; flex-wrap: wrap; }
.cust-stat-tile { flex: 1; min-width: 120px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 18px; }
.cust-stat-tile .stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.cust-stat-tile .stat-value { font-size: 26px; font-weight: 700; color: var(--text); margin-top: 4px; }
.cust-order-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--transition); gap: 12px; }
.cust-order-row:last-child { border-bottom: none; }
.cust-order-row:hover { background: var(--surface-alt); }
.cust-order-left  { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.cust-order-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.cust-order-num   { font-weight: 600; font-size: 13px; color: var(--text); }
.cust-order-items { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.cust-order-total { font-size: 13px; font-weight: 600; }
.cust-order-date  { font-size: 12px; color: var(--text-muted); }
.cust-no-orders   { padding: 20px 16px; font-size: 13px; color: var(--text-muted); }

.orders-detail-view { }
.detail-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 680px) { .detail-cols { grid-template-columns: 1fr; } }

/* ═══════════════════════════════════════════════════════
   TWEAKS PANEL
═══════════════════════════════════════════════════════ */
#tweaks-panel {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 260px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  z-index: 600;
  padding: 18px;
  font-size: 13px;
}
#tweaks-panel.open { display: block; }
.tweaks-title { font-weight: 700; font-size: 13px; color: var(--text); margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.tweaks-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-muted); padding: 0; line-height: 1; }
.tweaks-close:hover { color: var(--text); }
.tweak-row { margin-bottom: 14px; }
.tweak-row label { font-size: 11px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; display: block; text-transform: uppercase; letter-spacing: .05em; }
.tweak-options { display: flex; gap: 6px; flex-wrap: wrap; }
.tweak-opt {
  padding: 5px 12px; border: 1.5px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); font-size: 11.5px; font-weight: 600; cursor: pointer;
  font-family: inherit; color: var(--text-secondary); transition: all var(--transition);
}
.tweak-opt.active { border-color: var(--indigo); background: var(--indigo-light); color: var(--indigo-dark); }

/* ═══════════════════════════════════════════════════════
   DARK MODE
═══════════════════════════════════════════════════════ */
body.dark {
  --text:           #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-light:     #94a3b8;
  --text-muted:     #64748b;
  --border:         #1e293b;
  --border-strong:  #334155;
  --surface:        #0f172a;
  --surface-alt:    #1e293b;
  --surface-hover:  #273548;
  --bg:             #080d14;
  --indigo-light:   rgba(99,102,241,.15);
  --indigo-subtle:  rgba(99,102,241,.2);
  --green-light:    rgba(16,185,129,.15);
  --red-light:      rgba(239,68,68,.15);
  --amber-light:    rgba(245,158,11,.15);
  --purple-light:   rgba(139,92,246,.15);
}

body.dark .card { border-color: var(--border); }
body.dark input[type=text], body.dark input[type=email], body.dark input[type=tel],
body.dark input[type=number], body.dark input[type=date], body.dark select, body.dark textarea {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border);
}
body.dark input::placeholder, body.dark textarea::placeholder { color: #334155; }
body.dark .btn-secondary { background: var(--surface-alt); border-color: var(--border); color: var(--text-secondary); }
body.dark .btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }
body.dark .toggle-btn { background: var(--surface-alt); border-color: var(--border); color: var(--text-muted); }
body.dark .collapsible-card-header { background: var(--surface); border-bottom-color: var(--border); color: var(--text); }
body.dark .collapsible-card-header:hover { background: var(--surface-alt); }
body.dark .collapse-arrow { border-color: var(--border); color: var(--text-muted); }
body.dark .coupon-apply-panel { background: var(--surface-alt); border-color: var(--border); }
body.dark .coupon-inline-divider { background: var(--border); }
body.dark .tweak-opt { background: var(--surface-alt); border-color: var(--border); color: var(--text-secondary); }
body.dark .tweak-opt.active { border-color: var(--indigo); background: var(--indigo-light); color: #a5b4fc; }
body.dark #tweaks-panel { background: var(--surface); border-color: var(--border); }
body.dark .dropdown { background: var(--surface); border-color: var(--border); }
body.dark .dropdown-item:hover { background: var(--surface-alt); }
body.dark .items-table th { background: var(--surface-alt); border-bottom-color: var(--border); }
body.dark .items-table td { border-bottom-color: var(--border); }
body.dark .items-table tbody tr:hover td { background: var(--surface-alt); }
body.dark .empty-items { background: var(--surface-alt); border-color: var(--border-strong); }
body.dark .od-section { border-bottom-color: var(--border); }
body.dark .shipping-preset-btn { background: var(--surface-alt); border-color: var(--border-strong); }
body.dark .shipping-preset-btn:hover,
body.dark .shipping-preset-btn.selected { background: var(--indigo-dim); border-color: var(--indigo); }
body.dark .od-paid-row { background: var(--surface-alt); border-color: var(--border); }
body.dark .order-search-row:hover { background: var(--surface-alt); }
body.dark .stat-tile { background: var(--surface); border-color: var(--border); }
body.dark .ticket-item { background: var(--surface); border-color: var(--border); }
body.dark .ticket-item:hover,
body.dark .ticket-item.active { background: var(--surface-alt); }
body.dark .ticket-detail-pane { background: var(--bg); }
body.dark .ticket-filter-sidebar { border-right-color: var(--border); }
body.dark .ticket-status-control,
body.dark .ticket-claimed-lock { background: var(--surface-alt); border-color: var(--border); }
body.dark .ticket-claim-btn,
body.dark .ticket-detail-toggle { background: var(--surface-alt); border-color: var(--border); color: var(--text); }
body.dark .ticket-status-done,
body.dark .ticket-owner-pill,
body.dark .ticket-claim-btn.is-mine { background: rgba(16,185,129,.15); border-color: rgba(16,185,129,.3); color: #6ee7b7; }
body.dark .ticket-empty { background: var(--surface-alt); border-color: var(--border-strong); }
body.dark .ticket-faq-hits,
body.dark .faq-item,
body.dark .settings-section-header { background: var(--surface-alt); }
body.dark .settings-code-val       { background: #1a2133; color: #94a3b8; }
body.dark .settings-copy-btn       { background: var(--surface-alt); }
body.dark .settings-section-icon   { background: rgba(99,102,241,.15); border-color: rgba(99,102,241,.25); }
body.dark
body.dark .ticket-modal-panel,
body.dark .ticket-attachment-thumb,
body.dark .ticket-attachment-file { background: var(--surface-alt); border-color: var(--border); }
body.dark .ticket-modal-actions { background: var(--surface); border-color: var(--border); }
body.dark .cust-sidebar { background: var(--surface); border-right-color: var(--border); }
body.dark .cust-item:hover { background: var(--surface-alt); }
body.dark .cust-item.active { background: var(--indigo-light); border-left-color: var(--indigo); }
body.dark #customer-selected { background: var(--indigo-light); border-color: var(--indigo-subtle); }
body.dark #customer-selected .cs-name { color: #a5b4fc; }
body.dark .totals-row { border-bottom-color: var(--border); color: var(--text-secondary); }
body.dark .totals-row.total { border-top-color: var(--border-strong); color: var(--text); }
body.dark #sidebar-dropdown { background: var(--surface); border-color: var(--border); }
body.dark .sdrop-section { background: var(--surface-alt); border-bottom-color: var(--border); }
body.dark .sdrop-item { border-bottom-color: var(--surface-alt); }
body.dark .sdrop-item:hover { background: var(--indigo-light); }
body.dark .status-processing { background: rgba(99,102,241,.15); border-color: rgba(99,102,241,.3); color: #a5b4fc; }
body.dark .status-completed  { background: rgba(16,185,129,.15); border-color: rgba(16,185,129,.3); color: #6ee7b7; }
body.dark .status-pending    { background: rgba(245,158,11,.15); border-color: rgba(245,158,11,.3); color: #fcd34d; }
body.dark .status-cancelled  { background: rgba(239,68,68,.15);  border-color: rgba(239,68,68,.3);  color: #fca5a5; }
body.dark .status-on-hold    { background: var(--surface-alt);   border-color: var(--border);       color: #64748b; }

/* Dark + light sidebar */
body.dark.theme-light-sidebar header {
  background: #0f172a;
  border-right-color: #1e293b;
}
body.dark.theme-light-sidebar header h1 { color: #f1f5f9; }
body.dark.theme-light-sidebar .brand-subtitle { color: #475569; }
body.dark.theme-light-sidebar .nav-btn { color: #94a3b8; }
body.dark.theme-light-sidebar .nav-btn:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
body.dark.theme-light-sidebar .nav-btn.active { background: var(--indigo-dim); color: #a5b4fc; }
body.dark.theme-light-sidebar .nav-label { color: #374151; }
body.dark.theme-light-sidebar .sidebar-footer { border-top-color: #1e293b; }
body.dark.theme-light-sidebar #status-dot { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.06); color: #475569; }
body.dark.theme-light-sidebar .sidebar-search { border-bottom-color: #1e293b; }
body.dark.theme-light-sidebar .sidebar-search-wrap input { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.07); color: #e2e8f0; }
body.dark.theme-light-sidebar .sidebar-header { border-bottom-color: #1e293b; }
body.dark.theme-light-sidebar .brand-mark { border-color: #1e293b; }

/* Dark mode toggle button */
.dark-mode-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: none;
  border: none;
  font-size: .8rem;
  font-weight: 500;
  color: var(--sb-text);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 4px;
  box-sizing: border-box;
}
body.theme-light-sidebar .dark-mode-btn { border-color: var(--border); color: var(--text-muted); }
body.theme-light-sidebar .dark-mode-btn:hover { background: var(--surface-alt); border-color: var(--border-strong); color: var(--text); }
body.dark.theme-light-sidebar .dark-mode-btn { border-color: #1e293b; color: #475569; }
body.dark.theme-light-sidebar .dark-mode-btn:hover { background: rgba(255,255,255,.05); border-color: #334155; color: #94a3b8; }
.dark-mode-btn:hover { background: var(--sb-hover); border-color: rgba(255,255,255,.12); color: #9ca3af; }

/* ══════════════════════════════════════════════════════
   CHAT WIDGET
══════════════════════════════════════════════════════ */

/* Floating action button */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 600;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #059669;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(5,150,105,.4);
  transition: background .15s, transform .15s, box-shadow .15s;
}
.chat-fab:hover  { background: #047857; box-shadow: 0 6px 24px rgba(5,150,105,.5); transform: translateY(-2px); }
.chat-fab:active { transform: scale(.93); }
body.chat-open .chat-fab { background: #047857; }

.chat-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* Panel */
.chat-panel {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 360px;
  height: 520px;
  z-index: 590;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(.88) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform .2s cubic-bezier(.34,1.3,.64,1), opacity .18s ease;
}
body.chat-open .chat-panel {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
.chat-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.chat-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
  margin-right: 4px;
}
.chat-panel-title svg { color: var(--indigo); }

.chat-online-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--r-full);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #15803d;
  cursor: pointer;
  font-family: inherit;
  transition: background .13s;
  flex: 1;
}
.chat-online-pill:hover { background: #dcfce7; }
body.dark .chat-online-pill { background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.2); color: #34d399; }
.chat-online-dot-live {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse-green 2s infinite;
  flex-shrink: 0;
}
@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,.4); }
  50% { box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}

.chat-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--r-sm);
  transition: color .13s, background .13s;
  flex-shrink: 0;
}
.chat-close-btn:hover { color: var(--text); background: var(--surface-hover); }

/* Online dropdown */
.chat-online-dropdown {
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  flex-shrink: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height .2s ease;
}
.chat-online-dropdown.open { max-height: 180px; overflow-y: auto; }
.chat-online-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.chat-online-row:last-child { border-bottom: none; }
.chat-online-row-name { flex: 1; font-size: 12.5px; font-weight: 600; color: var(--text); }
.chat-online-row-sub  { font-size: 11px; color: var(--text-muted); }
.chat-dm-btn {
  background: var(--indigo-light);
  border: 1px solid var(--indigo-subtle);
  color: var(--indigo-dark);
  border-radius: var(--r-sm);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .13s;
  white-space: nowrap;
}
.chat-dm-btn:hover { background: var(--indigo-subtle); }

/* Conversation tabs */
.chat-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 10px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.chat-tabs::-webkit-scrollbar { display: none; }
.chat-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 5px 10px 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: color .13s, border-color .13s;
  position: relative;
  flex-shrink: 0;
}
.chat-tab:hover { color: var(--text); }
.chat-tab.active { color: var(--indigo); border-bottom-color: var(--indigo); }
.chat-tab-badge {
  position: absolute;
  top: 2px; right: 2px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  display: none;
}
.chat-tab-badge.show { display: block; }

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  scroll-behavior: smooth;
}
.chat-empty {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  margin: auto;
  line-height: 1.7;
}
.chat-msg { display: flex; flex-direction: column; gap: 2px; padding: 4px 0; }
.chat-msg-mine { align-items: flex-end; }
.chat-msg-header { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); }
.chat-msg-mine .chat-msg-header { flex-direction: row-reverse; }
.chat-msg-avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 800; color: #fff; flex-shrink: 0;
}
.chat-msg-name  { font-weight: 600; color: var(--text-secondary); }
.chat-msg-time  { font-size: 10px; }
.chat-msg-bubble {
  max-width: 84%;
  padding: 7px 11px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  word-break: break-word;
}
.chat-msg-mine .chat-msg-bubble { background: var(--indigo); border-color: var(--indigo-dark); color: #fff; }
.chat-day-sep {
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; color: var(--text-muted); font-weight: 600;
  margin: 6px 0 2px;
}
.chat-day-sep::before, .chat-day-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Input */
.chat-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-row input {
  flex: 1; padding: 8px 12px;
  border: 1.5px solid var(--border); border-radius: var(--r-full);
  font-size: 13px; font-family: inherit;
  background: var(--surface-alt); color: var(--text);
  outline: none; transition: border-color .15s;
}
.chat-input-row input:focus { border-color: var(--indigo); background: var(--surface); }
.chat-input-row input::placeholder { color: var(--text-muted); }
.chat-send-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--indigo); border: none; color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, transform .1s;
}
.chat-send-btn:hover  { background: var(--indigo-dark); }
.chat-send-btn:active { transform: scale(.93); }

@media (max-width: 768px) {
  .chat-fab  { bottom: 16px; right: 16px; }
  .chat-panel {
    bottom: 80px; right: 12px; left: 12px;
    width: auto; height: 65vh;
    border-radius: 14px;
  }
}

/* ═══════════════════════════════════════════════════════
   ORDER DETAIL
═══════════════════════════════════════════════════════ */
.od2-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.od2-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  margin-bottom: 10px;
  transition: color var(--transition);
}
.od2-back:hover { color: var(--indigo); }
.od2-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.od2-title { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.03em; }
.od2-meta  { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.od2-actions { display: flex; align-items: center; gap: 8px; }
.od2-status-select {
  padding: 7px 28px 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--surface);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--transition);
}
.od2-status-select:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }

/* Info card grid */
.od2-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 700px) { .od2-grid { grid-template-columns: 1fr; } }

.od2-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
body.dark .od2-card { background: var(--surface); border-color: var(--border); }

.od2-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.od2-card-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.od2-card-icon.indigo { background: var(--indigo-light); color: var(--indigo); }
.od2-card-icon.green  { background: var(--green-light);  color: var(--green-dark); }
.od2-card-icon.amber  { background: var(--amber-light);  color: var(--amber-dark); }
.od2-card-icon.slate  { background: var(--surface-alt);  color: var(--text-light); border: 1px solid var(--border); }

.od2-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}

.od2-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.od2-row:last-child { border-bottom: none; }
.od2-row-label { font-size: 10.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.od2-row-value { font-size: 13.5px; color: var(--text-secondary); font-weight: 500; }
.od2-row-value a { color: var(--indigo); text-decoration: none; }
.od2-row-value a:hover { text-decoration: underline; }
.od2-highlight { color: var(--text) !important; font-weight: 700 !important; }

/* Products table */
.od2-table-wrap {
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 14px;
}
.od2-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.od2-table thead tr { background: var(--surface-alt); }
.od2-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
.od2-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-secondary);
}
.od2-table tbody tr:last-child td { border-bottom: none; }
.od2-table tbody tr:hover td { background: var(--surface-alt); }
.od2-table .product-cell { display: flex; align-items: center; gap: 12px; }
.od2-table .product-img {
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  flex-shrink: 0;
  object-fit: cover;
}
.od2-table .product-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}
.od2-table .product-name { font-weight: 600; color: var(--text); font-size: 13.5px; }
.od2-table .product-sku  { font-size: 11px; color: var(--text-muted); margin-top: 2px; font-family: monospace; }
.od2-table tfoot td {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}
.od2-table tfoot tr:last-child td { border-bottom: none; }
.od2-table .total-row td {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  border-top: 2px solid var(--border);
  border-bottom: none;
  padding-top: 12px;
}

/* Notes */
.od2-notes-list { display: flex; flex-direction: column; gap: 0; margin-bottom: 14px; }
.od2-note {
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.od2-note:last-child { border-bottom: none; }
.od2-note-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.od2-note-type { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: var(--r-full); }
.od2-note-type.customer { background: var(--indigo-light); color: var(--indigo-dark); }
.od2-note-type.internal { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }
.od2-note-date { font-size: 11px; color: var(--text-muted); }
.od2-note-body { font-size: 13px; color: var(--text-secondary); line-height: 1.55; }
.od2-add-note { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.od2-add-note-input { flex: 1; }

/* ── ALTERNATE THEMES ─────────────────────────── */
body.theme-light-sidebar header {
  background: #ffffff;
  border-right: 1px solid var(--border);
  box-shadow: 1px 0 0 var(--border);
}
body.theme-light-sidebar .sidebar-header { border-bottom-color: var(--border); }
body.theme-light-sidebar .sidebar-search { border-bottom-color: var(--border); }
body.theme-light-sidebar header h1 { color: var(--text); }
body.theme-light-sidebar .brand-subtitle { color: var(--text-muted); }
body.theme-light-sidebar nav .nav-btn { color: var(--text-light); }
body.theme-light-sidebar nav .nav-btn:hover { background: var(--surface-alt); color: var(--text); }
body.theme-light-sidebar nav .nav-btn.active { background: var(--indigo-light); color: var(--indigo-dark); }
body.theme-light-sidebar .nav-label { color: var(--text-muted); }
body.theme-light-sidebar .sidebar-footer { border-top-color: var(--border); }
body.theme-light-sidebar #status-dot { color: var(--text-muted); background: var(--surface-alt); border-color: var(--border); }
body.theme-light-sidebar .sidebar-search-wrap input { background: var(--surface-alt); border-color: var(--border); color: var(--text); }
body.theme-light-sidebar .sidebar-search-wrap input::placeholder { color: var(--text-muted); }
body.theme-light-sidebar .brand-mark { box-shadow: var(--shadow-xs); border: 1px solid var(--border); }
body.theme-light-sidebar #sidebar-dropdown { left: var(--sidebar-width); }

body.accent-teal   { --indigo: #0d9488; --indigo-dark: #0f766e; --indigo-light: #f0fdfa; --indigo-subtle: #ccfbf1; --indigo-dim: rgba(13,148,136,.1); }
body.accent-violet { --indigo: #7c3aed; --indigo-dark: #6d28d9; --indigo-light: #f5f3ff; --indigo-subtle: #ede9fe; --indigo-dim: rgba(124,58,237,.1); }
body.accent-rose   { --indigo: #e11d48; --indigo-dark: #be123c; --indigo-light: #fff1f2; --indigo-subtle: #ffe4e6; --indigo-dim: rgba(225,29,72,.1); }

body.density-compact main { gap: 10px; padding: 10px 10px 48px; }
body.density-compact .card-header { padding: 10px 16px; }
body.density-compact .card-body   { padding: 16px; }
body.density-compact .field-group { margin-bottom: 10px; }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════ */
/* Mobile topbar + close btn: hidden on desktop */
.mobile-topbar { display: none; }
.nav-close-btn  { display: none; }

@media (max-width: 768px) {
  /* ── Mobile topbar ── */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    z-index: 200;
    background: var(--sb-bg);
    border-bottom: 1px solid var(--sb-border);
    padding: 0 16px;
  }
  body.theme-light-sidebar .mobile-topbar {
    background: #fff;
    border-bottom-color: var(--border);
  }
  .mobile-brand-name {
    flex: 1;
    font-size: 13px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -.01em;
  }
  body.theme-light-sidebar .mobile-brand-name { color: var(--text); }
  .hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--sb-text);
    padding: 6px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
  }
  body.theme-light-sidebar .hamburger-btn { color: var(--text-light); }
  .hamburger-btn:hover { background: var(--sb-hover); }

  /* ── Drawer ── */
  header {
    position: fixed;
    inset: 0 auto 0 0;
    width: 272px;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform .24s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
    padding-bottom: 24px;
  }
  body.nav-open header { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.35); }

  /* Close button inside drawer */
  .nav-close-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--sb-text);
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    padding: 14px 16px 10px;
    width: 100%;
    text-align: left;
    border-bottom: 1px solid var(--sb-border);
    margin-bottom: 4px;
    transition: color var(--transition);
  }
  .nav-close-btn:hover { color: #e2e8f0; }

  /* Backdrop */
  #nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  body.nav-open #nav-backdrop { display: block; }

  /* Page layout */
  .page { margin-left: 0; padding-top: 52px; }
  main  { padding: 20px 16px 48px; }
  #tickets-page { padding: 52px 0 0; }
  .tickets-split {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 52px);
  }
  .tickets-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: none;
  }
  .ticket-detail-pane { min-height: 360px; padding: 14px; }

  /* Dropdown search: full width on mobile */
  #sidebar-dropdown { left: 0 !important; right: 0; width: auto; }

  /* Content grids */
  .stats-grid        { grid-template-columns: repeat(2, 1fr); }
  .ticket-layout     { grid-template-columns: 1fr; }
  .ticket-filter-sidebar { position: static; border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 14px; }
  .settings-main       { padding: 16px 12px 48px; }
  .settings-row-label  { min-width: 100px; }
  .settings-row        { flex-wrap: wrap; gap: 6px; }
}

@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .code-row, .amount-btns, .coupon-type-row { flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr; }
  main { padding: 14px 12px 40px; gap: 12px; }
  .card-body { padding: 14px; }
}

/* ═══════════════════════════════════════════════════════
   AUTH GATING — hide the entire app until authenticated
═══════════════════════════════════════════════════════ */
body:not(.auth-ready) > header,
body:not(.auth-ready) > main,
body:not(.auth-ready) #sidebar-dropdown,
body:not(.auth-ready) #ticket-reply-modal { display: none !important; }

#login-page { display: none; }
body:not(.auth-ready) #login-page { display: flex; }

/* ═══════════════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════════════ */
.lp-page {
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  background: #f5f5f0;
  padding: 24px;
}

.lp-card {
  background: #fff;
  border-radius: 20px;
  padding: 36px 36px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 32px 80px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.05);
}

/* Brand row */
.lp-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f1f5f9;
}
.lp-logo {
  width: 32px;
  height: 32px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  overflow: hidden;
}
.lp-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lp-brand-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -.02em;
}

/* Heading */
.lp-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -.03em;
  margin-bottom: 6px;
  line-height: 1.2;
}
.lp-sub {
  font-size: .82rem;
  color: #64748b;
  margin-bottom: 26px;
  line-height: 1.5;
}

/* Fields */
.lp-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.lp-field label {
  font-size: .76rem;
  font-weight: 600;
  color: #475569;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.lp-field input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: #0f172a;
  background: #f8fafc;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.lp-field input::placeholder { color: #94a3b8; font-size: 13px; }
.lp-field input:focus {
  border-color: #6366f1;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99,102,241,.13);
}

/* Error */
.lp-error {
  font-size: .82rem;
  color: #ef4444;
  font-weight: 500;
  min-height: 1em;
  margin-bottom: 12px;
  line-height: 1.4;
}

/* Submit button */
.lp-btn {
  width: 100%;
  padding: 11px 20px;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: -.01em;
  transition: background .15s, box-shadow .15s, transform .1s;
  box-shadow: 0 2px 10px rgba(99,102,241,.38);
  margin-bottom: 22px;
}
.lp-btn:hover:not(:disabled) {
  background: #4f46e5;
  box-shadow: 0 4px 18px rgba(99,102,241,.48);
}
.lp-btn:active:not(:disabled) { transform: translateY(1px); }
.lp-btn:disabled { opacity: .55; cursor: not-allowed; }

/* Hint footer */
.lp-hint {
  font-size: .76rem;
  color: #94a3b8;
  line-height: 1.7;
  text-align: center;
  border-top: 1px solid #f1f5f9;
  padding-top: 18px;
}
.lp-hint strong { color: #64748b; font-weight: 600; }

@media (max-width: 480px) {
  .lp-card { padding: 28px 22px 22px; border-radius: 16px; }
  .lp-title { font-size: 1.25rem; }
}

/* ═══════════════════════════════════════════════════════
   SIDEBAR FOOTER — collapsible panel
═══════════════════════════════════════════════════════ */
.sf-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  padding: 7px 10px;
  cursor: pointer;
  color: var(--sb-text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  transition: background .15s;
  margin-bottom: 2px;
  gap: 6px;
}
.sf-toggle:hover { background: var(--sb-hover); }
.sf-toggle-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.sf-chevron {
  transition: transform .2s ease;
  flex-shrink: 0;
  opacity: .5;
}
.sf-toggle[aria-expanded="true"] .sf-chevron { transform: rotate(180deg); }

.sf-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height .25s ease;
}
.sf-panel.open { max-height: 220px; }
.sf-divider {
  height: 1px;
  background: var(--sb-border);
  margin: 4px 0;
}
body.theme-light-sidebar .sf-divider { background: var(--border); }

.sf-panel-inner {
  border-top: 1px solid var(--sb-border);
  margin-top: 4px;
  padding-top: 4px;
  padding-bottom: 4px;
}
body.theme-light-sidebar .sf-panel-inner { border-top-color: var(--border); }

/* ═══════════════════════════════════════════════════════
   STAFF CHIP (sidebar footer)
═══════════════════════════════════════════════════════ */
.staff-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  margin-top: 10px;
  margin-bottom: 4px;
  border-radius: var(--r-sm);
}
.staff-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--indigo);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
#staff-name {
  font-size: .78rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.staff-chip button {
  background: none;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--r-sm);
  color: var(--sb-text);
  font-size: .72rem;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
  margin-left: auto;
}
.staff-chip button:hover {
  background: rgba(255,255,255,.08);
  color: #f1f5f9;
}

/* ── Language toggle ──────────────────────────────── */
.lang-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
}
.lang-label {
  font-size: .8rem;
  color: var(--sb-text);
  white-space: nowrap;
}
.lang-btns {
  display: flex;
  gap: 4px;
}
.lang-btn {
  background: none;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--r-sm);
  color: var(--sb-text);
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
}
.lang-btn:hover {
  background: rgba(255,255,255,.06);
  color: #e2e8f0;
}
.lang-btn.active {
  background: var(--indigo);
  border-color: var(--indigo);
  color: #fff;
}
