/* 
 * Brand Design System v4 — Onshore Cellars
 * Single source of truth for all app branding.
 * Matches: Shopify theme, Zoho email templates, customer portal.
 * Navy + Gold palette, Open Sans UI (headings + body), Montserrat for hero/display, DM Mono for codes.
 */

:root {
  /* ═══════════════════════════════════════════════════════
     BRAND CORE — The two primary brand colors
     ═══════════════════════════════════════════════════════ */
  --brand-navy:        #011638;
  --brand-navy-light:  #0B2550;
  --brand-navy-dark:   #000E24;
  --brand-gold:        #C6904D;
  --brand-gold-light:  #D2A874;
  --brand-gold-dark:   #BD843D;
  --brand-gold-hover:  #b07d3c;

  /* ═══════════════════════════════════════════════════════
     PAGE BACKGROUNDS
     ═══════════════════════════════════════════════════════ */
  --white:             #FFFFFF;
  /* Unified to the canonical --oc-* system (one source of truth). Cooler,
     Apple-leaning neutrals; literal fallbacks keep the old look if ui-baseline
     isn't loaded. */
  --bg:                var(--oc-bg, #F6F8FB);
  --bg-soft:           var(--oc-gray-50, #F9FAFB);

  /* ═══════════════════════════════════════════════════════
     SIDEBAR / TOOLBAR
     ═══════════════════════════════════════════════════════ */
  --sidebar:           var(--brand-navy);
  --sidebar-mid:       var(--brand-navy-light);
  --sidebar-item:      rgba(255,255,255,0.06);
  --sidebar-active:    rgba(198,144,77,0.18);
  --sidebar-text:      rgba(255,255,255,0.6);
  --sidebar-active-text: var(--brand-gold-light);

  /* ═══════════════════════════════════════════════════════
     CONTENT AREA
     ═══════════════════════════════════════════════════════ */
  --border:            var(--oc-border, #E2E8F0);
  --border-soft:       var(--oc-gray-100, #F3F4F6);
  --text:              var(--oc-fg, #0B1220);
  --text-soft:         var(--oc-fg-muted, #5B6676);
  --text-muted:        var(--oc-fg-faint, #8A94A6);

  /* ═══════════════════════════════════════════════════════
     LEGACY ALIASES — backward compat, all point to brand core
     ═══════════════════════════════════════════════════════ */
  --garnet:            var(--brand-gold);
  --garnet-lt:         var(--brand-gold-light);
  --garnet-btn:        var(--brand-gold-dark);
  --amber:             var(--brand-gold);
  --amber-lt:          var(--brand-gold-light);
  --espresso:          var(--brand-navy);
  --sand:              var(--brand-gold-light);

  /* ═══════════════════════════════════════════════════════
     ACCENT COLORS
     ═══════════════════════════════════════════════════════ */
  --accent-red:        #C0392B;
  --accent-red-light:  #E74C3C;
  --accent-red-dark:   #922B21;

  --accent-green:      #15803D;
  --accent-green-light: #22C55E;
  --accent-green-dark: #166534;

  --accent-orange:     #D97706;
  --accent-orange-light: #F59E0B;
  --accent-orange-dark: #B45309;

  --accent-purple:     #6D28D9;
  --accent-purple-light: #8B5CF6;
  --accent-purple-dark: #5B21B6;

  /* === FUNCTIONAL STATUS PALETTES === */
  --overdue:           #B91C1C;
  --overdue-bg:        #FEF2F2;
  --overdue-border:    #FECACA;

  --paid-color:        #15803D;
  --paid-bg:           #F0FDF4;
  --paid-border:       #BBF7D0;

  --draft-color:       #92400E;
  --draft-bg:          #FFFBEB;
  --draft-border:      #FDE68A;

  --sent-color:        #1D4ED8;
  --sent-bg:           #EFF6FF;
  --sent-border:       #BFDBFE;

  --pending-color:     #6D28D9;
  --pending-bg:        #F5F3FF;
  --pending-border:    #DDD6FE;

  /* ═══════════════════════════════════════════════════════
     NEUTRAL GRAY SCALE
     ═══════════════════════════════════════════════════════ */
  --color-white:       #FFFFFF;
  --color-black:       #000000;
  --gray-50:           #FAFAFA;
  --gray-100:          #F2F2F2;
  --gray-200:          #E7E7E7;
  --gray-300:          #CCCCCC;
  --gray-400:          #999999;
  --gray-500:          #666666;
  --gray-600:          #555555;
  --gray-700:          #333333;
  --gray-800:          #1C1D1D;
  --gray-900:          #000000;

  /* === BACKGROUND TINTS === */
  --bg-navy-lightest:  #F8F8F8;
  --bg-gold-lightest:  #FDF8F0;
  --bg-red-lightest:   #FEF2F2;
  --bg-green-lightest: #F0FDF4;
  --bg-orange-lightest: #FFFBEB;
  --bg-purple-lightest: #F5F3FF;
  --bg-indigo-lightest: #EFF6FF;
  --bg-blue-lightest:  #EFF6FF;

  /* === STATUS BADGE COLORS === */
  --status-success-bg:   #D1FAE5;
  --status-success-text: #065F46;
  --status-danger-bg:    #FEE2E2;
  --status-danger-text:  #991B1B;
  --status-warning-bg:   #FEF3C7;
  --status-warning-text: #92400E;
  --status-info-bg:      #DBEAFE;
  --status-info-text:    #1E40AF;
  --status-purple-bg:    #EDE9FE;
  --status-purple-text:  #6D28D9;
  --status-indigo-bg:    #E0E7FF;
  --status-indigo-text:  #3730A3;

  /* === TYPOGRAPHY (from onshorecellars.com theme) === */
  --f-serif:           'Montserrat', system-ui, sans-serif;
  --f-ui:              'Open Sans', system-ui, -apple-system, sans-serif;
  --f-mono:            'DM Mono', 'SF Mono', monospace;

  /* === UI COMPONENT TOKENS — use these in all page CSS === */

  /* Buttons */
  --btn-padding:       0.5rem 1.125rem;
  --btn-padding-sm:    0.3rem 0.7rem;
  --btn-padding-xs:    0.2rem 0.5rem;
  --btn-font-size:     0.8125rem;
  --btn-font-size-sm:  0.72rem;
  --btn-font-size-xs:  0.65rem;
  --btn-font-weight:   600;
  --btn-radius:        6px;

  /* Form inputs */
  --input-padding:     0.45rem 0.7rem;
  --input-padding-sm:  0.3rem 0.5rem;
  --input-font-size:   0.8125rem;
  --input-font-size-sm: 0.75rem;
  --input-radius:      6px;
  --input-border:      1px solid var(--border);
  --input-focus-color: var(--brand-gold);
  --input-focus-shadow: 0 0 0 2px rgba(198,144,77,0.15);

  /* Product cards */
  --card-padding:      0.75rem;
  --card-radius:       8px;
  --card-border:       1px solid var(--border);
  --card-hover-shadow: 0 2px 8px rgba(0,0,0,0.08);
  --card-transition:   all 150ms ease;
  --card-img-w:        48px;
  --card-img-h:        60px;
  --card-img-radius:   6px;
  --card-name-size:    0.85rem;
  --card-meta-size:    0.7rem;
  --card-price-size:   0.8125rem;

  /* Badges */
  --badge-padding:     0.2rem 0.6rem;
  --badge-font-size:   0.6875rem;
  --badge-radius:      100px;

  /* === LAYOUT === */
  --radius-sm:         4px;
  --radius:            6px;
  --radius-md:         8px;
  --radius-lg:         10px;

  /* === SHADOWS === */
  --shadow-sm:         0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:         0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.05);
  --shadow-lg:         0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-xl:         0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);

  /* === TRANSITIONS === */
  --transition-fast:   150ms ease-in-out;
  --transition-normal: 200ms ease-in-out;
  --transition-slow:   300ms ease-in-out;

  /* === LAYOUT DIMENSIONS === */
  --header-height:     60px;

  /* === Z-INDEX HIERARCHY ===
     Toasts must sit ABOVE everything (including the mobile nav at 99999)
     so validation popups like "Vendor is required" are never hidden
     behind the shared header or other overlays. */
  --z-sticky:          50;
  --z-sidebar:         200;
  --z-dropdown:        4000;
  --z-panel:           9000;
  --z-modal:           9500;
  --z-nav-backdrop:    99998;
  --z-nav:             99999;
  --z-toast:           100000;
}

/* =====================================================
   BASE RESET
   ===================================================== */

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

html {
  overflow-x: hidden;          /* prevent horizontal scroll/slide on mobile */
}

body {
  font-family: var(--f-ui);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  background: var(--white);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;          /* prevent horizontal scroll/slide on mobile */
  overscroll-behavior-x: none; /* prevent pull-to-navigate gestures */
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--f-ui);
  letter-spacing: -0.01em;
}

/* =====================================================
   UNIFIED BUTTON SYSTEM — Gold / White
   -----------------------------------------------------
   Single source of truth for every button in the app.
   Mobile-first: compact on small screens, slightly roomier on md+.
   All legacy variants (primary/secondary/danger/etc) resolve here
   so there is ONE consistent look: brand gold bg, white text, no border.
   ===================================================== */

.oc-btn,
.btn,
.btn-primary, .btn-brand,
.btn-secondary, .btn-gold,
.btn-success, .btn-confirm,
.btn-danger, .btn-delete,
.btn-warning,
.btn-purple,
.btn-info,
.btn-outline-primary,
.btn-outline-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--brand-gold);
  color: var(--color-white);
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 0.85rem;
  min-height: 38px;
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 0.78rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(1, 22, 56, 0.08);
  transition: background var(--transition-fast),
              box-shadow var(--transition-fast),
              transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.oc-btn i,
.btn i,
.btn-primary i, .btn-brand i,
.btn-secondary i, .btn-gold i,
.btn-success i, .btn-confirm i,
.btn-danger i, .btn-delete i,
.btn-warning i,
.btn-purple i,
.btn-info i,
.btn-outline-primary i,
.btn-outline-secondary i {
  font-size: 0.85em;
  color: inherit;
}

.oc-btn:hover,
.btn:hover,
.btn-primary:hover, .btn-brand:hover,
.btn-secondary:hover, .btn-gold:hover,
.btn-success:hover, .btn-confirm:hover,
.btn-danger:hover, .btn-delete:hover,
.btn-warning:hover,
.btn-purple:hover,
.btn-info:hover,
.btn-outline-primary:hover,
.btn-outline-secondary:hover {
  background: var(--brand-gold-dark);
  color: var(--color-white);
  box-shadow: 0 2px 6px rgba(1, 22, 56, 0.14);
}

.oc-btn:active,
.btn:active,
.btn-primary:active, .btn-brand:active,
.btn-secondary:active, .btn-gold:active,
.btn-success:active, .btn-confirm:active,
.btn-danger:active, .btn-delete:active,
.btn-warning:active,
.btn-purple:active,
.btn-info:active,
.btn-outline-primary:active,
.btn-outline-secondary:active {
  background: var(--brand-gold-hover);
  transform: scale(0.97);
}

.oc-btn:disabled,
.btn:disabled,
.btn-primary:disabled, .btn-brand:disabled,
.btn-secondary:disabled, .btn-gold:disabled,
.btn-success:disabled, .btn-confirm:disabled,
.btn-danger:disabled, .btn-delete:disabled,
.btn-warning:disabled,
.btn-purple:disabled,
.btn-info:disabled,
.btn-outline-primary:disabled,
.btn-outline-secondary:disabled {
  background: var(--gray-300);
  color: var(--color-white);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Roomier on tablet / desktop */
@media (min-width: 768px) {
  .oc-btn,
  .btn,
  .btn-primary, .btn-brand,
  .btn-secondary, .btn-gold,
  .btn-success, .btn-confirm,
  .btn-danger, .btn-delete,
  .btn-warning,
  .btn-purple,
  .btn-info,
  .btn-outline-primary,
  .btn-outline-secondary {
    padding: 0.55rem 1.1rem;
    font-size: 0.82rem;
    min-height: 40px;
  }
}

/* =====================================================
   LINKS
   ===================================================== */

.link-primary {
  color: var(--garnet);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.link-primary:hover {
  color: var(--garnet-lt);
  text-decoration: underline;
}

.link-gold {
  color: var(--amber);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.link-gold:hover {
  color: var(--amber-lt);
  text-decoration: underline;
}

/* =====================================================
   BADGES & PILLS
   ===================================================== */

.badge-primary {
  background: rgba(198,144,77,0.08);
  color: var(--garnet);
  border: 1px solid rgba(198,144,77,0.2);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 600;
  display: inline-block;
}

.badge-gold {
  background: rgba(201,144,90,0.12);
  color: var(--amber);
  border: 1px solid rgba(201,144,90,0.25);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 600;
  display: inline-block;
}

.badge-success {
  background: var(--paid-bg);
  color: var(--paid-color);
  border: 1px solid var(--paid-border);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 600;
  display: inline-block;
}

.badge-danger {
  background: var(--overdue-bg);
  color: var(--overdue);
  border: 1px solid var(--overdue-border);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 600;
  display: inline-block;
}

.badge-warning {
  background: var(--draft-bg);
  color: var(--draft-color);
  border: 1px solid var(--draft-border);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 600;
  display: inline-block;
}

/* =====================================================
   STATUS TAGS (Zoho-style pill badges)
   ===================================================== */

.status-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
}

.st-overdue  { background: var(--overdue-bg); color: var(--overdue); border: 1px solid var(--overdue-border); }
.st-paid     { background: var(--paid-bg); color: var(--paid-color); border: 1px solid var(--paid-border); }
.st-draft    { background: var(--draft-bg); color: var(--draft-color); border: 1px solid var(--draft-border); }
.st-sent     { background: var(--sent-bg); color: var(--sent-color); border: 1px solid var(--sent-border); }
.st-pending  { background: var(--pending-bg); color: var(--pending-color); border: 1px solid var(--pending-border); }

/* =====================================================
   ALERTS & NOTIFICATIONS
   ===================================================== */

.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border-left: 3px solid;
  font-size: 0.8125rem;
}

.alert-info {
  background: var(--bg-soft);
  border-left-color: var(--garnet);
  color: var(--text);
}

.alert-success {
  background: var(--paid-bg);
  border-left-color: var(--paid-color);
  color: var(--accent-green-dark);
}

.alert-warning {
  background: var(--draft-bg);
  border-left-color: var(--accent-orange);
  color: var(--draft-color);
}

.alert-danger {
  background: var(--overdue-bg);
  border-left-color: var(--overdue);
  color: var(--accent-red-dark);
}

/* =====================================================
   CARDS & CONTAINERS
   ===================================================== */

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.card-header {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text);
}

/* =====================================================
   TABLES
   ===================================================== */

.table-header {
  background: var(--bg-soft);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.table-row:hover {
  background: rgba(198,144,77,0.02);
  transition: background var(--transition-fast);
}

/* =====================================================
   FORM INPUTS — Unified base styles
   All modules should inherit these defaults.
   Use --input-* tokens for page-specific overrides.
   ===================================================== */

input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="password"],
select,
textarea {
  font-family: var(--f-ui);
  font-size: var(--input-font-size);
  padding: var(--input-padding);
  border: var(--input-border);
  border-radius: var(--input-radius);
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: var(--input-focus-color);
  box-shadow: var(--input-focus-shadow);
}

/* ── Date / datetime-local / time — dedicated sizing rules ─────────
   Date inputs have native browser chrome (calendar icon, clear button
   on some browsers, AM/PM spinner on time inputs) that eats into the
   padding area. We give them slightly MORE horizontal padding than
   regular text inputs so the user-typed date text doesn't feel
   cramped against the icon. Width is constrained to a sensible
   max for date fields since they never hold more than ~16 chars;
   pages can override with width:100% where needed.
   -----------------------------------------------------------------*/
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
  padding: var(--input-padding);
  padding-right: 0.5rem;  /* leave room for native calendar icon */
  min-width: 8rem;
  max-width: 100%;
  line-height: 1.25;
}

input::placeholder,
textarea::placeholder {
  color: var(--gray-400);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--bg-soft);
  color: var(--text-muted);
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 60px;
}

/* Checkbox / Radio — unified accent color */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--brand-gold);
}

