/* ============================================================================
 * PostPatra Operations — Modern Web App Design System (pp-modern.css)
 * High-performance, responsive, accessible, tokenized enterprise design system.
 * ============================================================================ */

/* --------------------------------------------------------------------------
 * 1. DESIGN TOKENS (DARK THEME - DEFAULT)
 * -------------------------------------------------------------------------- */
:root {
  /* Brand Identity: PostPatra Royal Postal Blue (Stripe / Shopify style) */
  --brand-primary:        #3b82f6;
  --brand-primary-hover:  #60a5fa;
  --brand-primary-active: #2563eb;
  --brand-primary-ink:    #ffffff;  /* High contrast white text on solid blue */
  --brand-primary-glow:   rgba(59, 130, 246, 0.25);
  --brand-primary-subtle: rgba(59, 130, 246, 0.12);
  --brand-primary-border: rgba(59, 130, 246, 0.35);

  /* Legacy Brand Aliases */
  --brand-gold:          var(--brand-primary);
  --brand-gold-hover:    var(--brand-primary-hover);
  --brand-gold-active:   var(--brand-primary-active);
  --brand-gold-ink:      var(--brand-primary-ink);
  --brand-gold-glow:     var(--brand-primary-glow);
  --brand-gold-subtle:   var(--brand-primary-subtle);
  --brand-gold-border:   var(--brand-primary-border);

  /* Semantic Surfaces — Midnight Navy Palette */
  --surface-ground:      #0b132b;  /* Deep app viewport background */
  --surface-subtle:      #0f172a;  /* Sidebars, topbars, navigation headers */
  --surface-card:        #162035;  /* Standard cards, panels, modules */
  --surface-raised:      #1e293b;  /* Elevated cards, hovered rows, dropdowns */
  --surface-overlay:     #223049;  /* Tooltips, modals, floating popovers */
  --surface-sunken:      #0a0f20;  /* Inset inputs, code blocks, search wells */
  /* Aliases used by the orders workspace and order popups; they follow the theme. */
  --surface-elevated:    var(--surface-raised);
  --text-main:           var(--text-primary);
  --brand-primary-soft:  var(--brand-primary-subtle);
  --r-md:                10px;
  --surface-hover:       rgba(255, 255, 255, 0.05);
  --surface-active:      rgba(255, 255, 255, 0.09);

  /* Semantic Borders & Dividers */
  --border-subtle:       rgba(255, 255, 255, 0.07);
  --border-default:      rgba(255, 255, 255, 0.12);
  --border-strong:       rgba(255, 255, 255, 0.20);
  --border-focus:        var(--brand-primary);

  /* Typography & Ink */
  --text-primary:        #f8fafc;
  --text-secondary:      #94a3b8;
  --text-muted:          #7d8aa0;  /* 5:1 on the navy canvas; #64748b failed AA */
  --text-faint:          #475569;
  --text-inverse:        #0b132b;

  /* Semantic State Colors */
  --state-success:       #10b981;
  --state-success-bg:    rgba(16, 185, 129, 0.12);
  --state-success-border:rgba(16, 185, 129, 0.30);
  --state-success-ink:   #34d399;

  --state-warning:       #f59e0b;
  --state-warning-bg:    rgba(245, 158, 11, 0.12);
  --state-warning-border:rgba(245, 158, 11, 0.30);
  --state-warning-ink:   #fbbf24;

  --state-danger:        #ef4444;
  --state-danger-bg:     rgba(239, 68, 68, 0.12);
  --state-danger-border: rgba(239, 68, 68, 0.30);
  --state-danger-ink:    #f87171;

  --state-info:          #3b82f6;
  --state-info-bg:       rgba(59, 130, 246, 0.12);
  --state-info-border:   rgba(59, 130, 246, 0.30);
  --state-info-ink:      #60a5fa;

  /* Typography System */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-3xs:   10px;
  --fs-2xs:   11.5px;
  --fs-xs:    12.5px;
  --fs-sm:    13.5px;
  --fs-base:  14.5px;
  --fs-md:    16px;
  --fs-lg:    18px;
  --fs-xl:    22px;
  --fs-2xl:   26px;
  --fs-3xl:   32px;

  --lh-tight: 1.25;
  --lh-snug:  1.4;
  --lh-base:  1.55;

  /* 4px Spacing Rhythm */
  --sp-0-5: 2px;
  --sp-1:   4px;
  --sp-1-5: 6px;
  --sp-2:   8px;
  --sp-2-5: 10px;
  --sp-3:   12px;
  --sp-4:   16px;
  --sp-5:   20px;
  --sp-6:   24px;
  --sp-8:   32px;
  --sp-10:  40px;
  --sp-12:  48px;

  /* Corner Radius Scale */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-pill: 9999px;

  /* Elevation Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.65);
  --shadow-glow: 0 0 24px var(--brand-primary-glow);

  /* Touch & Interaction Floor */
  --touch-target: 44px;
  --transition-fast: 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-base: 0.25s cubic-bezier(0.16, 1, 0.3, 1);

  /* ------------------------------------------------------------------------
   * BACKWARDS-COMPATIBILITY MAPPINGS FOR LEGACY MODULES & SCRIPTS
   * ------------------------------------------------------------------------ */
  --gold:         var(--brand-primary);
  --gold-soft:    var(--brand-primary-hover);
  --gold-bright:  var(--brand-primary-hover);
  --gold-tint:    var(--brand-primary-subtle);
  --gold-line:    var(--brand-primary-border);
  --gold-glow:    var(--brand-primary-glow);

  --bg:           var(--surface-ground);
  --bg2:          var(--surface-subtle);
  --surface:      var(--surface-card);
  --surface2:     var(--surface-raised);
  --elev:         var(--surface-raised);
  --border:       var(--border-default);
  --border2:      var(--border-strong);
  --ink:          var(--text-primary);
  --muted:        var(--text-secondary);
  --faint:        var(--text-muted);

  --m-card:       var(--surface-card);
  --m-panel:      var(--surface-raised);
  --m-line:       var(--border-default);
  --m-line2:      var(--border-strong);
  --m-line3:      rgba(255, 255, 255, 0.22);
  --m-ink:        var(--text-primary);
  --m-ink2:       var(--text-primary);
  --m-ink3:       var(--text-secondary);
  --m-muted:      var(--text-secondary);
  --m-muted2:     var(--text-secondary);
  --m-muted3:     var(--text-muted);
  --m-muted4:     var(--text-muted);
  --m-faint:      var(--text-muted);
  --m-faint2:     var(--text-muted);   /* was --text-faint: unreadable for real text */
  --m-gold:       var(--brand-primary);
  --m-gold-ink:   var(--brand-primary);
  --m-on-accent:  var(--brand-primary-ink);
  --m-on-accent2: var(--brand-primary-ink);
  --m-ok:         var(--state-success);
  --m-ok-bg:      var(--state-success-bg);
  --m-danger:     var(--state-danger);
  --m-danger2:    var(--state-danger);
  --m-warn:       var(--state-warning);
  --m-warn-bg:    var(--state-warning-bg);
  --m-blue:       var(--state-info);

  /* .ppui Backwards Compatibility */
  --pp-bg:        var(--surface-ground);
  --pp-surface:   var(--surface-card);
  --pp-sunken:    var(--surface-sunken);
  --pp-hover:     var(--surface-raised);
  --pp-line:      var(--border-default);
  --pp-line-strong: var(--border-strong);
  --pp-ink:       var(--text-primary);
  --pp-ink-2:     var(--text-secondary);
  --pp-ink-3:     var(--text-muted);
  --pp-ink-4:     var(--text-faint);
  --pp-accent:    var(--brand-primary);
  --pp-accent-fill: var(--brand-primary);
  --pp-accent-bg: var(--brand-primary-subtle);
  --pp-accent-line: var(--brand-primary-border);
  --pp-primary:   var(--text-primary);
  --pp-primary-ink: var(--surface-ground);
  --pp-good:      var(--state-success);
  --pp-good-bg:   var(--state-success-bg);
  --pp-danger:    var(--state-danger);
  --pp-danger-bg: var(--state-danger-bg);
  --pp-info:      var(--state-info);
  --pp-info-bg:   var(--state-info-bg);
}

