    :root {
      --primary: #4f46e5;
      --primary-hover: #4338ca;
      --primary-subtle: #eef2ff;
      --primary-border: #c7d2fe;
      --text: #0f172a;
      --text-muted: #64748b;
      --bg: #f8fafc;
      --card-bg: #ffffff;
      --border: #e2e8f0;
      --border-subtle: #f1f5f9;
      --header-bg: rgba(255, 255, 255, 0.92);
      --nav-bg: #f1f5f9;
      --nav-btn-active: #ffffff;
      --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
      --table-row-hover: #f8fafc;
    }
    body.theme-meesho {
      --primary: #f43397;
      --primary-hover: #db2777;
      --primary-subtle: #fdf2f8;
      --primary-border: #fbcfe8;
      --text: #1e1b4b;
      --text-muted: #6b7280;
      --bg: #fff5f8;
      --card-bg: #ffffff;
      --border: #fce7f3;
      --border-subtle: #fdf2f8;
      --header-bg: rgba(255, 255, 255, 0.94);
      --nav-bg: #fce7f3;
      --nav-btn-active: #ffffff;
      --shadow: 0 4px 10px -2px rgba(244, 51, 151, 0.08);
      --table-row-hover: #fff1f7;
    }
    body.theme-dark {
      --primary: #818cf8;
      --primary-hover: #6366f1;
      --primary-subtle: #1e1b4b;
      --primary-border: #3730a3;
      --text: #f8fafc;
      --text-muted: #94a3b8;
      --bg: #090d16;
      --card-bg: #111827;
      --border: #1f2937;
      --border-subtle: #1e293b;
      --header-bg: rgba(17, 24, 39, 0.92);
      --nav-bg: #1f2937;
      --nav-btn-active: #374151;
      --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
      --table-row-hover: #1f2937;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      background: var(--bg);
      color: var(--text);
      line-height: 1.5;
      transition: background 0.2s ease, color 0.2s ease;
      -webkit-font-smoothing: antialiased;
    }
    code, pre { font-family: 'JetBrains Mono', monospace; }
    header {
      background: var(--header-bg);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      border-bottom: 1px solid var(--border);
      padding: 0.85rem 2rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
      position: sticky;
      top: 0;
      z-index: 40;
      gap: 1rem;
      flex-wrap: wrap;
    }
    .brand { display: flex; align-items: center; gap: 0.85rem; }
    .brand-logo {
      width: 40px; height: 40px;
      background: var(--primary);
      color: #fff;
      border-radius: 10px;
      display: flex; align-items: center; justify-content: center;
      font-weight: 800; font-size: 1.25rem;
      box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    }
    .brand-text h1 { font-size: 1.12rem; font-weight: 800; letter-spacing: -0.02em; }
    .brand-text p { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
    .global-search-container {
      display: flex;
      align-items: center;
      background: var(--card-bg);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 0.2rem 0.5rem 0.2rem 0.75rem;
      transition: all 0.2s ease;
      box-shadow: 0 1px 3px rgba(0,0,0,0.04);
      min-width: 290px;
    }
    .global-search-container:focus-within {
      border-color: var(--primary);
      box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
    }
    .global-search-input {
      border: none;
      outline: none;
      background: transparent;
      color: var(--text);
      font-size: 0.84rem;
      font-family: inherit;
      width: 100%;
      padding: 0.35rem 0.25rem;
    }
    nav { 
      display: flex; 
      gap: 0.3rem; 
      background: var(--nav-bg); 
      padding: 0.3rem; 
      border-radius: 10px; 
      flex-wrap: wrap; 
      border: 1px solid var(--border);
    }
    .nav-btn {
      background: transparent;
      border: none;
      padding: 0.5rem 0.95rem;
      border-radius: 8px;
      font-size: 0.82rem;
      font-weight: 600;
      color: var(--text-muted);
      cursor: pointer;
      transition: all 0.18s ease;
    }
    .nav-btn:hover { color: var(--text); }
    .nav-btn.active {
      background: var(--nav-btn-active);
      color: var(--primary);
      box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    }
    .theme-select {
      background: var(--card-bg);
      color: var(--text);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 0.4rem 0.75rem;
      font-size: 0.8rem;
      font-weight: 600;
      outline: none;
      cursor: pointer;
    }
    main { max-width: 1320px; margin: 1.75rem auto; padding: 0 1.25rem; }
    .view-panel { display: none; }
    .view-panel.active { display: block; animation: fadeIn 0.22s ease-out; }
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(4px); }
      to { opacity: 1; transform: translateY(0); }
    }
    .card {
      background: var(--card-bg);
      border: 1px solid var(--border);
      border-radius: 14px;
      padding: 1.35rem;
      box-shadow: var(--shadow);
      margin-bottom: 1.35rem;
    }
    .kpi-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 1.1rem;
      margin-bottom: 1.35rem;
    }
    .kpi-card {
      background: var(--card-bg);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 1.25rem 1.35rem;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      position: relative;
    }
    .kpi-title { 
      font-size: 0.75rem; 
      text-transform: uppercase; 
      letter-spacing: 0.06em; 
      color: var(--text-muted); 
      font-weight: 700; 
    }
    .kpi-value { 
      font-size: 1.95rem; 
      font-weight: 800; 
      color: var(--text); 
      margin: 0.35rem 0 0.15rem; 
      letter-spacing: -0.03em;
    }
    .kpi-sub { font-size: 0.77rem; color: var(--text-muted); font-weight: 500; }

    /* Compact dashboard KPIs */
    .kpi-grid.compact {
      grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
      gap: 0.55rem;
      margin-bottom: 0;
    }
    .kpi-card.compact {
      padding: 0.65rem 0.75rem;
      border-radius: 10px;
      min-height: 0;
    }
    .kpi-card.compact .kpi-title {
      font-size: 0.65rem;
      letter-spacing: 0.04em;
    }
    .kpi-card.compact .kpi-value {
      font-size: 1.2rem;
      margin: 0.2rem 0 0.1rem;
    }
    .kpi-card.compact .kpi-sub {
      font-size: 0.68rem;
      line-height: 1.25;
    }
    .kpi-card.compact.hero {
      grid-column: span 2;
      padding: 0.75rem 0.9rem;
      background: var(--primary-subtle);
      border-color: var(--primary-border);
    }
    .kpi-card.compact.hero .kpi-value {
      font-size: 1.55rem;
    }
    .kpi-card.compact.clickable {
      cursor: pointer;
      transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    }
    .kpi-card.compact.clickable:hover {
      transform: translateY(-1px);
      border-color: var(--primary);
      box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 12%, transparent);
    }
    .kpi-card.compact.clickable:active {
      transform: translateY(0);
    }
    .dash-day-strip {
      margin-top: 0.55rem;
      padding: 0.55rem 0.7rem;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: var(--border-subtle);
      display: flex;
      flex-wrap: wrap;
      gap: 0.65rem 1.1rem;
      align-items: center;
      cursor: pointer;
      transition: border-color 0.12s ease, background 0.12s ease;
      font-size: 0.78rem;
    }
    .dash-day-strip.has-repeat { border-color: #10b981; box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.28); }
    .repeat-alert {
      margin-top: 0.55rem; padding: 0.6rem 0.8rem; border-radius: 10px;
      background: #ecfdf5; border: 1px solid #a7f3d0; border-left: 4px solid #10b981;
      color: #064e3b; font-size: 0.82rem;
    }
    .repeat-alert .ra-title { font-weight: 800; cursor: pointer; display: flex; justify-content: space-between; gap: 0.5rem; }
    .repeat-alert .ra-title .ra-open { font-weight: 600; color: #047857; white-space: nowrap; }
    .repeat-alert .ra-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.45rem; }
    .repeat-chip {
      background: #fff; color: #064e3b; border: 1px solid #6ee7b7; border-radius: 9999px;
      padding: 0.18rem 0.6rem; font-size: 0.76rem; font-weight: 700; cursor: pointer;
    }
    .repeat-chip:hover { background: #d1fae5; }
    .badge-multi { background: #eef2ff; color: #3730a3; border-color: #c7d2fe; }
    .dash-day-strip.has-multi { box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.28); }
    .dash-day-strip.has-repeat.has-multi { box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.28), 0 0 0 4px rgba(99, 102, 241, 0.22); }
    .multi-alert {
      margin-top: 0.55rem; padding: 0.6rem 0.8rem; border-radius: 10px;
      background: #eef2ff; border: 1px solid #c7d2fe; border-left: 4px solid #6366f1;
      color: #312e81; font-size: 0.82rem;
    }
    .multi-alert .ra-title { font-weight: 800; cursor: pointer; display: flex; justify-content: space-between; gap: 0.5rem; }
    .multi-alert .ra-title .ra-open { font-weight: 600; color: #4338ca; white-space: nowrap; }
    .multi-alert .ra-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.45rem; }
    .multi-chip {
      background: #fff; color: #312e81; border: 1px solid #a5b4fc; border-radius: 9999px;
      padding: 0.18rem 0.6rem; font-size: 0.76rem; font-weight: 700; cursor: pointer;
    }
    .multi-chip:hover { background: #e0e7ff; }
    .multi-chip .ra-why { font-weight: 500; color: #4338ca; }
    .cal-multi-badge {
      background: #6366f1; color: #fff; border-radius: 5px; font-size: 0.66rem; font-weight: 800;
      padding: 2px 3px; margin-top: 2px; text-align: center; line-height: 1.15; overflow-wrap: anywhere;
    }
    @media (max-width: 720px) { .cal-multi-badge .rp-word, .cal-multiorder-badge .rp-word { display: none; } }
    .cal-multiorder-badge { background:#dbeafe; color:#1e40af; border:1px solid #93c5fd; border-radius:5px; font-size:.66rem; font-weight:800; padding:2px 3px; margin-top:2px; text-align:center; line-height:1.15; overflow-wrap:anywhere; }
    .repeat-chip .ra-why { font-weight: 500; color: #047857; }
    .dash-day-strip:hover {
      border-color: var(--primary);
      background: var(--primary-subtle);
    }
    .dash-day-strip strong {
      font-weight: 800;
      color: var(--text);
    }
    .dash-day-strip .muted {
      color: var(--text-muted);
      font-weight: 600;
    }
    .dash-top {
      display: grid;
      grid-template-columns: 1.35fr 1fr;
      gap: 1.15rem;
      margin-bottom: 1.15rem;
      align-items: start;
    }
    .dash-section-title {
      font-size: 0.72rem;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text-muted);
      margin: 0 0 0.5rem;
    }
    .dash-section-title strong {
      color: var(--text);
      font-size: 0.88rem;
      text-transform: none;
      letter-spacing: -0.01em;
    }
    .dash-divider {
      height: 1px;
      background: var(--border);
      margin: 0.95rem 0;
    }
    .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.15rem; }
    .grid-2 > * { min-width: 0; } /* let wide tables scroll inside their card instead of stretching the page */
    @media (max-width: 960px) {
      .grid-2 { grid-template-columns: 1fr; }
      .dash-top { grid-template-columns: 1fr; }
    }
    @media (max-width: 720px) {
      header { padding: 0.75rem 1rem; }
      .global-search-container { min-width: 0; width: 100%; order: 3; flex-basis: 100%; }
      .brand-text h1 { font-size: 1rem; }
      nav { width: 100%; }
      .nav-btn { padding: 0.45rem 0.7rem; font-size: 0.78rem; }
      main { padding: 0 0.85rem; margin-top: 1.15rem; }
    }
    .drop-zone.drag-over {
      border-color: var(--primary);
      background: var(--primary-subtle);
      box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
    }
    .cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
    .cal-grid {
      display: grid;
      grid-template-columns: repeat(7, minmax(0, 1fr));
      gap: 6px;
      text-align: center;
    }
    .cal-day-name { 
      font-size: 0.75rem; 
      font-weight: 700; 
      color: var(--text-muted); 
      padding: 0.4rem 0; 
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }
    .cal-cell {
      min-height: 46px;
      border: 1px solid var(--border);
      border-radius: 7px;
      padding: 0.28rem;
      font-size: 0.76rem;
      cursor: pointer;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      transition: all 0.15s ease;
      background: var(--card-bg);
    }
    .cal-cell:hover { border-color: var(--primary); transform: translateY(-1px); }
    /* Days that had a repeat customer: green cell + green badge so they stand out */
    .cal-cell.has-orders.has-repeat, .cal-cell.has-repeat { background: #d1fae5; border: 2px solid #10b981; }
    .cal-cell.has-orders.has-repeat:hover { border-color: #059669; }
    .cal-cell.has-repeat .cal-day-num { color: #064e3b; }
    @media (max-width: 720px) { .cal-repeat-badge .rp-word { display: none; } }
    .cal-repeat-badge {
      background: #10b981; color: #fff; border-radius: 5px; font-size: 0.66rem; font-weight: 800;
      padding: 2px 3px; margin-top: 2px; text-align: center; line-height: 1.15; overflow-wrap: anywhere;
    }
    .cal-cell.empty { border: none; cursor: default; background: transparent; }
    .cal-cell.has-orders { 
      border-color: var(--primary-border); 
      background: var(--primary-subtle); 
    }
    .cal-badge {
      background: var(--card-bg);
      color: var(--primary);
      border: 1px solid var(--primary-border);
      border-radius: 5px;
      font-size: 0.68rem;
      font-weight: 700;
      padding: 2px 4px;
    }
    .badge {
      display: inline-flex;
      align-items: center;
      padding: 0.22rem 0.6rem;
      border-radius: 9999px;
      font-size: 0.72rem;
      font-weight: 700;
      border: 1px solid transparent;
    }
    .badge-repeat { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
    .badge-new { background: var(--primary-subtle); color: var(--primary); border-color: var(--primary-border); }
    .badge-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
    .badge-vip { background: #fefce8; color: #854d0e; border-color: #fef08a; }
    .badge-fraud { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
    tr.fraud-row > td { background: rgba(220, 38, 38, 0.09); }
    .fraud-banner {
      background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; border-left: 4px solid #dc2626;
      border-radius: 8px; padding: 0.7rem 0.9rem; font-size: 0.84rem; line-height: 1.4; margin-bottom: 1rem;
    }
    .fraud-form {
      border: 1px dashed #fca5a5; border-radius: 8px; padding: 0.75rem; margin-bottom: 1rem;
      display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
    }
    .btn-fraud { background: #dc2626; color: #fff; border: 1px solid #dc2626; }
    .btn-fraud:hover { background: #b91c1c; }
    .badge-courier { 
      background: var(--border-subtle); 
      color: var(--text); 
      border: 1px solid var(--border); 
      font-weight: 700; 
      font-size: 0.73rem; 
      white-space: nowrap;
    }
    .btn {
      background: var(--primary);
      color: #fff;
      border: none;
      padding: 0.55rem 1.05rem;
      font-size: 0.83rem;
      font-weight: 600;
      border-radius: 8px;
      cursor: pointer;
      transition: all 0.16s ease;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 0.45rem;
    }
    .btn:hover { background: var(--primary-hover); transform: translateY(-0.5px); }
    .btn-outline { 
      background: var(--card-bg); 
      color: var(--text); 
      border: 1px solid var(--border); 
    }
    .btn-outline:hover { background: var(--border-subtle); border-color: var(--text-muted); }
    .btn-danger { background: #dc2626; color: #fff; }
    .btn-danger:hover { background: #b91c1c; }
    .btn-xs { padding: 0.25rem 0.6rem; font-size: 0.72rem; border-radius: 6px; font-weight: 600; }
    .copy-pill {
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      background: var(--border-subtle);
      padding: 0.15rem 0.45rem;
      border-radius: 5px;
      cursor: pointer;
      transition: background 0.15s;
    }
    .copy-pill:hover { background: var(--primary-subtle); color: var(--primary); }
    .input-field {
      padding: 0.52rem 0.85rem;
      border: 1px solid var(--border);
      border-radius: 8px;
      font-size: 0.84rem;
      font-family: inherit;
      outline: none;
      background: var(--card-bg);
      color: var(--text);
      transition: all 0.15s ease;
    }
    .input-field:focus { 
      border-color: var(--primary); 
      box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
    }
    .table-container { width: 100%; overflow-x: auto; margin-top: 0.85rem; border-radius: 8px; }
    table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; font-size: 0.83rem; }
    th {
      background: var(--border-subtle);
      padding: 0.75rem 0.95rem;
      font-weight: 700;
      color: var(--text-muted);
      border-bottom: 1px solid var(--border);
      white-space: nowrap;
      font-size: 0.76rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    td {
      padding: 0.8rem 0.95rem;
      border-bottom: 1px solid var(--border-subtle);
      vertical-align: middle;
      background: var(--card-bg);
    }
    tr:last-child td { border-bottom: 1px solid var(--border); }
    tr:hover td { background: var(--table-row-hover); }
    .cust-link { 
      color: var(--primary); 
      text-decoration: none; 
      font-weight: 700; 
      cursor: pointer; 
    }
    .cust-link:hover { text-decoration: underline; }
    .drop-zone {
      border: 2px dashed var(--border);
      border-radius: 14px;
      padding: 2.75rem 1.5rem;
      text-align: center;
      background: var(--border-subtle);
      cursor: pointer;
      transition: all 0.2s ease;
    }
    .drop-zone:hover { border-color: var(--primary); background: var(--primary-subtle); }
    .modal-backdrop {
      position: fixed; inset: 0; background: rgba(15, 23, 42, 0.65);
      backdrop-filter: blur(5px);
      -webkit-backdrop-filter: blur(5px);
      display: none; align-items: center; justify-content: center; z-index: 100;
      padding: 1.25rem;
    }
    .modal-backdrop.open { display: flex; animation: fadeIn 0.18s ease-out; }
    .modal {
      background: var(--card-bg);
      color: var(--text);
      width: 100%;
      max-width: 800px;
      max-height: 88vh;
      border-radius: 16px;
      overflow-y: auto;
      padding: 1.75rem;
      position: relative;
      box-shadow: var(--shadow);
      border: 1px solid var(--border);
    }
    .modal-close {
      position: absolute; right: 1.35rem; top: 1.35rem;
      background: var(--border-subtle); border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted);
      width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
    }
    .modal-close:hover { color: var(--text); }
    .notice {
      font-size: 0.76rem;
      color: var(--text-muted);
      background: var(--border-subtle);
      border-left: 3px solid var(--primary);
      padding: 0.75rem 1rem;
      border-radius: 6px;
      margin-top: 1.75rem;
    }
    .tree-month-block {
      margin-bottom: 0.85rem;
      border: 1px solid var(--border);
      border-radius: 12px;
      overflow: hidden;
    }
    .tree-month-title {
      background: var(--border-subtle);
      padding: 0.7rem 1rem;
      font-weight: 800;
      font-size: 0.9rem;
      color: var(--text);
      border-bottom: 1px solid var(--border);
      cursor: pointer;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.5rem;
      user-select: none;
    }
    .tree-month-title:hover { background: var(--primary-subtle); }
    .tree-month-title .chev {
      font-size: 0.75rem;
      color: var(--text-muted);
      transition: transform 0.15s ease;
    }
    .tree-month-block.collapsed .tree-month-title .chev { transform: rotate(-90deg); }
    .tree-month-block.collapsed .tree-month-body { display: none; }
    .tree-month-body { background: var(--card-bg); }
    .tree-date-block {
      border-bottom: 1px solid var(--border-subtle);
      padding: 0.65rem 1rem 0.95rem;
      background: var(--card-bg);
    }
    .tree-date-block:last-child { border-bottom: none; }
    .tree-date-title {
      font-size: 0.82rem;
      font-weight: 700;
      color: var(--primary);
      margin: 0.25rem 0 0.45rem;
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      align-items: baseline;
    }
    .view-toggle {
      display: inline-flex;
      background: var(--nav-bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 0.2rem;
      gap: 0.15rem;
    }
    .view-toggle-btn {
      border: none;
      background: transparent;
      padding: 0.4rem 0.75rem;
      border-radius: 6px;
      font-size: 0.78rem;
      font-weight: 700;
      color: var(--text-muted);
      cursor: pointer;
      font-family: inherit;
    }
    .view-toggle-btn.active {
      background: var(--nav-btn-active);
      color: var(--primary);
      box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }
    .cust-summary-bar {
      margin-top: 0.85rem;
      padding: 0.55rem 0.85rem;
      background: var(--border-subtle);
      border: 1px solid var(--border);
      border-radius: 8px;
      font-size: 0.8rem;
      font-weight: 700;
      color: var(--text);
      display: flex;
      flex-wrap: wrap;
      gap: 0.35rem 1rem;
    }
    .cust-summary-bar span { color: var(--text-muted); font-weight: 600; }
    .cust-summary-bar strong { color: var(--text); font-weight: 800; }
    .table-scroll-max {
      max-height: 340px;
      overflow: auto;
    }
    .table-scroll-max thead th {
      position: sticky;
      top: 0;
      z-index: 2;
      background: var(--border-subtle);
    }
    .region-card {
      background: var(--card-bg);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 0.95rem;
      margin-bottom: 0.85rem;
    }
    .region-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-weight: 700;
      font-size: 0.86rem;
      margin-bottom: 0.45rem;
    }
    .region-states {
      display: flex;
      flex-wrap: wrap;
      gap: 0.45rem;
      margin-top: 0.5rem;
    }
    .state-pill {
      background: var(--border-subtle);
      border: 1px solid var(--border);
      padding: 0.22rem 0.6rem;
      border-radius: 6px;
      font-size: 0.74rem;
      color: var(--text);
    }
    .state-pill strong { color: var(--primary); }


    /* Shipment workspace: focused sub-navigation and responsive sections */
    .shipment-subnav {
      display:flex; flex-wrap:wrap; gap:0.4rem; padding:0.35rem;
      border:1px solid var(--border); background:var(--nav-bg); border-radius:12px;
      margin:0 0 1rem;
    }
    .shipment-subtab {
      border:1px solid transparent; background:transparent; color:var(--text-muted);
      padding:0.62rem 0.9rem; border-radius:8px; font-family:inherit; font-size:0.82rem; font-weight:600; cursor:pointer;
      transition:all .15s ease; white-space:nowrap;
    }
    .shipment-subtab:hover { color:var(--text); background:var(--card-bg); }
    .shipment-subtab.active { color:var(--primary); background:var(--card-bg); border-color:var(--border); box-shadow:0 1px 4px rgba(0,0,0,.05); }
    .shipment-subview { display:none; animation:fadeIn .18s ease-out; }
    .shipment-subview.active { display:block; }
    .shipment-hero {
      display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap;
      padding:1.15rem 1.25rem; margin-bottom:1rem;
      border:1px solid var(--primary-border); border-radius:14px; background:var(--primary-subtle);
    }
    .shipment-hero h2 { font-size:1.08rem; font-weight:800; letter-spacing:-.02em; }
    .shipment-hero p { margin-top:.22rem; color:var(--text-muted); font-size:.8rem; max-width:720px; }
    .shipment-quick-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:1rem; }
    .shipment-quick-card { background:var(--card-bg); border:1px solid var(--border); border-radius:12px; padding:1rem; min-width:0; }
    .shipment-quick-card h3 { font-size:.86rem; font-weight:800; margin-bottom:.25rem; }
    .shipment-quick-card p { color:var(--text-muted); font-size:.76rem; line-height:1.5; margin-bottom:.7rem; }
    .shipment-quick-number { font-size:1.7rem; font-weight:800; letter-spacing:-.04em; margin:.15rem 0 .45rem; }
    .shipment-section-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:.75rem; flex-wrap:wrap; margin-bottom:.75rem; }
    .shipment-section-heading h3 { font-size:1rem; font-weight:800; }
    .shipment-section-heading p { font-size:.77rem; color:var(--text-muted); margin-top:.2rem; }
    .shipment-record-toolbar { display:flex; flex-wrap:wrap; gap:.5rem; align-items:center; }
    .shipment-record-toolbar .input-field { min-width:190px; }
    .shipment-note { border:1px solid var(--border); background:var(--border-subtle); padding:.75rem .9rem; border-radius:9px; font-size:.77rem; color:var(--text-muted); line-height:1.5; overflow-wrap:anywhere; }
    @media (max-width:960px) { .shipment-quick-grid { grid-template-columns:1fr 1fr; } }
    @media (max-width:640px) { .shipment-quick-grid { grid-template-columns:1fr; } .shipment-subtab { flex:1 1 calc(50% - .4rem); } .shipment-record-toolbar, .shipment-record-toolbar .input-field { width:100%; } }

    @media print {
      body * { visibility: hidden; }
      #printable-picklist, #printable-picklist * { visibility: visible; }
      #printable-picklist { position: absolute; left: 0; top: 0; width: 100%; border: none; box-shadow: none; padding: 0; }
    }

    /* Shipment analytics: fit wide tables to desktop panels and keep mobile scrolling inside each table. */
    #an-shipment-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    #an-sec-shipments .shipment-analytics-fit { width:100%; max-width:100%; overflow-x:auto; }
    #an-sec-shipments .shipment-analytics-table { width:100%; min-width:0 !important; table-layout:fixed; }
    #an-sec-shipments .shipment-analytics-table th,
    #an-sec-shipments .shipment-analytics-table td {
      white-space:normal; overflow-wrap:anywhere; padding:.58rem .5rem; font-size:.75rem; line-height:1.35;
    }
    #an-sec-shipment-cohort .shipment-analytics-table th:first-child { width:13%; }
    #an-sec-shipment-cohort .shipment-analytics-table th:nth-child(2) { width:8%; }
    #an-sec-shipment-cohort .shipment-analytics-table th:nth-child(3) { width:14%; }
    #an-sec-shipment-cohort .shipment-analytics-table th:nth-child(4) { width:16%; }
    #an-sec-shipment-cohort .shipment-analytics-table th:nth-child(5) { width:11%; }
    #an-sec-shipment-cohort .shipment-analytics-table th:nth-child(6) { width:17%; }
    #an-sec-shipment-cohort .shipment-analytics-table th:nth-child(7) { width:21%; }
    #an-sec-shipments .shipment-analytics-table th { font-size:.69rem; letter-spacing:.025em; }
    @media (max-width: 1050px) {
      #an-shipment-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    }
    @media (max-width: 720px) {
      #an-shipment-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      #an-sec-shipments .shipment-analytics-table { min-width:900px !important; table-layout:auto; }
      #an-sec-shipment-cohort .shipment-analytics-table { min-width:1020px !important; }
      #an-sec-shipments .shipment-analytics-table th,
      #an-sec-shipments .shipment-analytics-table td { white-space:nowrap; overflow-wrap:normal; }
    }

    /* ===== Server edition additions ===== */
    .user-menu { display:flex; align-items:center; gap:0.45rem; }
    .user-chip {
      font-size:0.78rem; font-weight:700; color:var(--text); background:var(--card-bg);
      border:1px solid var(--border); padding:0.38rem 0.65rem; border-radius:8px; white-space:nowrap;
    }
    .user-chip small { color:var(--text-muted); font-weight:600; }
    a.btn { text-decoration:none; }
    body.role-staff .admin-only { display:none !important; }
    .settings-grid { display:grid; grid-template-columns:1fr 1fr; gap:1.15rem; }
    .settings-grid > * { min-width:0; }
    @media (max-width:960px) { .settings-grid { grid-template-columns:1fr; } }
    .form-row { display:flex; flex-direction:column; gap:0.3rem; margin-bottom:0.75rem; }
    .form-row label { font-size:0.76rem; font-weight:700; color:var(--text-muted); }
    .settings-hint { font-size:0.74rem; color:var(--text-muted); margin-top:0.6rem; line-height:1.45; }
    .section-head { display:flex; justify-content:space-between; align-items:center; gap:0.75rem; flex-wrap:wrap; margin-bottom:0.65rem; }
    .section-head h3 { font-size:0.95rem; font-weight:800; }

    /* Sign-in / installer */
    .auth-wrap { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:1.25rem; }
    .auth-card { width:100%; max-width:410px; padding:1.75rem; }
    .auth-msg { border-radius:8px; padding:0.65rem 0.85rem; font-size:0.82rem; margin-bottom:0.9rem; line-height:1.45; }
    .auth-error { background:#fee2e2; color:#7f1d1d; border:1px solid #fca5a5; }
    .auth-ok { background:#ecfdf5; color:#064e3b; border:1px solid #a7f3d0; }
    .auth-remember { display:flex; align-items:center; gap:0.45rem; font-size:0.8rem; color:var(--text-muted); font-weight:600; margin:0.2rem 0 1rem; cursor:pointer; }
    .auth-foot { font-size:0.74rem; color:var(--text-muted); margin-top:0.9rem; text-align:center; }