/* Small variant — for dense data tables and compact forms */
.input-sm,
.field-sm input,
.field-sm select,
.field-sm textarea {
  font-size: var(--input-font-size-sm);
  padding: var(--input-padding-sm);
}

/* Button small variants — override unified system for compact contexts */
.btn-sm {
  padding: var(--btn-padding-sm) !important;
  font-size: var(--btn-font-size-sm) !important;
  min-height: 30px !important;
}

.btn-xs {
  padding: var(--btn-padding-xs) !important;
  font-size: var(--btn-font-size-xs) !important;
  min-height: 24px !important;
}

/* =====================================================
   MODAL / POPUP / OVERLAY — Base styles
   Page CSS can extend these with module-specific classes.
   ===================================================== */

.modal-overlay,
[class*="-overlay"] {
  background: rgba(1,22,56,0.5);
}

[class*="-modal-header"],
[class*="-popup-header"],
[class*="-drawer-header"] {
  font-family: var(--f-ui);
  font-weight: 600;
}

[class*="-modal-close"],
[class*="-popup-close"] {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
  transition: opacity var(--transition-fast);
}

[class*="-modal-close"]:hover,
[class*="-popup-close"]:hover {
  opacity: 0.7;
}

/* =====================================================
   MOBILE — iOS zoom prevention (16px min font)
   ===================================================== */