/* --------------------------------------------------------------------------
 * 2. LIGHT THEME OVERRIDES (WCAG AA Contrast Compliant)
 * -------------------------------------------------------------------------- */
:root[data-theme="light"] {
  /* Brand Identity: PostPatra Royal Postal Blue (Stripe / Shopify style) */
  --brand-primary:        #2563eb;
  --brand-primary-hover:  #1d4ed8;
  --brand-primary-active: #1e40af;
  --brand-primary-ink:    #ffffff;
  --brand-primary-glow:   rgba(37, 99, 235, 0.20);
  --brand-primary-subtle: rgba(37, 99, 235, 0.08);
  --brand-primary-border: rgba(37, 99, 235, 0.25);

  /* Legacy Brand Aliases */
  --brand-gold:          var(--brand-primary);
  --brand-gold-hover:    var(--brand-primary-hover);
  --brand-gold-active:   var(--brand-primary-active);
  --brand-gold-ink:      var(--brand-primary-ink);
  --brand-gold-glow:     var(--brand-primary-glow);
  --brand-gold-subtle:   var(--brand-primary-subtle);
  --brand-gold-border:   var(--brand-primary-border);

  /* Semantic Surfaces — Crisp Slate White Palette */
  --surface-ground:      #f8fafc;
  --surface-subtle:      #ffffff;
  --surface-card:        #ffffff;
  --surface-raised:      #f1f5f9;
  --surface-overlay:     #ffffff;
  --surface-sunken:      #f1f5f9;
  --surface-hover:       rgba(15, 23, 42, 0.04);
  --surface-active:      rgba(15, 23, 42, 0.08);

  /* Semantic Borders & Dividers */
  --border-subtle:       rgba(0, 0, 0, 0.05);
  --border-default:      #e2e8f0;
  --border-strong:       #cbd5e1;
  --border-focus:        var(--brand-primary);

  /* Typography & Ink */
  --text-primary:        #0f172a;
  --text-secondary:      #334155;
  --text-muted:          #64748b;
  --text-faint:          #94a3b8;
  --text-inverse:        #ffffff;

  /* Semantic State Colors */
  --state-success:       #059669;
  --state-success-bg:    #ecfdf5;
  --state-success-border:#a7f3d0;
  --state-success-ink:   #047857;

  --state-warning:       #d97706;
  --state-warning-bg:    #fffbeb;
  --state-warning-border:#fde68a;
  --state-warning-ink:   #b45309;

  --state-danger:        #dc2626;
  --state-danger-bg:     #fef2f2;
  --state-danger-border: #fecaca;
  --state-danger-ink:    #b91c1c;

  --state-info:          #0284c7;
  --state-info-bg:       #f0f9ff;
  --state-info-border:   #bae6fd;
  --state-info-ink:      #0369a1;

  /* Elevation Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.07);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 14px 34px rgba(15, 23, 42, 0.10);

  /* Legacy Shell Variables in Light */
  --gold:         var(--brand-primary);
  --gold-soft:    #3b82f6;
  --gold-bright:  #2563eb;
  --gold-deep:    #1d4ed8;
  --gold-line:    var(--brand-primary-border);
  --gold-glow:    var(--brand-primary-glow);
  --gold-tint:    var(--brand-primary-subtle);

  --bg:           var(--surface-ground);
  --bg2:          var(--surface-subtle);
  --surface:      var(--surface-card);
  --surface2:     var(--surface-raised);
  --elev:         var(--surface-raised);
  --border:       var(--border-default);
  --border2:      var(--border-strong);
  --ink:          var(--text-primary);
  --muted:        var(--text-secondary);
  --faint:        var(--text-muted);

  /* Legacy Mappings in Light */
  --m-card:       var(--surface-card);
  --m-panel:      var(--surface-raised);
  --m-line:       var(--border-default);
  --m-line2:      var(--border-strong);
  --m-line3:      var(--border-strong);
  --m-ink:        var(--text-primary);
  --m-ink2:       var(--text-primary);
  --m-ink3:       var(--text-secondary);
  --m-muted:      var(--text-secondary);
  --m-muted2:     var(--text-secondary);
  --m-muted3:     var(--text-muted);
  --m-muted4:     var(--text-muted);
  --m-faint:      var(--text-muted);
  --m-faint2:     var(--text-muted);   /* was --text-faint: unreadable for real text */
  --m-gold:       var(--brand-primary);
  --m-gold-ink:   #1d4ed8;
  --m-on-accent:  #ffffff;
  --m-on-accent2: #ffffff;
  --m-ok:         var(--state-success);
  --m-ok-bg:      var(--state-success-bg);
  --m-danger:     var(--state-danger);
  --m-danger2:    var(--state-danger);
  --m-warn:       var(--state-warning);
  --m-warn-bg:    var(--state-warning-bg);
  --m-blue:       var(--state-info);

  --pp-bg:        var(--surface-ground);
  --pp-surface:   var(--surface-card);
  --pp-sunken:    var(--surface-sunken);
  --pp-hover:     var(--surface-raised);
  --pp-line:      var(--border-default);
  --pp-line-strong: var(--border-strong);
  --pp-ink:       var(--text-primary);
  --pp-ink-2:     var(--text-secondary);
  --pp-ink-3:     var(--text-muted);
  --pp-ink-4:     var(--text-faint);
  --pp-accent:    var(--brand-primary);
  --pp-accent-fill: var(--brand-primary);
  --pp-accent-bg: var(--brand-primary-subtle);
  --pp-accent-line: var(--brand-primary-border);
  --pp-primary:   var(--brand-primary);
  --pp-primary-ink: #ffffff;
}