@media (max-width: 768px) {
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="tel"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px;
    min-height: 44px;
  }
}

/* =====================================================
   FORM INPUTS
   ===================================================== */

.input-primary {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  transition: all var(--transition-fast);
  font-family: var(--f-ui);
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--white);
}

.input-primary:focus {
  outline: none;
  border-color: var(--garnet);
  box-shadow: 0 0 0 2px rgba(198,144,77,0.1);
}

.input-gold:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 2px rgba(201,144,90,0.15);
}

/* =====================================================
   TEXT COLOR UTILITIES
   ===================================================== */

.text-brand-navy  { color: var(--text); }
.text-brand-gold  { color: var(--garnet); }
.text-accent-red  { color: var(--accent-red); }
.text-accent-green { color: var(--accent-green); }
.text-accent-orange { color: var(--accent-orange); }
.text-accent-purple { color: var(--accent-purple); }

/* =====================================================
   BACKGROUND COLOR UTILITIES
   ===================================================== */

.bg-brand-navy  { background-color: var(--sidebar); }
.bg-brand-gold  { background-color: var(--garnet); }
.bg-brand-gold-light { background-color: var(--garnet-lt); }
.hover\:bg-brand-gold-light:hover { background-color: var(--garnet-lt); }
.bg-accent-red  { background-color: var(--accent-red); }
.bg-accent-green { background-color: var(--accent-green); }
.bg-accent-orange { background-color: var(--accent-orange); }
.bg-accent-purple { background-color: var(--accent-purple); }