/* --------------------------------------------------------------------------
 * 3. GLOBAL APP RESET & MODERN BASE
 * -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: var(--lh-base);
  color: var(--text-primary);
  background-color: var(--surface-ground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  min-height: 100%;
  background-color: var(--surface-ground);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--brand-primary-hover);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Icons */
.ic, .li {
  width: 1.15em;
  height: 1.15em;
  display: inline-block;
  vertical-align: -0.16em;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
 * 4. COMPONENT: BUTTONS
 * -------------------------------------------------------------------------- */
.pp-btn, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 9px 16px;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all var(--transition-fast);
  text-decoration: none;
  min-height: 38px;
}

.pp-btn:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.pp-btn:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Button Variants */
.pp-btn.primary, .btn.primary, .btn-primary {
  background: var(--brand-primary);
  color: var(--brand-primary-ink);
  border-color: var(--brand-primary);
  box-shadow: 0 1px 3px var(--brand-primary-glow);
}
.pp-btn.primary:hover, .btn.primary:hover, .btn-primary:hover {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--brand-primary-glow);
  color: var(--brand-primary-ink);
}
.pp-btn.primary:active, .btn.primary:active, .btn-primary:active {
  transform: translateY(0);
}

.pp-btn.secondary, .btn.secondary, .btn-secondary {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.pp-btn.secondary:hover, .btn.secondary:hover, .btn-secondary:hover {
  background: var(--surface-overlay);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.pp-btn.ghost, .btn.ghost, .btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.pp-btn.ghost:hover, .btn.ghost:hover, .btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.pp-btn.danger, .btn.danger, .btn-danger {
  background: var(--state-danger-bg);
  color: var(--state-danger-ink);
  border-color: var(--state-danger-border);
}
.pp-btn.danger:hover, .btn.danger:hover, .btn-danger:hover {
  background: var(--state-danger);
  color: #ffffff;
  border-color: var(--state-danger);
}

.pp-btn.success, .btn.success, .btn-success {
  background: var(--state-success-bg);
  color: var(--state-success-ink);
  border-color: var(--state-success-border);
}
.pp-btn.success:hover, .btn.success:hover, .btn-success:hover {
  background: var(--state-success);
  color: #ffffff;
  border-color: var(--state-success);
}

/* Button Sizes */
.pp-btn.sm, .btn.sm, .btn-sm {
  padding: 6px 11px;
  font-size: var(--fs-xs);
  min-height: 30px;
  border-radius: var(--radius-sm);
}

.pp-btn.lg, .btn.lg, .btn-lg {
  padding: 13px 22px;
  font-size: var(--fs-base);
  min-height: 48px;
  border-radius: var(--radius-lg);
}

.pp-btn.icon-only, .btn.icon-only {
  padding: 0;
  width: 38px;
  height: 38px;
  min-height: 38px;
}
.pp-btn.icon-only.sm, .btn.icon-only.sm {
  width: 30px;
  height: 30px;
  min-height: 30px;
}

/* --------------------------------------------------------------------------
 * 5. COMPONENT: FORMS & INPUT CONTROLS
 * -------------------------------------------------------------------------- */
.pp-input, .form-control,
input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  background-color: var(--surface-sunken);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  min-height: 40px;
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

.pp-input:focus, .form-control:focus,
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-primary-subtle);
  background-color: var(--surface-card);
}

textarea {
  min-height: 90px;
  resize: vertical;
  line-height: var(--lh-base);
}

/* --------------------------------------------------------------------------
 * 6. COMPONENT: CARDS & CONTAINERS
 * -------------------------------------------------------------------------- */
.pp-card, .card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.pp-card.interactive:hover, .card.interactive:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.pp-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.pp-card-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Stat KPI Cards */
.pp-stat-card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-base);
}
.pp-stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-primary-border);
  box-shadow: var(--shadow-md);
}

.pp-stat-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--sp-1-5);
}

.pp-stat-number {
  font-size: var(--fs-2xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  margin: var(--sp-2) 0 var(--sp-1);
  line-height: 1.1;
}

.pp-stat-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.pp-stat-bg-icon {
  position: absolute;
  right: 14px;
  bottom: 12px;
  width: 44px;
  height: 44px;
  opacity: 0.08;
  color: var(--text-primary);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
 * 7. COMPONENT: BADGES & STATUS PILLS
 * -------------------------------------------------------------------------- */
.pp-badge, .badge, .status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px 9px;
  font-size: var(--fs-2xs);
  font-weight: 700;
  line-height: 1.3;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.pp-badge.success, .badge.success, .badge-ok {
  background-color: var(--state-success-bg);
  color: var(--state-success-ink);
  border: 1px solid var(--state-success-border);
}

.pp-badge.warning, .badge.warning, .badge-warn {
  background-color: var(--state-warning-bg);
  color: var(--state-warning-ink);
  border: 1px solid var(--state-warning-border);
}

.pp-badge.danger, .badge.danger, .badge-danger {
  background-color: var(--state-danger-bg);
  color: var(--state-danger-ink);
  border: 1px solid var(--state-danger-border);
}

.pp-badge.info, .badge.info, .badge-info {
  background-color: var(--state-info-bg);
  color: var(--state-info-ink);
  border: 1px solid var(--state-info-border);
}

.pp-badge.gold, .badge.gold {
  background-color: var(--brand-primary-subtle);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-border);
}

.pp-badge.neutral, .badge.neutral {
  background-color: var(--surface-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

/* --------------------------------------------------------------------------
 * 8. COMPONENT: RESPONSIVE DATA TABLES
 * -------------------------------------------------------------------------- */
.pp-table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background-color: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.pp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  text-align: left;
}

.pp-table th {
  padding: 12px 16px;
  background-color: var(--surface-raised);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.pp-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.pp-table tbody tr {
  transition: background-color var(--transition-fast);
}

.pp-table tbody tr:hover td {
  background-color: var(--surface-hover);
}

.pp-table tbody tr:last-child td {
  border-bottom: none;
}

.pp-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
 * 9. COMPONENT: GLOBAL TOAST STACK
 * -------------------------------------------------------------------------- */
.pp-toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100000;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--sp-2-5);
  pointer-events: none;
  max-width: 420px;
  width: calc(100vw - 32px);
}

@media (max-width: 768px) {
  .pp-toast-stack {
    top: 68px;
    bottom: auto;
    right: 16px;
    left: 16px;
    width: auto;
    flex-direction: column;
  }
}

.pp-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 14px 18px;
  background-color: var(--surface-overlay);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  animation: ppToastIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.2s, transform 0.2s;
  backdrop-filter: blur(12px);
}

.pp-toast.is-leaving {
  opacity: 0;
  transform: translateY(8px) scale(0.96);
}

@keyframes ppToastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.pp-toast-icon {
  flex-shrink: 0;
  margin-top: 1px;
}
.pp-toast.success .pp-toast-icon { color: var(--state-success-ink); }
.pp-toast.error   .pp-toast-icon { color: var(--state-danger-ink); }
.pp-toast.warning .pp-toast-icon { color: var(--state-warning-ink); }
.pp-toast.info    .pp-toast-icon { color: var(--state-info-ink); }

.pp-toast-body {
  flex: 1;
  min-width: 0;
}
.pp-toast-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  margin-bottom: 2px;
}
.pp-toast-message {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  line-height: var(--lh-snug);
}

.pp-toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  margin: -2px -4px 0 0;
  line-height: 1;
}
.pp-toast-close:hover {
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
 * 10. COMPONENT: COMMAND PALETTE (CMD + K)
 * -------------------------------------------------------------------------- */
.pp-cmd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 99999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 20px;
  animation: ppFadeIn 0.15s ease;
}

@keyframes ppFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.pp-cmd-dialog {
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 620px;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-subtle);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: ppCmdSlide 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ppCmdSlide {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.pp-cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
  background: var(--surface-subtle);
}

.pp-cmd-input-wrap .ic {
  color: var(--brand-primary);
  width: 20px;
  height: 20px;
}

.pp-cmd-input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-size: var(--fs-md);
  color: var(--text-primary);
  outline: none;
  padding: 0 !important;
  min-height: auto !important;
}