/* =====================================================
   BORDER COLOR UTILITIES
   ===================================================== */

.border-brand-navy  { border-color: var(--border); }
.border-brand-gold  { border-color: var(--garnet); }
.border-accent-red  { border-color: var(--accent-red); }
.border-accent-green { border-color: var(--accent-green); }
.border-accent-orange { border-color: var(--accent-orange); }
.border-accent-purple { border-color: var(--accent-purple); }

/* =====================================================
   MODAL & OVERLAY
   ===================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: var(--z-modal, 9500);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* =====================================================
   STATUS COLORS — Shipment/delivery
   ===================================================== */

.status-delivered  { background: var(--paid-bg); color: var(--paid-color); }
.status-in-transit { background: var(--sent-bg); color: var(--sent-color); }
.status-exception  { background: var(--overdue-bg); color: var(--overdue); }
.status-pending    { background: var(--draft-bg); color: var(--draft-color); }

/* =====================================================
   FINANCIAL DATA — Monospace
   ===================================================== */

.financial, .mono {
  font-family: var(--f-mono);
}

/* =====================================================
   BRAND MARK — Serif italic
   ===================================================== */

.brand-mark {
  font-family: var(--f-serif);
  font-style: italic;
  font-weight: 300;
}

/* =====================================================
   ZOHO-STYLE APP CONTAINERS
   ===================================================== */

/* App frame — full-page shell with sidebar + content */
.app-frame {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

/* Page header — breadcrumb + title bar */
.page-header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: var(--white);
}

.page-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.page-breadcrumb {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.page-breadcrumb span { color: var(--garnet); }

/* Filter bar — Zoho-style dropdowns above data */
.zoho-filter-bar {
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  background: var(--bg-soft);
}

.zoho-filter-bar .filter-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.zoho-filter-bar select,
.zoho-filter-bar input {
  font-size: 11px;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  color: var(--text);
  font-family: var(--f-ui);
  font-weight: 500;
}

.zoho-filter-bar select:focus,
.zoho-filter-bar input:focus {
  outline: none;
  border-color: var(--garnet);
  box-shadow: 0 0 0 2px rgba(198,144,77,0.08);
}

.zoho-filter-bar label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.zoho-filter-bar .run-btn {
  background: var(--garnet);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.28rem 0.85rem;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  margin-left: auto;
}

.zoho-filter-bar .run-btn:hover {
  background: var(--garnet-lt);
}

/* Filter chips — active filter pills */
.zoho-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.15rem 0.55rem;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(198,144,77,0.06);
  color: var(--garnet);
  border: 1px solid rgba(198,144,77,0.15);
}

.zoho-filter-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--garnet);
  font-size: 12px;
  padding: 0;
  line-height: 1;
  opacity: 0.6;
}

.zoho-filter-chip button:hover { opacity: 1; }

/* =====================================================
   ZOHO-STYLE DATA TABLES
   ===================================================== */

.zoho-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--f-ui);
}

.zoho-table thead th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

.zoho-table thead th:hover {
  background: var(--gray-200);
}

.zoho-table thead th.num { text-align: right; }

.zoho-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

.zoho-table tbody tr:hover td {
  background: rgba(198,144,77,0.025);
}

.zoho-table tbody td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  vertical-align: middle;
  font-size: 12px;
}

.zoho-table tbody td.num {
  text-align: right;
  font-family: var(--f-mono);
  font-size: 11px;
}

.zoho-table tbody td.num.amount { color: var(--text-soft); }
.zoho-table tbody td.num.balance { color: var(--garnet); font-weight: 500; }

.zoho-table .table-link {
  color: var(--garnet);
  text-decoration: none;
  font-weight: 500;
}

.zoho-table .table-link:hover { text-decoration: underline; }