.pp-cmd-badge {
  font-size: var(--fs-2xs);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.pp-cmd-list {
  max-height: 380px;
  overflow-y: auto;
  padding: var(--sp-2);
}

.pp-cmd-group {
  padding: 8px 12px 4px;
  font-size: var(--fs-2xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.pp-cmd-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pp-cmd-item:hover, .pp-cmd-item.is-selected {
  background-color: var(--brand-primary-subtle);
  color: var(--text-primary);
  border-left: 3px solid var(--brand-primary);
  padding-left: 11px;
}

.pp-cmd-item .ic, .pp-cmd-item .li {
  color: var(--brand-primary);
}

.pp-cmd-item-label {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--text-primary);
}

.pp-cmd-item-desc {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.pp-cmd-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-subtle);
  font-size: var(--fs-2xs);
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
 * 11. MODERN APPLICATION SHELL (TOPBAR, SIDEBAR & MOBILE NAVIGATION)
 * -------------------------------------------------------------------------- */

/* Desktop & Tablet Top App Bar */
.pp-topbar {
  position: fixed;
  top: 0;
  left: 260px;
  right: 0;
  height: 60px;
  background-color: var(--surface-subtle);
  border-bottom: 1px solid var(--border-default);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: var(--sp-4);
  transition: left var(--transition-base);
}

body.sidebar-collapsed .pp-topbar {
  left: 76px;
}

@media (max-width: 1024px) {
  .pp-topbar {
    left: 0;
    padding: 0 16px;
  }
}

.pp-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.pp-topbar-breadcrumb {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--sp-1-5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pp-topbar-breadcrumb b {
  color: var(--text-primary);
  font-weight: 700;
}

/* Spotlight Search Trigger */
.pp-top-search-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2-5);
  background: var(--surface-sunken);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  padding: 7px 16px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  cursor: pointer;
  min-width: 260px;
  transition: all var(--transition-fast);
}

.pp-top-search-btn:hover {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.pp-top-search-btn kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-3xs);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}

.pp-topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2-5);
  margin-left: auto;
}

.pp-theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pp-theme-toggle-btn:hover {
  background: var(--surface-raised);
  color: var(--brand-primary);
  border-color: var(--brand-primary-border);
}

.pp-top-profile {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-decoration: none;
}

.pp-top-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand-primary-subtle);
  border: 1px solid var(--brand-primary-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-primary);
  font-weight: 700;
}

/* Sidebar Modern Overhaul */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 260px;
  background-color: var(--surface-subtle);
  border-right: 1px solid var(--border-default);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-base), transform var(--transition-base);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  position: relative;
  min-height: 60px;
}

.sidebar-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--brand-primary-border);
  box-shadow: 0 0 12px var(--brand-primary-glow);
  flex-shrink: 0;
}

.sidebar-brand-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: opacity var(--transition-fast);
}

.sidebar-brand-title {
  font-size: var(--fs-base);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.sidebar-brand-sub {
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-top: 2px;
}

.sidebar-toggle-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.sidebar-toggle-btn:hover {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.sidebar-nav {
  flex: 1;
  padding: var(--sp-3) var(--sp-2-5);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-sep {
  padding: var(--sp-3) var(--sp-2-5) var(--sp-1);
  font-size: var(--fs-3xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-item .icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.nav-item:hover {
  background-color: var(--surface-hover);
  color: var(--text-primary);
}

.nav-item:hover .icon {
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--brand-primary-subtle);
  color: var(--brand-primary);
  font-weight: 600;
}

.nav-item.active .icon {
  color: var(--brand-primary);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  background-color: var(--brand-primary);
  box-shadow: 0 0 8px var(--brand-primary-glow);
}

/* Sidebar Collapsed State (Desktop) */
body.sidebar-collapsed .sidebar {
  width: 76px;
}

body.sidebar-collapsed .sidebar .sidebar-brand-text,
body.sidebar-collapsed .sidebar .nav-sep,
body.sidebar-collapsed .sidebar .nav-item span:not(.icon),
body.sidebar-collapsed .sidebar .sidebar-footer span:not(.icon) {
  display: none !important;
}

body.sidebar-collapsed .sidebar .nav-item {
  justify-content: center;
  padding: 10px 0;
}

body.sidebar-collapsed .sidebar .sidebar-header {
  justify-content: center;
  padding: var(--sp-3) 0;
}

body.sidebar-collapsed .sidebar .sidebar-toggle-btn {
  position: static;
  transform: none;
  margin-top: 6px;
}

/* Main Content Area */
.main-content {
  margin-left: 260px;
  margin-top: 0;
  padding: var(--sp-6) var(--sp-8);
  min-height: 100vh;
  background-color: var(--surface-ground);
  transition: margin-left var(--transition-base);
  width: calc(100% - 260px);
  box-sizing: border-box;
}

.pp-topbar ~ .main-content {
  margin-top: 60px;
  min-height: calc(100vh - 60px);
}

body.sidebar-collapsed .main-content {
  margin-left: 76px;
  width: calc(100% - 76px);
}

.content-wrapper {
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* Mobile & Tablet Overrides */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px !important;
    box-shadow: var(--shadow-lg);
  }

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

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    padding: var(--sp-4) var(--sp-4) 84px !important;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1040;
  }

  .sidebar-overlay.active {
    display: block;
  }
}

/* Modern Mobile Bottom Navigation (5 Core Tabs) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background-color: var(--surface-subtle);
  border-top: 1px solid var(--border-default);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
  z-index: 1020;
  padding-bottom: env(safe-area-inset-bottom);
}

@media (max-width: 1024px) {
  .bottom-nav {
    display: block;
  }
}

.bottom-nav-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 0;
  transition: all var(--transition-fast);
  min-height: var(--touch-target);
  user-select: none;
}

.bottom-nav-item:active {
  transform: scale(0.92);
}

.bottom-nav-item.active {
  color: var(--brand-primary);
}

.bottom-nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav-label {
  font-size: var(--fs-3xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}


/* --------------------------------------------------------------------------
 * 12. SHELL FIXES FROM THE OCT 2026 AUDIT
 * -------------------------------------------------------------------------- */

/* One top bar on every width. The old mobile header sat underneath it. */
.mobile-header { display: none !important; }

.pp-topbar .menu-toggle#menuToggleTop {
  display: none !important;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
}

@media (max-width: 1024px) {
  .pp-topbar .menu-toggle#menuToggleTop { display: inline-flex !important; }
}

@media (max-width: 768px) {
  .pp-topbar { padding: 0 10px; gap: 8px; }
  .pp-topbar-breadcrumb { display: none; }
  .pp-top-search-btn { min-width: 0; flex: 1 1 auto; padding: 8px 12px; }
  .pp-top-search-btn .pp-top-search-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pp-top-search-btn kbd { display: none; }
  .pp-topbar-right { gap: 6px; flex: none; }
  .pp-topbar-right .pp-status-label,
  .pp-top-profile .pp-top-name,
  .pp-top-profile .pp-top-role { display: none; }
  .pp-topbar-right .pp-badge.success { padding: 10px !important; }
  .pp-top-profile { padding: 3px; }
  .pp-theme-toggle-btn { width: 38px; height: 38px; }
}

@media (max-width: 380px) {
  .pp-top-search-btn .pp-top-search-text { display: none; }
  .pp-top-search-btn { flex: 0 0 auto; }
}

/* Bottom bar: exactly five equal tabs, the "More" button looks like the rest. */
.bottom-nav-container { grid-template-columns: repeat(5, minmax(0, 1fr)); overflow: visible; }
.bottom-nav-item { min-width: 0; font: inherit; }
.bottom-nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Leave room so the floating saved-messages button never sits on the last row. */
.main-content { padding-bottom: 104px; }
@media (max-width: 1024px) {
  .main-content { padding-bottom: 156px !important; }
}

/* Scrollable tab rows on phones (Work, People and any .tabs strip). */
@media (max-width: 640px) {
  .ppui .tabs, .ppui .pp-tabs, .ppui nav.tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .ppui .tabs::-webkit-scrollbar, .ppui .pp-tabs::-webkit-scrollbar { display: none; }
  .ppui .tabs > *, .ppui .pp-tabs > * { flex: 0 0 auto; white-space: nowrap; }
}

/* --------------------------------------------------------------------------
 * 13. SIDEBAR, PROFILE MENU AND MOBILE TOP BAR (Oct 2026, round 4)
 * The sidebar header is the same 60px band as the top bar so the two line up.
 * Collapsing gives a 76px icon rail; there is no hover "peek" any more — it
 * slid the full-width panel over the page with the labels still hidden.
 * -------------------------------------------------------------------------- */
.sidebar .sidebar-header {
  height: 60px; min-height: 60px; padding: 0 16px !important;
  display: flex; align-items: center; gap: 10px; text-align: left;
  border-bottom: 1px solid var(--border-default);
  flex: none;
}
.sidebar .sidebar-home { display: inline-flex; flex: none; border-radius: 10px; }
.sidebar .sidebar-home:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.sidebar .sidebar-logo {
  width: 36px !important; height: 36px !important; margin: 0 !important;
  border-radius: 10px; border: 1px solid var(--border-default); box-shadow: none; display: block;
}
.sidebar .sidebar-brand-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar .sidebar-brand-title { font-size: 15px; font-weight: 800; color: var(--text-primary); line-height: 1.15; }
.sidebar .sidebar-brand-sub { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; margin-top: 2px; white-space: nowrap; }

.sidebar .sidebar-nav { padding: 10px 10px 16px !important; }
.sidebar .nav-item { padding: 8px 12px !important; margin: 0 !important; }
.sidebar .nav-item .icon { margin-right: 0 !important; width: 20px; }
.sidebar .nav-sep { margin: 14px 4px 4px !important; padding: 10px 8px 0 !important; border-top: 1px solid var(--border-subtle); }
.sidebar .nav-sep:first-child { border-top: none; margin-top: 0 !important; padding-top: 4px !important; }

.sidebar .sidebar-footer {
  flex: none; padding: 10px !important; border-top: 1px solid var(--border-default);
  position: sticky; bottom: 0; background: var(--surface-subtle);
}
.sidebar-collapse-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-md);
  background: transparent; border: 1px solid transparent; color: var(--text-secondary);
  font: inherit; font-size: var(--fs-sm); font-weight: 500; cursor: pointer;
}
.sidebar-collapse-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.sidebar-collapse-btn:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: -2px; }
.sidebar-collapse-btn .ic { width: 18px; height: 18px; transition: transform var(--transition-base); flex: none; }
@media (max-width: 1024px) { .sidebar .sidebar-footer { display: none; } }

@media (min-width: 1025px) {
  body.sidebar-collapsed .sidebar, body.sidebar-collapsed .sidebar:hover { width: 76px !important; box-shadow: none !important; }
  body.sidebar-collapsed .sidebar .sidebar-header { justify-content: center; padding: 0 !important; }
  body.sidebar-collapsed .sidebar .sidebar-brand-text,
  body.sidebar-collapsed .sidebar .nav-sep span,
  body.sidebar-collapsed .sidebar .nav-item span:not(.icon),
  body.sidebar-collapsed .sidebar .sidebar-collapse-label { display: none !important; }
  body.sidebar-collapsed .sidebar .nav-sep { display: block !important; margin: 8px 14px !important; padding: 0 !important; height: 0; border-top: 1px solid var(--border-subtle); }
  body.sidebar-collapsed .sidebar .nav-sep:first-child { display: none !important; }
  body.sidebar-collapsed .sidebar .sidebar-nav { padding: 10px 12px !important; }
  body.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 10px 0 !important; }
  body.sidebar-collapsed .sidebar .sidebar-collapse-btn { justify-content: center; padding: 8px 0; }
  body.sidebar-collapsed .sidebar .sidebar-collapse-btn .ic { transform: rotate(180deg); }
}