/* Table section headers & totals */
.zoho-table .section-header td {
  background: var(--bg-soft);
  font-weight: 600;
  font-size: 11px;
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.zoho-table .section-total td {
  font-size: 11px;
  color: var(--text-muted);
}

.zoho-table .section-total td.num {
  font-family: var(--f-mono);
  color: var(--text);
  font-weight: 500;
}

.zoho-table .grand-total td {
  font-weight: 700;
  font-size: 12px;
  border-top: 2px solid var(--border);
  padding-top: 0.6rem;
}

.zoho-table .grand-total td.num {
  font-family: var(--f-mono);
  color: var(--garnet);
}

/* Sort indicator */
.zoho-table th .sort-icon {
  margin-left: 4px;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.4;
}

.zoho-table th.sorted-asc .sort-icon,
.zoho-table th.sorted-desc .sort-icon {
  color: var(--garnet);
  opacity: 1;
}

/* =====================================================
   ZOHO-STYLE TABLE WRAP — bordered container
   ===================================================== */

.zoho-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

/* =====================================================
   ZOHO-STYLE TOOLBAR
   ===================================================== */

.zoho-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.zoho-toolbar .search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.zoho-toolbar .search-wrap input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--f-ui);
  background: var(--white);
  color: var(--text);
}

.zoho-toolbar .search-wrap input:focus {
  outline: none;
  border-color: var(--garnet);
  box-shadow: 0 0 0 2px rgba(198,144,77,0.08);
}

.zoho-toolbar .search-wrap .search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}

.zoho-toolbar-btn {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--f-ui);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-soft);
  transition: all 0.15s;
}

.zoho-toolbar-btn:hover {
  background: var(--bg);
  border-color: var(--gray-400);
}

.zoho-toolbar-btn.active {
  background: var(--garnet);
  color: var(--white);
  border-color: var(--garnet);
}

/* =====================================================
   ZOHO-STYLE CARDS
   ===================================================== */

.zoho-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.zoho-card:hover {
  box-shadow: var(--shadow-md);
}

.zoho-card-header {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1rem;
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 600;
  font-size: 11px;
  color: var(--text);
  letter-spacing: 0.02em;
}

/* =====================================================
   ZOHO-STYLE DETAIL MODAL
   ===================================================== */

.zoho-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.4);
  display: none;
}

.zoho-modal-overlay.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.zoho-modal-panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 960px;
  box-shadow: var(--shadow-xl);
  margin-top: 20px;
  margin-bottom: 40px;
}

.zoho-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--white);
}

.zoho-modal-header h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.zoho-modal-header .close-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.zoho-modal-header .close-btn:hover {
  background: var(--overdue-bg);
  color: var(--overdue);
  border-color: var(--overdue-border);
}

.zoho-modal-body {
  padding: 1.25rem;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.zoho-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* =====================================================
   ZOHO-STYLE DETAIL SECTIONS
   ===================================================== */

.zoho-detail-section {
  margin-bottom: 1.5rem;
}

.zoho-detail-section h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.zoho-detail-section h3 i {
  color: var(--garnet);
  font-size: 12px;
}

.zoho-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.zoho-detail-field {
  display: flex;
  flex-direction: column;
}

.zoho-detail-field label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.25rem;
}

.zoho-detail-field input,
.zoho-detail-field select,
.zoho-detail-field textarea {
  font-size: 12px;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  color: var(--text);
  font-family: var(--f-ui);
  transition: border 0.15s;
}

.zoho-detail-field input:focus,
.zoho-detail-field select:focus,
.zoho-detail-field textarea:focus {
  outline: none;
  border-color: var(--garnet);
  box-shadow: 0 0 0 2px rgba(198,144,77,0.08);
}

.zoho-detail-field input[readonly] {
  background: var(--bg-soft);
  color: var(--text-muted);
}

/* =====================================================
   ZOHO-STYLE PAGINATION
   ===================================================== */

.zoho-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
}

.zoho-pagination button {
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  font-size: 11px;
  font-family: var(--f-ui);
  cursor: pointer;
  color: var(--text-soft);
  transition: all 0.15s;
}

.zoho-pagination button:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--gray-400);
}

.zoho-pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

.zoho-pagination button.active {
  background: var(--garnet);
  color: var(--white);
  border-color: var(--garnet);
}

.zoho-pagination .page-info {
  font-size: 11px;
  color: var(--text-muted);
}

/* =====================================================
   ZOHO-STYLE TAB NAVIGATION
   ===================================================== */

.zoho-tab-container {
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--garnet) var(--gray-200);
  border-bottom: 1px solid var(--border);
  background: var(--white);
}

.zoho-tab-container::-webkit-scrollbar { height: 3px; }
.zoho-tab-container::-webkit-scrollbar-track { background: var(--gray-200); }
.zoho-tab-container::-webkit-scrollbar-thumb { background: var(--garnet); border-radius: 2px; }

.zoho-tab-btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 500;
  font-size: 12px;
  font-family: var(--f-ui);
  transition: all 0.15s;
  white-space: nowrap;
}

.zoho-tab-btn:hover {
  color: var(--text-soft);
  background: var(--bg-soft);
}

.zoho-tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--garnet);
  font-weight: 600;
}

/* =====================================================
   ZOHO-STYLE SUMMARY CARDS
   ===================================================== */

.zoho-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.zoho-summary-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-sm);
}

.zoho-summary-card .summary-value {
  font-family: var(--f-mono);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.zoho-summary-card .summary-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.25rem;
}

/* =====================================================
   ZOHO-STYLE TOAST NOTIFICATIONS
   ===================================================== */

.zoho-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--f-ui);
  color: var(--white);
  box-shadow: var(--shadow-lg);
  transition: transform 0.3s, opacity 0.3s;
  transform: translateY(100px);
  opacity: 0;
}

.zoho-toast.show { transform: translateY(0); opacity: 1; }
.zoho-toast.success { background: var(--accent-green); }
.zoho-toast.error { background: var(--overdue); }
.zoho-toast.info { background: var(--sent-color); }

/* =====================================================
   ZOHO-STYLE LOADING SPINNER
   ===================================================== */

.zoho-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--garnet);
  border-radius: 50%;
  animation: zoho-spin 0.6s linear infinite;
}

@keyframes zoho-spin { to { transform: rotate(360deg); } }

.zoho-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  border-radius: var(--radius);
}

/* =====================================================
   ZOHO-STYLE TOGGLE SWITCH
   ===================================================== */

.zoho-toggle {
  position: relative;
  width: 36px;
  height: 20px;
}

.zoho-toggle input { opacity: 0; width: 0; height: 0; }

.zoho-toggle .slider {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s;
}

.zoho-toggle .slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white);
  left: 2px;
  top: 2px;
  transition: 0.2s;
}

.zoho-toggle input:checked + .slider { background: var(--garnet); }
.zoho-toggle input:checked + .slider::before { transform: translateX(16px); }

/* =====================================================
   LEGACY COMPAT
   ===================================================== */

.luxury-gradient { background: var(--sidebar); }
.gold-accent     { background: var(--garnet); }
.navy-accent     { background: var(--sidebar); }
.brand-gradient  { background: var(--sidebar); color: var(--color-white); }

/* Gold-accent text/border utilities */
.text-gold-accent  { color: var(--amber); }
.border-gold-accent { border-color: var(--garnet); }

/* =====================================================
   TAILWIND OVERRIDES — fix cold-blue values
   ===================================================== */

/* hover\:bg-navy-light was cold navy — override to OC navy */
.hover\:bg-navy-light:hover { background-color: var(--sidebar-mid) !important; }

/* bg-navy-lightest — override to OC dim */
.bg-navy-lightest,
.hover\:bg-navy-lightest:hover { background-color: var(--bg-navy-lightest) !important; }

/* =====================================================
   SHARED MODULE HEADER — unified nav + user avatar
   ===================================================== */

/* ── Mobile-first: slide-out nav (base styles) ── */
.unified-nav-menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.2);
  padding: 1rem;
  gap: 0.125rem;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 99999;
  width: 300px;
  max-width: 88vw;
  overflow-y: auto;
}

.unified-nav-menu.open {
  transform: translateX(0);
}

.unified-nav-mobile-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  transition: all 0.15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  z-index: 10;
}

.unified-nav-mobile-toggle:hover,
.unified-nav-mobile-toggle:active {
  background: var(--gray-200);
  color: var(--text);
}

/* Mobile: accordion — each section is a tappable header that expands its links */
.unified-nav-group {
  position: static;
  display: flex;
  flex-direction: column;
}

.unified-nav-trigger {
  display: flex; /* Mobile: visible accordion section header */
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.625rem;
  border-radius: var(--radius);
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.unified-nav-trigger:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}

.unified-nav-group.has-active > .unified-nav-trigger {
  color: var(--amber);
}

.unified-nav-caret {
  font-size: 0.55rem;
  margin-left: auto;
  transition: transform 0.15s;
}

.unified-nav-group.open > .unified-nav-trigger .unified-nav-caret {
  transform: rotate(180deg);
}

/* Mobile: dropdowns collapsed until their section is expanded */
.unified-nav-dropdown {
  display: none;
  position: static;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0 0 0.25rem 0.875rem;
  min-width: 0;
  flex-direction: column;
}

.unified-nav-group.open > .unified-nav-dropdown {
  display: flex;
}

.unified-nav-dropdown .unified-nav-section-label {
  display: none; /* the accordion trigger is the section label */
}

.unified-nav-link {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.55rem 0.625rem;
  min-height: 42px;
  border-radius: var(--radius);
  text-decoration: none;
  color: rgba(255,255,255,0.6);
  font-weight: 500;
  font-size: 0.8125rem;
  transition: all 0.15s;
  white-space: nowrap;
  justify-content: flex-start;
  width: 100%;
}

.unified-nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}

.unified-nav-link.active {
  background: rgba(201,144,90,0.18);
  color: var(--amber);
  font-weight: 600;
}

.unified-nav-link i {
  font-size: 0.8125rem;
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}

.unified-nav-section-label {
  display: block;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
  padding: 0.5rem 0.625rem 0.15rem;
  margin-top: 0.25rem;
}

.unified-nav-close {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.5rem;
  color: rgba(255,255,255,0.6);
  font-weight: 600;
  font-size: 0.8125rem;
}

.unified-nav-close button {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 1.125rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  line-height: 1;
}

/* Backdrop overlay behind mobile nav */
.unified-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.unified-nav-backdrop.open {
  display: block;
  opacity: 1;
}

/* Quick-create (+ New) — global header button + dropdown */
.qc-wrapper {
  position: relative;
  flex-shrink: 0;
}

.qc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 36px;
  padding: 0 0.8rem;
  background: var(--garnet);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.qc-btn:hover {
  filter: brightness(1.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.qc-btn i {
  font-size: 0.75rem;
}

.qc-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--oc-radius, 10px);
  box-shadow: var(--oc-shadow-2, 0 4px 20px rgba(0,0,0,0.12));
  min-width: 200px;
  padding: 0.375rem;
  z-index: 4000;
}

.qc-menu.open {
  display: block;
}

.qc-menu-header {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.375rem 0.625rem 0.15rem;
}

.qc-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.625rem;
  min-height: 40px;
  border-radius: var(--radius);
  color: var(--text-soft);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
}

.qc-menu-item:hover {
  background: var(--bg);
  color: var(--text);
}

.qc-menu-item i {
  width: 1rem;
  text-align: center;
  color: var(--garnet);
}