/* Top bar controls: fixed sizes so nothing stretches. */
.pp-topbar .pp-theme-toggle-btn { width: 38px !important; height: 38px; margin: 0 !important; padding: 0 !important; flex: none; }
.pp-top-brand { display: none; align-items: center; gap: 8px; text-decoration: none; color: var(--text-primary); flex: none; }
.pp-top-brand-logo { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border-default); }
.pp-top-brand-name { font-weight: 800; font-size: 15px; letter-spacing: -.01em; }

/* Profile menu */
.pp-profile { position: relative; flex: none; }
.pp-profile .pp-top-profile { font: inherit; font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
.pp-profile .pp-top-profile:hover, .pp-profile.open .pp-top-profile { border-color: var(--border-strong); background: var(--surface-raised); }
.pp-profile .pp-top-profile:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.pp-top-caret { width: 14px; height: 14px; color: var(--text-muted); transition: transform var(--transition-fast); }
.pp-profile.open .pp-top-caret { transform: rotate(180deg); }
.pp-profile-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; z-index: 1200;
  background: var(--surface-card); border: 1px solid var(--border-default); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.28); padding: 6px;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .12s ease, transform .12s ease, visibility 0s linear .12s;
}
.pp-profile-menu::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; } /* hover bridge */
.pp-profile.open .pp-profile-menu { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.pp-profile-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 4px; }
.pp-profile-name { font-weight: 700; color: var(--text-primary); font-size: 14px; }
.pp-profile-role { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.pp-profile-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px;
  color: var(--text-primary); text-decoration: none; font: inherit; font-size: 14px; font-weight: 500;
  background: none; border: none; cursor: pointer; text-align: left;
}
.pp-profile-item .ic { width: 16px; height: 16px; color: var(--text-secondary); }
.pp-profile-item:hover, .pp-profile-item:focus-visible { background: var(--surface-hover); outline: none; }
.pp-profile-item.danger, .pp-profile-item.danger .ic { color: var(--state-danger-ink); }
.pp-profile-sep { height: 1px; background: var(--border-subtle); margin: 4px 0; }

@media (max-width: 1024px) {
  .pp-top-brand { display: inline-flex; }
}
@media (max-width: 768px) {
  .pp-topbar-right .pp-badge.success { display: none !important; }   /* status dot: hidden on phones */
  .pp-top-search-btn { flex: 0 0 auto; width: 38px; height: 38px; padding: 0; justify-content: center; margin-left: auto; }
  .pp-top-search-btn .pp-top-search-text { display: none; }
  .pp-top-caret { display: none; }
  .pp-profile-menu { right: -4px; min-width: 210px; }
}
@media (max-width: 360px) {
  .pp-top-brand-name { display: none; }
}

/* Horizontal scroller that pp-modern.js puts around every table in the
   content area, so wide tables scroll inside themselves while narrow ones
   still fill the full width. */
.pp-table-scroll { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pp-table-scroll > table { min-width: 100%; }

/* Form controls take the app font (browsers default buttons/selects to the
   system font, which is why some buttons rendered in Arial). */
button, input, select, textarea { font-family: inherit; }

/* Phones: search icon sits with the other top-bar controls on the right. */
@media (max-width: 768px) {
  .pp-topbar { justify-content: flex-start; }
  .pp-topbar .pp-top-search-btn { margin-left: auto; }
  .pp-topbar .pp-topbar-right { margin-left: 0; }
}

/* Tablet / small laptop (sidebar is a drawer here): the brand is shown, so the
   breadcrumb is redundant and was being cut to "Fi…"; search text stays one line. */
.pp-top-search-btn .pp-top-search-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 1200px) {
  .pp-topbar-breadcrumb { display: none; }
}
@media (min-width: 769px) and (max-width: 1200px) {
  .pp-topbar .pp-top-search-btn { min-width: 0; flex: 0 1 340px; margin-left: auto; }
  .pp-topbar .pp-topbar-right { margin-left: 0; }
}
/* Sidebar footer: a hairline shadow shows the list continues underneath it. */
.sidebar .sidebar-footer { box-shadow: 0 -8px 12px -8px rgba(0,0,0,.25); }

/* Safety net: the collapsed rail is a desktop layout. If the class is ever
   present below 1025px (old cached script, odd resize), undo every effect. */
@media (max-width: 1024px) {
  body.sidebar-collapsed .pp-topbar { left: 0 !important; }
  body.sidebar-collapsed .main-content { margin-left: 0 !important; width: 100% !important; }
  body.sidebar-collapsed .sidebar { width: 280px !important; }
  body.sidebar-collapsed .sidebar .sidebar-header { justify-content: flex-start !important; padding: 0 16px !important; }
  body.sidebar-collapsed .sidebar .sidebar-brand-text { display: flex !important; }
  body.sidebar-collapsed .sidebar .nav-sep { display: flex !important; }
  body.sidebar-collapsed .sidebar .nav-item span:not(.icon) { display: inline !important; }
  body.sidebar-collapsed .sidebar .nav-item { justify-content: flex-start !important; padding: 8px 12px !important; }
}

/* Tab strips: a mouse click must not leave the browser's square focus box around the tab (seen on
   Finances → Stock Ledger and Reports → Settings); keyboard users still get a clear inset ring. */
:is(.fin-tab, .rp-tab, .set-tab, [role="tab"]):focus:not(:focus-visible) { outline: none; }
:is(.fin-tab, .rp-tab, .set-tab, [role="tab"]):focus-visible { outline: 2px solid var(--brand-primary); outline-offset: -3px; border-radius: 6px; }