@media (max-width: 768px) {
  .qc-btn {
    width: 36px;
    padding: 0;
  }
  .qc-btn-label {
    display: none;
  }
}

/* User avatar + dropdown */
.user-avatar-wrapper {
  position: relative;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.user-avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--garnet);
  color: white;
  border: 2px solid rgba(198,144,77,0.2);
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  letter-spacing: 0.5px;
  line-height: 1;
}

.user-avatar-btn:hover {
  border-color: var(--garnet);
  transform: scale(1.05);
}

.user-avatar-btn img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--white);
  border-radius: var(--oc-radius, 10px);
  box-shadow: var(--oc-shadow-2, 0 4px 20px rgba(0,0,0,0.12));
  border: 1px solid var(--border);
  min-width: 200px;
  z-index: 4000;
  overflow: hidden;
}

.user-dropdown.open {
  display: block;
}

.user-dropdown-info {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.user-dropdown-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.8125rem;
}

.user-dropdown-email {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 2px;
  word-break: break-all;
}

.user-dropdown-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 1rem;
  border: none;
  background: none;
  color: var(--text-soft);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}

.user-dropdown-action:hover {
  background: var(--bg-soft);
}

.user-dropdown-action.logout {
  color: var(--accent-red);
  border-top: 1px solid var(--border);
}

.user-dropdown-action.logout:hover {
  background: var(--overdue-bg);
}

/* Mobile: hide button labels when an icon sibling exists; label-only buttons stay visible.
   Trim the icon-only buttons further (32×32, no shadow) so a row of 4–7 quick
   actions doesn't crowd out the title or the bell+avatar+nav cluster on a
   390 px viewport. The desktop look (40+ px gold tiles) is unchanged. */
@media (max-width: 768px) {
  .header-action-btn:has(> i) .header-btn-label {
    display: none;
  }
  .header-action-btn:has(> i) {
    padding: 0.3rem !important;
    min-width: 32px;
    height: 32px;
    justify-content: center;
    box-shadow: none !important;
    border-width: 1px;
  }
  .header-action-btn:has(> i) i {
    font-size: 0.85rem !important;
  }
  .header-action-btn:not(:has(> i)) {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.72rem;
  }
  /* Burger / sidebar mobile-toggle was 42×42 — that's larger than the
     bell (36) and avatar (34) and made the right cluster look top-heavy.
     Match the bell. */
  .unified-nav-mobile-toggle {
    width: 36px !important;
    height: 36px !important;
    font-size: 1rem !important;
  }
  /* Bell already 36×36, but pull margin in a touch so it doesn't push
     the avatar off the header on the narrowest viewports. */
  .notif-bell-wrapper { margin-right: 4px !important; }
  .user-avatar-wrapper { margin-left: 4px !important; }
}

/* ── Desktop: horizontal nav bar (min-width: 1280px) ──
   Was 1441px, which forced most laptops (1280–1440) into the mobile
   burger drawer. Triggers are compact text-only (icons stay in the
   dropdown items) so all sections fit at 1280px, Zoho-style. */
@media (min-width: 1280px) {
  .unified-nav-menu {
    position: static;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    background: none;
    box-shadow: none;
    padding: 0;
    transform: none;
    transition: none;
    z-index: auto;
    width: auto;
    max-width: none;
    overflow-y: visible;
  }

  .unified-nav-mobile-toggle {
    display: none;
  }

  .unified-nav-close {
    display: none;
  }

  .unified-nav-backdrop {
    display: none !important;
  }

  .unified-nav-group {
    position: relative;
    flex-direction: row;
  }

  .unified-nav-trigger {
    width: auto;
    min-height: 0;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    color: var(--text-soft);
    font-weight: 500;
  }

  /* Compact: hide section icons in the top bar, keep text + caret */
  .unified-nav-trigger > i:not(.unified-nav-caret) {
    display: none;
  }

  .unified-nav-trigger:hover {
    background: var(--bg);
    color: var(--text);
  }

  .unified-nav-group.has-active > .unified-nav-trigger {
    color: var(--garnet);
    font-weight: 600;
  }

  .unified-nav-caret {
    margin-left: 0.125rem;
    font-size: 0.5rem;
  }

  .unified-nav-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--oc-radius, 10px);
    box-shadow: var(--oc-shadow-2, 0 4px 20px rgba(0,0,0,0.12));
    min-width: 200px;
    padding: 0.375rem;
    z-index: 4000;
  }

  .unified-nav-group.open > .unified-nav-dropdown {
    display: block;
  }

  /* Last three nav groups (Logistics, Tools, Admin) — align dropdown to right
     edge so it doesn't extend past the viewport on narrower screens */
  .unified-nav-group:nth-last-child(-n+3) > .unified-nav-dropdown {
    left: auto;
    right: 0;
  }

  .unified-nav-dropdown .unified-nav-section-label {
    display: none;
  }

  .unified-nav-section-label {
    display: none;
  }

  .unified-nav-link {
    color: var(--text-soft);
    justify-content: flex-start;
    width: auto;
  }

  .unified-nav-link:hover {
    background: var(--bg);
    color: var(--text);
  }

  .unified-nav-link.active {
    background: rgba(198,144,77,0.08);
    color: var(--garnet);
  }
}

/* Module header bar — tight single-line separator in brand gold so
   the page content sits right under the header. Previously had a
   grey 1px border + 1rem margin-bottom, which felt like dead space
   on mobile (the chunky empty band between Packages / Back). */