/* --------------------------------------------------------------------------
 * 14. GLOBAL FLUID TRANSITIONS & WORKFLOW COMPONENTS (OPERATIONS REDESIGN)
 * -------------------------------------------------------------------------- */

/* (No entrance animation on .content-wrapper: a transform there — even the final
   translateY(0) kept by animation-fill-mode — makes every position:fixed popup inside the
   page position against the content area instead of the screen.) */

/* Button & interactive element tactile micro-interactions */
button:active:not(:disabled),
.pp-a:active:not(:disabled),
.btn-small:active:not(:disabled),
.sh-btn:active:not(:disabled),
.dsp-btn:active:not(:disabled),
.cs-btn:active:not(:disabled),
.ps-btn:active:not(:disabled),
[role="button"]:active:not(:disabled) {
  transform: scale(0.97);
}

/* Universal Visual Workflow Stepper */
.pp-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl, 16px);
  padding: 12px 16px;
  margin-bottom: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.pp-step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 0;
  min-width: 140px;
  padding: 8px 12px;
  border-radius: var(--radius-md, 10px);
  transition: all var(--transition-base);
  opacity: 0.65;
  position: relative;
}

.pp-step:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 2px;
  background: var(--border-default);
}

.pp-step.active {
  opacity: 1;
  background: var(--brand-primary-subtle);
  border: 1px solid var(--brand-primary-border);
}

.pp-step.done {
  opacity: 0.95;
}

.pp-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1.5px solid var(--border-strong);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 800;
  flex: none;
  transition: all var(--transition-fast);
}

.pp-step.active .pp-step-num {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 0 10px var(--brand-primary-glow);
}

.pp-step.done .pp-step-num {
  background: var(--state-success);
  border-color: var(--state-success);
  color: #ffffff;
}

.pp-step-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pp-step-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pp-step.active .pp-step-title {
  color: var(--brand-primary-hover);
}

.pp-step-desc {
  font-size: var(--fs-3xs);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .pp-stepper {
    padding: 10px 12px;
    gap: 6px;
  }
  .pp-step {
    min-width: 120px;
    padding: 6px 8px;
  }
  .pp-step-desc {
    display: none;
  }
}

/* Dynamic Operational Guidance Banner */
.pp-guide-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-lg, 12px);
  margin-bottom: 18px;
  font-size: var(--fs-sm);
  line-height: 1.45;
  transition: all var(--transition-base);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.pp-guide-banner .pp-guide-icon {
  font-size: 22px;
  flex: none;
  line-height: 1;
}

.pp-guide-banner .pp-guide-body {
  flex: 1 1 auto;
  color: var(--text-primary);
}

.pp-guide-banner.info {
  background: var(--brand-primary-subtle);
  border: 1px solid var(--brand-primary-border);
}

.pp-guide-banner.warn {
  background: var(--state-warning-bg);
  border: 1px solid var(--state-warning-border);
}

.pp-guide-banner.success {
  background: var(--state-success-bg);
  border: 1px solid var(--state-success-border);
}

.pp-guide-banner.ready {
  background: linear-gradient(135deg, var(--state-success-bg) 0%, var(--brand-primary-subtle) 100%);
  border: 1px solid var(--state-success-border);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
}



/* --------------------------------------------------------------------------
 * Search palette (Cmd/Ctrl+K) layout: the input is a plain full-width field (the
 * generic input:focus rules drew a small box with a glow inside the header), rows keep
 * the label on one line with the status on the right, and on phones the status drops
 * under the label instead of cutting both off.
 * -------------------------------------------------------------------------- */
.pp-cmd-input-wrap input#ppCmdInput,
.pp-cmd-input-wrap input#ppCmdInput:focus,
.pp-cmd-input-wrap input#ppCmdInput:focus-visible {
  flex: 1 1 auto !important; width: 100% !important; min-width: 0 !important;
  background: transparent !important; border: 0 !important; border-radius: 0 !important;
  box-shadow: none !important; outline: none !important;
  padding: 0 !important; margin: 0 !important; height: auto !important; min-height: 30px !important;
  font-size: 17px !important; line-height: 1.5 !important; color: var(--text-primary) !important;
}
.pp-cmd-input-wrap { padding: 14px 18px; }
.pp-cmd-input-wrap .ic { flex: none; }
.pp-cmd-badge { cursor: pointer; }
.pp-cmd-list { max-height: min(62vh, 560px); overscroll-behavior: contain; }
.pp-cmd-item { min-width: 0; min-height: 44px; border-left: 3px solid transparent; padding-left: 11px; }
.pp-cmd-item-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; color: var(--brand-primary); }
.pp-cmd-item-icon .ic, .pp-cmd-item-icon svg { width: 18px; height: 18px; }
.pp-cmd-item-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-cmd-item-desc { flex: 0 1 auto; min-width: 0; max-width: 45%; text-align: right; }
@media (max-width: 640px) {
  .pp-cmd-backdrop { padding: 10px 8px; }
  .pp-cmd-dialog { max-height: calc(100dvh - 20px); }
  .pp-cmd-list { max-height: calc(100dvh - 92px); }
  .pp-cmd-footer { display: none; }
  .pp-cmd-item { flex-wrap: wrap; row-gap: 2px; padding-top: 9px; padding-bottom: 9px; }
  .pp-cmd-item-label { flex: 1 1 calc(100% - 40px); white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .pp-cmd-item-desc { flex: 1 1 100%; max-width: none; margin-left: 32px; text-align: left; white-space: nowrap; }
}