.module-header-bar {
  background: var(--white);
  border-bottom: 2px solid var(--brand-gold);
  margin-bottom: 0.25rem;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

/* When any desktop section dropdown is open, lift the header above
   everything so the dropdown can escape lower stacking contexts —
   kebab menus and panel popovers can sit at higher z-index than the
   header's default sticky layer.
   The mobile slide-out menu uses a different escape route: it is
   portaled to document.body via JS (initUnifiedNav in
   shared-module-header.js) so it never has to fight the header's
   stacking context. That's why .unified-nav-menu.open is NOT in
   this selector — lifting the header while the mobile menu is open
   drags page chrome above the backdrop, which is exactly the bug
   we used to have. */
.module-header-bar:has(.unified-nav-group.open),
.module-header-bar:has(.qc-menu.open) {
  z-index: var(--z-nav);
}

.module-header-bar .header-inner {
  padding: 0.5rem 0.75rem;
}

@media (min-width: 768px) {
  .module-header-bar {
    margin-bottom: 0.5rem;
  }
  .module-header-bar .header-inner {
    padding: 0.45rem 1.25rem;
  }
}

/* Single-row header layout: title block + actions + right cluster.
   Wraps on narrow viewports so action buttons drop under the title. */
.module-header-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex-wrap: wrap;
}
@media (min-width: 768px) {
  .module-header-row {
    gap: 0.75rem;
    flex-wrap: nowrap;
  }
}

.module-header-titleblock {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 0 1 auto;
}

.module-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}
@media (min-width: 768px) {
  .module-header-actions {
    flex: 1 1 auto;
    flex-wrap: nowrap;
  }
}

.module-header-custom { min-width: 0; }
.module-header-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.module-header-rightcluster {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-shrink: 0;
}

.module-header-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

@media (min-width: 768px) {
  .module-header-title {
    font-size: 1.1rem;
  }
}

.module-header-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
  display: none;
}
@media (min-width: 1024px) {
  .module-header-subtitle { display: block; }
}

/* === TAILWIND UTILITY OVERRIDES (garnet accent — missing from Tailwind config) === */
.bg-garnet     { background-color: var(--garnet) !important; }
.bg-garnet-lt  { background-color: var(--garnet-lt) !important; }
.bg-garnet-btn { background-color: var(--garnet-btn) !important; }
.hover\:bg-garnet-lt:hover { background-color: var(--garnet-lt) !important; }
.hover\:bg-garnet:hover    { background-color: var(--garnet) !important; }
.text-garnet   { color: var(--garnet); }
.hover\:text-garnet:hover  { color: var(--garnet); }
.border-garnet { border-color: var(--garnet); }
.focus\:border-garnet:focus { border-color: var(--garnet); }
.focus\:ring-garnet\/10:focus { --tw-ring-color: rgb(198 144 77 / 0.1); box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), 0 0 0 2px var(--tw-ring-color), var(--tw-shadow, 0 0 #0000); }

/* ═══════════════════════════════════════════════════════════════════
   GLOBAL MOBILE FORM INPUT STANDARDIZATION
   Applied once here so every page inherits it. Prevents:
     – iOS auto-zoom on focus (requires ≥16px font on input)
     – Caret drawing below the text line (requires explicit line-height
       + padding, NOT min-height — see the detailed comment in
       create-item.css and items.css for the full bug explanation)
     – Date/datetime inputs feeling cramped under the native calendar
       icon chrome
   Pages with more specific selectors (e.g. .form-group input,
   .detail-field input) will inherit these as a baseline and can
   tighten/loosen as needed — but they no longer need to duplicate
   the 16px / line-height / padding fix themselves.
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Text-like inputs: standardized 16px font + safe padding.
     Excludes checkbox / radio / file / hidden / range which have
     their own native rendering and don't benefit from text styling. */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  input[type="date"],
  input[type="datetime-local"],
  input[type="time"],
  input[type="password"],
  input:not([type]),
  select {
    font-size: 16px;
    line-height: 1.25;
    padding: 10px 12px;
    height: auto;
  }

  /* Date/datetime/time inputs need slightly more right padding on
     mobile because the native date-picker icon sits inside the
     padding area and can overlap the typed text. */
  input[type="date"],
  input[type="datetime-local"],
  input[type="time"] {
    padding-right: 8px;
    min-width: 0;  /* allow shrinking on narrow viewports */
  }

  textarea {
    font-size: 16px;
    line-height: 1.4;
    padding: 10px 12px;
  }
}

/* ═══════════════════════════════════════════════════════════
   Global mobile app-shell scroll fix
   ═══════════════════════════════════════════════════════════
   Every module page (orders, purchases, packages, inventory-
   adjustments, reports, estimate-builder, stock-check, crm,
   …) wraps its content in:

     <div class="mx-auto px-2 md:px-4 py-2 md:py-4 flex flex-col"
          style="height: 100vh; height: 100dvh; overflow: hidden;">

   On iOS Safari that height-pinned + overflow:hidden outer box
   traps the body — internal scroll containers handle their own
   list but the last 60-150px of any page that flows past the
   viewport sits in a dead zone (we chased this through PRs
   #894/#895/#896/#898/#899 before realising the actual culprit
   was an inline-style outer wrapper).

   Drop the lock on mobile so the page scrolls as a single
   document. Attribute selector targets only the specific
   inline-style combo, so unrelated wrappers (modals, overlays)
   that legitimately need 100dvh fixed are untouched.

   The 80px bottom padding clears safe-area / floating FABs so
   the last item is never wedged under the URL bar. */
@media (max-width: 768px) {
  [style*="100dvh"][style*="overflow: hidden"] {
    height: auto !important;
    overflow: visible !important;
    min-height: 0 !important;
    padding-bottom: 80px;
  }
  /* stock-check.html uses overflow-y: auto on the outer wrapper
     instead of overflow: hidden — same locked-viewport issue,
     same treatment. */
  [style*="100dvh"][style*="overflow-y: auto"] {
    height: auto !important;
    overflow: visible !important;
    min-height: 0 !important;
    padding-bottom: 80px;
  }
}

