/* ============================================================
   Phone Enterprise WorkFlow
   style.css
   ============================================================ */

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

/* ------------------------------------------------------------
   1. CSS CUSTOM PROPERTIES
   ------------------------------------------------------------ */
:root {
  /* Page surfaces — warm off-whites, Shopify Polaris-aligned */
  --bg:              #f6f6f7;
  --card-bg:         #ffffff;

  /* Sidebar — warm near-black, refined accent rail */
  --sidebar-bg:      #1a1a1a;
  --sidebar-text:    #e3e3e3;
  --sidebar-muted:   #a8a8a8;
  --sidebar-hover:   rgba(255,255,255,.06);
  --sidebar-active:  rgba(255,255,255,.10);
  --sidebar-active-bar: #ffffff;
  --sidebar-section: #6b6b6b;
  --sidebar-width:   248px;

  /* Primary = warm near-black (Polaris), not flat blue */
  --primary:         #1a1a1a;
  --primary-hover:   #303030;
  --primary-light:   #ebebeb;

  /* Status colors — calmer, more refined */
  --success:         #008060;
  --success-light:   #e3f1df;
  --warning:         #b86200;
  --warning-light:   #fff1c2;
  --danger:          #d72c0d;
  --danger-light:    #fed3d1;
  --info:            #006eb8;
  --info-light:      #d6ecff;

  /* Text & borders */
  --text:            #202223;
  --text-secondary:  #6d7175;
  --text-muted:      #8c9196;
  --border:          #e1e3e5;
  --border-strong:   #c9cccf;
  --border-focus:    #1a1a1a;

  /* Accent (kept for charts/links/highlights) */
  --accent:          #2c6ecb;
  --accent-hover:    #205497;
  --accent-light:    #d6ecff;

  --radius-sm:       4px;
  --radius:          8px;
  --radius-md:       10px;
  --radius-lg:       12px;
  --radius-pill:     9999px;

  /* Refined shadow stack — softer, layered, Polaris-style */
  --shadow-sm:       0 1px 0 rgba(0,0,0,.05);
  --shadow:          0 1px 2px rgba(0,0,0,.05), 0 0 0 1px rgba(0,0,0,.04);
  --shadow-md:       0 4px 8px -2px rgba(0,0,0,.06), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg:       0 12px 24px -8px rgba(0,0,0,.10), 0 4px 8px -2px rgba(0,0,0,.06);

  --topbar-height:   60px;
  --font:            'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:       'SF Mono', 'Fira Mono', 'JetBrains Mono', 'Courier New', monospace;

  --transition:      140ms cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  /* Shopify-style dark — warm near-black surfaces, not blue-tinted */
  --bg:              #0e0e0e;
  --card-bg:         #1a1a1a;
  --sidebar-bg:      #0a0a0a;
  --sidebar-hover:   rgba(255,255,255,.06);
  --sidebar-active:  rgba(255,255,255,.10);
  --sidebar-text:    #e3e3e3;
  --sidebar-muted:   #a8a8a8;
  --sidebar-section: #6b6b6b;
  --text:            #e3e3e3;
  --text-secondary:  #a8a8a8;
  --text-muted:      #6b6b6b;
  --border:          #2c2c2c;
  --border-strong:   #3a3a3a;
  --border-focus:    #ffffff;
  --primary:         #ffffff;
  --primary-hover:   #e3e3e3;
  --primary-light:   rgba(255,255,255,.08);
  --shadow-sm:       0 1px 0 rgba(0,0,0,.4);
  --shadow:          0 1px 2px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.04);
  --shadow-md:       0 4px 8px -2px rgba(0,0,0,.5), 0 2px 4px -2px rgba(0,0,0,.4);
  --shadow-lg:       0 12px 24px -8px rgba(0,0,0,.6), 0 4px 8px -2px rgba(0,0,0,.4);
  --accent:          #4d8fdc;
  --accent-hover:    #6ea4e4;
  --accent-light:    rgba(77,143,220,.12);
  --success-light:   rgba(0,128,96,.18);
  --warning-light:   rgba(184,98,0,.18);
  --danger-light:    rgba(215,44,13,.18);
  --info-light:      rgba(0,110,184,.18);
}

/* ------------------------------------------------------------
   2. CSS RESET
   ------------------------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  overflow-y: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

img, svg {
  display: block;
}

ul, ol {
  list-style: none;
}

h1, h2, h3, h4 {
  line-height: 1.3;
}

/* ------------------------------------------------------------
   3. LAYOUT — SIDEBAR + MAIN
   ------------------------------------------------------------ */
/* ─── Sidebar: rail + panel (Linear-style) ─────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  display: flex;
  z-index: 200;
  transition: transform var(--transition);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

/* Rail — narrow icon column */
.rail {
  width: 56px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 14px;
  border-right: 1px solid rgba(255,255,255,.06);
}

.rail__brand {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.06);
}
.rail__logo {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.rail__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.rail__bottom {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  width: 36px;
  align-items: center;
}

.rail-link {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--sidebar-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  padding: 0;
}
.rail-link svg {
  width: 18px;
  height: 18px;
}
.rail-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}
.rail-link.rail-link--active {
  background: var(--sidebar-active);
  color: #fff;
}
.rail-link.rail-link--active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: #fff;
}

/* Tooltip on rail (uses title attribute via :hover) */
.rail-link::after {
  content: attr(aria-label);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: #2a2a2a;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 100ms ease;
  z-index: 250;
  box-shadow: 0 4px 8px rgba(0,0,0,.3);
}
.rail-link:hover::after { opacity: 1; }

/* Panel — contextual sub-nav */
.panel {
  flex: 1;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.panel__title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  padding: 14px 16px 6px;
}

.panel__nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 8px 12px;
  flex: 1;
}

.panel-section-label {
  padding: 14px 8px 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  width: 100%;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.panel-link svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.85;
}
.panel-link:hover {
  background: rgba(0,0,0,.04);
  color: var(--text);
}
[data-theme="dark"] .panel-link:hover {
  background: rgba(255,255,255,.04);
}
.panel-link.panel-link--active {
  background: rgba(0,0,0,.06);
  color: var(--text);
  font-weight: 600;
}
[data-theme="dark"] .panel-link.panel-link--active {
  background: rgba(255,255,255,.06);
}
.panel-link__count {
  margin-left: auto;
  font-size: 0.6875rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-weight: 500;
}

/* Main area */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------
   4. TOPBAR
   ------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  flex-shrink: 0;
}

.topbar__menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.topbar__logo {
  height: 36px;
  width: auto;
  flex-shrink: 0;
}

.topbar__menu-btn:hover {
  color: var(--text);
  background: var(--bg);
}

.topbar__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------
   5. VIEWS
   ------------------------------------------------------------ */
.view {
  padding: 1.5rem;
  flex: 1 0 auto;
  display: none;
}

.view.view--active {
  display: block;
}

/* legacy .hidden helper still works */
.view.hidden {
  display: none !important;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-bottom: 14px;
}

/* ------------------------------------------------------------
   6. STATS GRID
   ------------------------------------------------------------ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: flex-start;
  align-items: flex-start;
  gap: 1rem;
  min-height: 0;
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  -webkit-transform: translateY(-1px);
  transform: translateY(-1px);
}

.stat-card__icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  background: var(--primary-light);
  color: var(--primary);
}

.stat-card__icon svg {
  width: 22px;
  height: 22px;
}

.stat-card__body {
  -webkit-flex: 1;
  flex: 1;
  min-width: 0;
}

.stat-card__title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.stat-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.stat-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.stat-card__sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.stat-card__value--positive { color: var(--success); }
.stat-card__value--negative { color: var(--danger); }

/* Stat card colour variants */
.stat-card--blue    .stat-card__icon { background: #dbeafe; color: #2563eb; }
.stat-card--orange  .stat-card__icon { background: #fef3c7; color: #d97706; }
.stat-card--red     .stat-card__icon { background: #fee2e2; color: #dc2626; }
.stat-card--green   .stat-card__icon { background: #dcfce7; color: #16a34a; }
.stat-card--info    .stat-card__icon { background: #cffafe; color: #0891b2; }
.stat-card--success .stat-card__icon { background: #dcfce7; color: #16a34a; }
.stat-card--warning .stat-card__icon { background: #fef3c7; color: #d97706; }
.stat-card--danger  .stat-card__icon { background: #fee2e2; color: #dc2626; }

/* ─── Bento dashboard ─────────────────────────────────────────── */
.bento-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  margin-bottom: 1.5rem;
}
@media (min-width: 720px) {
  .bento-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .bento-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(120px, auto);
    grid-template-areas:
      "hero hero sold jobs"
      "hero hero returns warranty"
      "parts parts pipeline pipeline";
  }
  .bento-tile--hero      { grid-area: hero; }
  .bento-tile--sold      { grid-area: sold; }
  .bento-tile--jobs      { grid-area: jobs; }
  .bento-tile--returns   { grid-area: returns; }
  .bento-tile--parts     { grid-area: parts; }
  .bento-tile--warranty  { grid-area: warranty; }
  .bento-tile--pipeline  { grid-area: pipeline; }
}

.bento-tile {
  position: relative;
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 120px;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow);
}
.bento-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.bento-tile__label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}
.bento-tile__value {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  font-feature-settings: "tnum";
  margin-top: auto;
}
.bento-tile__sub {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.75;
  margin-top: 6px;
}
.bento-tile__icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255,255,255,.18);
}
.bento-tile__icon svg { width: 18px; height: 18px; }

/* Hero tile (Gross Profit) — emerald gradient, big */
.bento-tile--hero {
  background: linear-gradient(135deg, #059669 0%, #047857 50%, #065f46 100%);
  color: #fff;
  min-height: 240px;
}
.bento-tile--hero .bento-tile__value {
  font-size: 3.5rem;
  letter-spacing: -0.03em;
}
.bento-tile--hero::after {
  content: '';
  position: absolute;
  right: -40px;
  bottom: -40px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,.10) 0%, transparent 70%);
  pointer-events: none;
}

/* Color variants — vivid solid fills */
.bento-tile--indigo {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: #fff;
}
.bento-tile--orange {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #fff;
}
.bento-tile--rose {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: #fff;
}
.bento-tile--cyan {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  color: #fff;
}
.bento-tile--amber {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
}
.bento-tile--violet {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: #fff;
}
.bento-tile--slate {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.bento-tile--slate .bento-tile__icon { background: var(--primary-light); color: var(--primary); }

/* Pipeline tile — wider, contains chips */
.bento-tile--pipeline {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  min-height: 120px;
}
.bento-tile--pipeline .bento-pipeline-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.bento-pipeline-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.bento-pipeline-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.bento-pipeline-chip__count {
  color: var(--text-secondary);
  font-weight: 700;
  margin-left: 4px;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-lg);
  border-top: none !important;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ------------------------------------------------------------
   7. PIPELINE
   ------------------------------------------------------------ */
.pipeline {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.pipeline .section-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-secondary);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.pipeline__stages {
  display: flex;
  gap: 0.625rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.pipeline__stages::-webkit-scrollbar {
  height: 4px;
}
.pipeline__stages::-webkit-scrollbar-track { background: transparent; }
.pipeline__stages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.stage-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  min-width: 110px;
  cursor: default;
  flex-shrink: 0;
  transition: box-shadow var(--transition);
}

.stage-chip:hover {
  box-shadow: var(--shadow-md);
}

.stage-chip__count {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stage-chip__label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 0.25rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ------------------------------------------------------------
   8. TOOLBAR
   ------------------------------------------------------------ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 180px;
  max-width: 360px;
  height: 38px;
  padding: 0 0.875rem 0 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 0.625rem center;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.search-input::placeholder { color: var(--text-muted); }

.select {
  height: 38px;
  padding: 0 2rem 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  transition: border-color var(--transition);
}

.select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ------------------------------------------------------------
   9. DATA TABLES
   ------------------------------------------------------------ */
.table-wrap {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: auto;
  transition: box-shadow var(--transition);
}
.table-wrap:hover {
  box-shadow: var(--shadow-md);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th {
  background: rgba(246,246,247,.92);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  color: var(--text-secondary);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .055em;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  position: relative;
}
[data-theme="dark"] .data-table th {
  background: rgba(26,26,26,.92);
}

/* Column resize handle */
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  z-index: 2;
  touch-action: none;
}
.col-resize-handle:hover,
.col-resize-handle.active {
  background: var(--primary);
  opacity: 0.4;
}
.data-table.resizable {
  table-layout: fixed;
}
.data-table.resizable td,
.data-table.resizable th {
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table td {
  padding: 0.6875rem 0.875rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

.data-table tbody tr:nth-child(even) td {
  background: transparent;
}

.data-table tbody tr:hover td {
  background: rgba(0,0,0,.02);
}
[data-theme="dark"] .data-table tbody tr:hover td {
  background: rgba(255,255,255,.03);
}

.data-table .text-muted {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.data-table .mono {
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  letter-spacing: 0;
  color: var(--text);
}
.data-table .imei-full {
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Right-align money/numeric columns automatically when class is set */
.data-table .num,
.data-table .money,
.data-table th.num,
.data-table th.money { text-align: right; }

/* Table action buttons */
.action-btns {
  display: flex;
  gap: 0.375rem;
  align-items: center;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.btn-icon:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-icon--danger:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

.btn-icon--primary:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.empty-state svg {
  margin: 0 auto 0.75rem;
  opacity: 0.4;
}

/* ------------------------------------------------------------
   10. STATUS BADGES
   ------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.6em;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.badge--broken        { background: #fee2e2; color: #991b1b; }
.badge--waiting_parts { background: #fef3c7; color: #92400e; }
.badge--repairing     { background: #dbeafe; color: #1e40af; }
.badge--in_stock      { background: #dcfce7; color: #14532d; }
.badge--sold          { background: #1e293b; color: #f8fafc; }
.badge--returned      { background: #fef9c3; color: #713f12; }
.badge--scrapped      { background: #f1f5f9; color: #475569; }
.badge--lost          { background: #fecaca; color: #991b1b; }
.badge--completed     { background: #dcfce7; color: #14532d; }
.badge--abandoned     { background: #fee2e2; color: #991b1b; }
.badge--warranty_return { background: #fef3c7; color: #92400e; }
.badge--in_progress   { background: #dbeafe; color: #1e40af; }

/* Grade badges */
.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.grade-badge--A { background: var(--success-light); color: var(--success); }
.grade-badge--B { background: var(--primary-light); color: var(--primary); }
.grade-badge--C { background: var(--warning-light); color: var(--warning); }

/* Low stock warning */
.stock-low { color: var(--danger); font-weight: 600; }

/* Inline stock stepper */
.stock-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.stock-stepper__btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.stock-stepper__btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-strong);
}
.stock-stepper__btn:active { transform: scale(0.95); }
.stock-stepper__value {
  width: 48px;
  height: 24px;
  padding: 0 4px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: center;
  font-feature-settings: "tnum";
  font-family: var(--font-mono);
  appearance: textfield;
  -moz-appearance: textfield;
}
.stock-stepper__value::-webkit-outer-spin-button,
.stock-stepper__value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.stock-stepper__value:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(0,0,0,.05);
}
.stock-stepper__value--low {
  color: var(--danger);
  border-color: rgba(215,44,13,.3);
}

/* Stock health dot */
.stock-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  margin-right: 2px;
}
.stock-dot--ok  { background: var(--success); box-shadow: 0 0 0 2px rgba(0,128,96,.15); }
.stock-dot--low { background: var(--warning); box-shadow: 0 0 0 2px rgba(184,98,0,.15); }
.stock-dot--out { background: var(--danger);  box-shadow: 0 0 0 2px rgba(215,44,13,.15); }

/* Subtle red tint on low-stock rows */
.data-table tbody tr.row-low td {
  background: rgba(215,44,13,.04);
}
[data-theme="dark"] .data-table tbody tr.row-low td {
  background: rgba(215,44,13,.08);
}

/* Invoice row two-line cells */
.invoice-cell__customer { min-width: 180px; }
.invoice-cell__customer-name {
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.invoice-cell__email {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.invoice-cell__device { min-width: 200px; }
.invoice-cell__device-name {
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.invoice-cell__imei {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-top: 1px;
}

/* Sales channel pills */
.channel-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: capitalize;
  white-space: nowrap;
}

/* Month sub-headers inside the invoices table */
.invoice-month-header td {
  padding: 10px 14px 6px !important;
  background: transparent !important;
  border-bottom: 1px solid var(--border) !important;
}
.invoice-month-header__label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-right: 10px;
}
.invoice-month-header__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* POS bento summary strip — 4-up on desktop, no big hero */
.bento-grid--pos {
  grid-template-columns: 1fr;
  grid-template-areas: none !important;
  margin-bottom: 14px;
}
@media (min-width: 720px) {
  .bento-grid--pos { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .bento-grid--pos {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: auto !important;
    grid-template-areas: none !important;
  }
}
.bento-grid--pos .bento-tile--hero {
  min-height: 0 !important;
  grid-area: auto !important;
}
.bento-grid--pos .bento-tile--hero .bento-tile__value {
  font-size: 2.25rem !important;
}
.bento-grid--pos .bento-tile {
  min-height: 110px;
  grid-area: auto !important;
}

/* Profit / value colours */
.val-positive { color: var(--success); font-weight: 600; }
.val-negative { color: var(--danger); font-weight: 600; }

/* ------------------------------------------------------------
   11. BUTTONS
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
}

.btn--primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.2), 0 1px 0 rgba(0,0,0,.05);
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

[data-theme="dark"] .btn--primary {
  /* In dark mode --primary is white; flip text to near-black so it's readable */
  color: #1a1a1a;
  box-shadow: 0 1px 0 rgba(0,0,0,.4);
}
[data-theme="dark"] .btn--primary:hover:not(:disabled) {
  color: #1a1a1a;
}

.btn--ghost {
  background: var(--card-bg);
  color: var(--text);
  border-color: var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn--danger:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn--sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8125rem;
}

.btn--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.btn--icon:hover {
  background: rgba(0,0,0,.06);
  color: var(--text);
}
[data-theme="dark"] .btn--icon:hover {
  background: rgba(255,255,255,.08);
}

.btn--icon.btn--danger,
.btn--icon.btn--success,
.btn--icon.btn--warning {
  background: transparent;
  color: var(--text-muted);
}

.btn--icon.btn--danger:hover {
  background: var(--danger-light);
  color: var(--danger);
}
.btn--icon.btn--success:hover {
  background: var(--success-light);
  color: var(--success);
}
.btn--icon.btn--warning:hover {
  background: var(--warning-light);
  color: var(--warning);
}

.btn--icon svg {
  width: 16px;
  height: 16px;
}

/* ------------------------------------------------------------
   12. MODALS
   ------------------------------------------------------------ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 500;
  display: none;          /* hidden by default */
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

/* JS toggles .is-open to show the modal */
.modal-overlay.is-open {
  display: flex;
  animation: overlayIn 150ms ease;
}

/* legacy .hidden still hides */
.modal-overlay.hidden {
  display: none !important;
}

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

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 180ms cubic-bezier(.34,1.56,.64,1);
}

.modal--wide { max-width: 720px; }
.modal--sm   { max-width: 400px; }

@keyframes modalIn {
  from { transform: scale(0.94) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0);      opacity: 1; }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal__header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.modal__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.125rem;
  line-height: 1;
  padding: 0.25rem 0.375rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

.modal__close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal__body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.625rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: 1.25rem;
}

/* ------------------------------------------------------------
   13. FORM ELEMENTS
   ------------------------------------------------------------ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--card-bg);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.5;
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.form-input::placeholder { color: var(--text-muted); }

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

textarea.form-input {
  resize: vertical;
  min-height: 72px;
}

/* ------------------------------------------------------------
   14. QC CHECKLIST GRID
   ------------------------------------------------------------ */
.qc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.qc-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  user-select: none;
}

.qc-item input[type="checkbox"] {
  display: none;
}

.qc-item__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background var(--transition);
}

.qc-item.checked {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
}

.qc-item.checked .qc-item__dot {
  background: var(--success);
}

.qc-item.failed {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

.qc-item.failed .qc-item__dot {
  background: var(--danger);
}

/* ------------------------------------------------------------
   15. PASSPORT MODAL BODY
   ------------------------------------------------------------ */
.passport-section {
  margin-bottom: 1.25rem;
}

.passport-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-secondary);
  margin-bottom: 0.625rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border);
}

.passport-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.375rem 1.25rem;
  font-size: 0.875rem;
}

.passport-dl dt {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.passport-dl dd {
  color: var(--text);
  font-weight: 500;
}

.passport-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 0.75rem;
  padding-bottom: 1rem;
  position: relative;
}

.timeline-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 16px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--card-bg);
  box-shadow: 0 0 0 2px var(--primary);
  flex-shrink: 0;
  margin-top: 2px;
  z-index: 1;
}

.timeline-dot--success  { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-dot--warning  { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.timeline-dot--danger   { background: var(--danger);  box-shadow: 0 0 0 2px var(--danger); }

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-content strong {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.timeline-content span {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.timeline-content p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Detail field grid (label + value pairs in passport) */
.phone-detail-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.phone-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.875rem;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.form-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 0.25rem;
}

.form-input.input--error {
  border-color: var(--danger);
}

.detail-field label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
}

.detail-field span {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}
.detail-field span.badge--sold          { color: #f8fafc; }
.detail-field span.badge--broken        { color: #991b1b; }
.detail-field span.badge--scrapped      { color: #475569; }
.detail-field span.badge--returned      { color: #713f12; }
.detail-field span.badge--in_stock      { color: #14532d; }
.detail-field span.badge--repairing     { color: #1e40af; }
.detail-field span.badge--waiting_parts { color: #9a3412; }
.detail-field span.imei-badge--clean         { color: var(--success); }
.detail-field span.imei-badge--blacklisted   { color: var(--danger); }
.detail-field span.imei-badge--icloud_locked { color: var(--warning); }
.detail-field span.imei-badge--unknown       { color: var(--warning); }

.detail-field .mono,
span.mono {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 0.825rem;
  letter-spacing: .03em;
}

.detail-notes {
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

.detail-notes label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

/* Section header with title + action button on same row */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.section-header .section-title {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

/* Quick status change bar */
.passport-quick-status {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 0 0;
  margin-top: 0.875rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.passport-quick-status select {
  flex: 0 0 auto;
  padding: 0.35rem 0.625rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--card-bg);
  color: var(--text);
}

/* QC record list */
.qc-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.qc-record {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
  background: var(--bg);
}

.qc-record__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.qc-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.qc-check-item {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}

.qc-check-item--pass { background: #f0fdf4; border-color: #86efac; color: #166534; }
.qc-check-item--fail { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }

.qc-notes {
  margin-top: 0.5rem;
  font-size: 0.825rem;
  color: var(--text-secondary);
}

/* Job outcome badge */
.badge--outcome-completed    { background: #dcfce7; color: #166534; }
.badge--outcome-abandoned    { background: #fee2e2; color: #991b1b; }
.badge--outcome-warranty_return { background: #fef9c3; color: #854d0e; }
.badge--outcome-pending      { background: #f1f5f9; color: var(--text-secondary); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ------------------------------------------------------------
   16. TOAST NOTIFICATIONS
   ------------------------------------------------------------ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: #1e293b;
  color: #f1f5f9;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 240px;
  max-width: 380px;
  pointer-events: auto;
  border-left: 3px solid var(--primary);
  /* slide-in via transition — JS adds .toast--visible to trigger */
  opacity: 0;
  transform: translateX(110%);
  transition: opacity 200ms ease, transform 200ms cubic-bezier(.34,1.56,.64,1);
}

.toast.toast--visible {
  opacity: 1;
  transform: translateX(0);
}

.toast--success { border-left-color: var(--success); }
.toast--error   { border-left-color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }

.toast__icon {
  flex-shrink: 0;
  opacity: 0.9;
}

/* ------------------------------------------------------------
   17. MISCELLANEOUS UTILITIES
   ------------------------------------------------------------ */
.hidden { display: none !important; }

.text-right { text-align: right; }
.text-center { text-align: center; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 0.5rem; }

.font-mono {
  font-family: 'SF Mono', 'Fira Mono', 'Courier New', monospace;
  font-size: 0.8125rem;
}

/* Cost / profit display */
.cost-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}

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

/* ------------------------------------------------------------
   18. RESPONSIVE — MOBILE (< 768px)
   ------------------------------------------------------------ */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
  }

  /* JS toggles body.sidebar-open */
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main {
    margin-left: 0;
  }

  .topbar__menu-btn {
    display: flex;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .qc-grid {
    grid-template-columns: 1fr;
  }

  .view {
    padding: 1rem;
  }

  .topbar {
    padding: 0 1rem;
  }

  .modal {
    max-height: 95vh;
    border-radius: var(--radius) var(--radius) 0 0;
    margin-bottom: 0;
    align-self: flex-end;
    animation: modalInMobile 220ms cubic-bezier(.34,1.56,.64,1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal__footer {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    position: relative;
    z-index: 10;
  }

  @keyframes modalInMobile {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input {
    max-width: 100%;
  }

  .action-btns {
    gap: 0.25rem;
  }

  /* Tables: horizontal scroll with touch support */
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    position: relative;
  }

  /* Charts grid: single column, reduced height */
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .chart-card {
    min-height: 220px;
  }

  .chart-card canvas {
    max-height: 200px;
  }

  .chart-card--full {
    min-height: 240px;
  }

  .chart-card--full canvas {
    max-height: 220px;
  }

  /* Pipeline stages: 3-column grid wrap */
  .pipeline__stages {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    overflow-x: visible;
  }

  .pipeline-stage,
  .stage-chip {
    min-width: unset;
    padding: 0.5rem 0.625rem;
  }

  .pipeline-stage__count,
  .stage-chip__count {
    font-size: 1.2rem;
  }

  .pipeline-stage__label,
  .stage-chip__label {
    font-size: 0.65rem;
  }

  /* Phone model cards: 2-column grid, smaller padding */
  .model-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .model-card {
    padding: 0.75rem;
  }

  .model-card__count {
    font-size: 1.1rem;
  }
}

/* Extra-small screens */
@media (max-width: 359px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .model-cards-grid {
    grid-template-columns: 1fr;
  }

  .pipeline__stages {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ------------------------------------------------------------
   19. RESPONSIVE — TABLET (768px – 1023px)
   ------------------------------------------------------------ */
/* Tablet: show full sidebar with text */
@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --sidebar-width: 232px;
  }
}

/* Tablet + phone: responsive table columns */
@media (max-width: 1023px) {
  .col-check,
  .col-grade,
  .col-cost,
  .col-source { display: none !important; }

  .data-table.resizable { table-layout: auto; }
  .data-table.resizable td,
  .data-table.resizable th { overflow: visible; text-overflow: clip; white-space: normal; }
  .col-resize-handle { display: none; }

  .bulk-bar { display: none !important; }
}

/* ------------------------------------------------------------
   20. SCROLLBAR STYLING (WEBKIT)
   ------------------------------------------------------------ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #cbd5e1;
}

/* ------------------------------------------------------------
   21. FOCUS VISIBLE (ACCESSIBILITY)
   ------------------------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------
   22. PASSPORT TABS
   ------------------------------------------------------------ */
.passport-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}

.tab-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

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

.tab-panel {
  display: none;
}

.tab-panel.tab-panel--active {
  display: block;
}

/* Phone detail card inside passport */
.phone-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.phone-detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.phone-detail-item dt {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.phone-detail-item dd {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}

/* Status timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.timeline-item .badge {
  flex-shrink: 0;
}

/* Job detail in passport */
.job-detail-section {
  margin-top: 1.25rem;
}

.job-detail-section h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

/* Parts used table inside job detail */
.parts-used-table {
  width: 100%;
  font-size: 0.85rem;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.parts-used-table th,
.parts-used-table td {
  padding: 0.4rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.parts-used-table th {
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
}

/* Passport back button */
.passport-back {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0 0 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.passport-back:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------
   24. MODEL SUMMARY CARDS (Phones view)
   ------------------------------------------------------------ */
.model-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.model-card {
  position: relative;
  border: none;
  border-radius: 16px;
  padding: 18px 20px;
  cursor: pointer;
  user-select: none;
  color: #fff;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 150px;
}

.model-card::after {
  content: '';
  position: absolute;
  right: -30px;
  bottom: -30px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(255,255,255,.10) 0%, transparent 70%);
  pointer-events: none;
}

.model-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Rotating colourways — each card a distinct vivid gradient */
.model-card:nth-child(6n+1) { background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%); }
.model-card:nth-child(6n+2) { background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%); }
.model-card:nth-child(6n+3) { background: linear-gradient(135deg, #f97316 0%, #ea580c 100%); }
.model-card:nth-child(6n+4) { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); }
.model-card:nth-child(6n+5) { background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%); }
.model-card:nth-child(6n+6) { background: linear-gradient(135deg, #059669 0%, #047857 100%); }

.model-card__make {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.8;
  margin-bottom: 4px;
}

.model-card__model {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-bottom: auto;
  padding-bottom: 12px;
}

.model-card__count {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 6px;
  color: inherit;
  font-feature-settings: "tnum";
}

.model-card__dots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.20);
  position: relative;
  z-index: 1;
}

.model-card__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,.25);
}

.model-card__dot-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: rgba(255,255,255,.85);
  margin-right: 2px;
}

/* ─── Phones view toggle (Kanban / Table) ────────────────────── */
.phones-view-toggle {
  display: inline-flex;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.phones-view-toggle button {
  padding: 6px 14px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.phones-view-toggle button:hover { color: var(--text); }
.phones-view-toggle button.active {
  background: var(--text);
  color: var(--card-bg);
}
[data-theme="dark"] .phones-view-toggle button.active {
  background: var(--card-bg);
  color: var(--text);
}
.phones-view-toggle svg { width: 14px; height: 14px; }

/* ─── Kanban board ───────────────────────────────────────────── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 16px;
  align-items: start;
}
@media (max-width: 1100px) {
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .kanban-board { grid-template-columns: 1fr; }
}

.kanban-column {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 240px);
  min-height: 280px;
  overflow: hidden;
}

.kanban-column__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.kanban-column__header::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 16px 0 0 0;
}
.kanban-column--workshop .kanban-column__header::before { background: linear-gradient(180deg, #f97316, #ea580c); }
.kanban-column--ready    .kanban-column__header::before { background: linear-gradient(180deg, #06b6d4, #0891b2); }
.kanban-column--sold     .kanban-column__header::before { background: linear-gradient(180deg, #059669, #047857); }
.kanban-column--archive  .kanban-column__header::before { background: linear-gradient(180deg, #94a3b8, #64748b); }

.kanban-column__title {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.kanban-column__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg);
  border-radius: var(--radius-pill);
}

.kanban-column__body {
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.kanban-column__empty {
  color: var(--text-muted);
  font-size: 0.8125rem;
  text-align: center;
  padding: 24px 12px;
}

.kanban-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.kanban-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}
.kanban-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.kanban-card__model {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.25;
}
.kanban-card__storage {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.kanban-card__imei {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.kanban-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.kanban-card__meta strong {
  color: var(--text);
  font-weight: 700;
  font-feature-settings: "tnum";
}
.kanban-card__meta--profit-positive strong { color: var(--success); }
.kanban-card__meta--profit-negative strong { color: var(--danger); }
.kanban-card__action {
  margin-top: 4px;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.kanban-card__action:hover { filter: brightness(1.08); }
.kanban-card__action svg { width: 13px; height: 13px; }
.kanban-card__action--workshop { background: linear-gradient(135deg, #f97316, #ea580c); color: #fff; }
.kanban-card__action--ready    { background: linear-gradient(135deg, #06b6d4, #0891b2); color: #fff; }
.kanban-card__action--sold     { background: var(--card-bg); color: var(--text-secondary); border: 1px solid var(--border); }
.kanban-card__action--sold:hover { background: var(--bg); color: var(--text); filter: none; }

/* ------------------------------------------------------------
   25b. IMEI CAMERA SCAN
   ------------------------------------------------------------ */
.imei-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.imei-input-row .form-input {
  flex: 1;
  min-width: 0;
}

.imei-scan-label {
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.imei-scan-label--busy {
  opacity: 0.6;
  pointer-events: none;
}

/* ------------------------------------------------------------
   26. SUPPLIER CARDS (Suppliers view)
   ------------------------------------------------------------ */
.supplier-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.supplier-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.supplier-card__type {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 0.2rem;
}

.supplier-card__name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.supplier-card__count {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 0.2rem;
}

.supplier-card__label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.supplier-card__contact {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  padding-top: 0.4rem;
}

/* Job detail – status update bar */
.job-status-update {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.job-status-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.4rem;
}

.job-status-row .form-input {
  flex: 1;
}

/* ------------------------------------------------------------
   23. JOB MODAL – PARTS PICKER
   ------------------------------------------------------------ */
.job-parts-picker {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.job-parts-picker .form-input {
  flex: 1;
}

#job-parts-list {
  margin-top: 0.25rem;
}

.job-parts-list-table {
  width: 100%;
  font-size: 0.85rem;
  border-collapse: collapse;
  margin-bottom: 0.5rem;
}

.job-parts-list-table th,
.job-parts-list-table td {
  padding: 0.35rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.job-parts-list-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--bg);
}

.job-parts-list-table .btn--icon {
  font-size: 0.8rem;
  padding: 0.15rem 0.35rem;
}

.job-cost-summary {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 0.25rem;
}

.job-cost-summary .cost-row {
  display: flex;
  justify-content: space-between;
}

.job-cost-summary .cost-row--total {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  border-top: 1px solid var(--border);
  padding-top: 0.3rem;
  margin-top: 0.1rem;
}

/* ── POS / Invoices ───────────────────────────────────────────────────────── */

.pos-results {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 0.4rem;
  background: var(--surface);
}

.pos-result-item {
  padding: 0.65rem 0.875rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.pos-result-item:last-child { border-bottom: none; }
.pos-result-item:hover { background: var(--bg); }

.pos-result-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}
.pos-result-storage {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 0.75rem;
  padding: 0.1rem 0.3rem;
  color: var(--text-secondary);
}
.pos-result-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.pos-result-empty {
  padding: 0.75rem 0.875rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.pos-selected { margin-bottom: 0.5rem; }

.pos-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.875rem;
  font-size: 0.875rem;
  color: var(--text);
}
.pos-chip__info { line-height: 1.5; }

/* Invoice document */
.invoice-print-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.25rem;
}

.invoice-doc {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 640px;
  margin: 0 auto;
  background: #fff;
  font-size: 0.9rem;
  color: #1e293b;
}

.invoice-doc__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid #e2e8f0;
}

.invoice-doc__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.invoice-doc__number {
  font-size: 1rem;
  font-weight: 700;
  color: #1d4ed8;
  text-align: right;
}
.invoice-doc__date {
  font-size: 0.85rem;
  color: #64748b;
  text-align: right;
  margin-top: 0.2rem;
}

.invoice-doc__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (max-width: 480px) {
  .invoice-doc { padding: 1.25rem; }
  .invoice-doc__body { grid-template-columns: 1fr; gap: 1.25rem; }
}

.invoice-doc__section h3 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 0.6rem;
}

.invoice-doc__customer {
  line-height: 1.7;
  font-size: 0.875rem;
}

.invoice-doc__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.invoice-doc__table td {
  padding: 0.25rem 0;
  vertical-align: top;
}
.invoice-doc__table td:first-child {
  color: #64748b;
  width: 40%;
  padding-right: 0.75rem;
}

.invoice-doc__total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
  font-size: 1.05rem;
  margin-bottom: 1rem;
  color: #1e293b;
}
.invoice-doc__total strong { font-size: 1.25rem; color: #1d4ed8; }

.invoice-doc__notes {
  font-size: 0.85rem;
  color: #64748b;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

@media print {
  body > *:not(#invoiceViewModal) { display: none !important; }
  #invoiceViewModal { position: static !important; background: none !important; }
  #invoiceViewModal .modal { box-shadow: none !important; max-width: 100% !important; }
  .invoice-print-bar, .modal__header, .modal__close { display: none !important; }
  .invoice-doc { border: none; padding: 0; }
}

/* Payment status badges */
.badge--paid     { background: #dcfce7; color: #16a34a; border: 1px solid #bbf7d0; }
.badge--unpaid   { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge--refunded { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge--lost     { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }

/* Force light-mode badge colors inside invoice (always white bg) — !important overrides dark theme */
.invoice-doc .badge--paid     { background: #dcfce7 !important; color: #16a34a !important; border: 1px solid #bbf7d0 !important; }
.invoice-doc .badge--unpaid   { background: #fff7ed !important; color: #c2410c !important; border: 1px solid #fed7aa !important; }
.invoice-doc .badge--refunded { background: #fef3c7 !important; color: #92400e !important; border: 1px solid #fde68a !important; }
.invoice-doc .badge--lost     { background: #fee2e2 !important; color: #dc2626 !important; border: 1px solid #fecaca !important; }

/* Success button */
.btn--success {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}
.btn--success:hover { background: #15803d; }

/* ------------------------------------------------------------
   27. DASHBOARD CHARTS
   ------------------------------------------------------------ */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.chart-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  min-height: 300px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.chart-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.chart-card .section-title {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--text);
  padding-bottom: 0;
  margin-bottom: 14px;
  border-bottom: 0;
}

.chart-card canvas {
  max-height: 260px;
}

.chart-card--full {
  grid-column: 1 / -1;
  min-height: 300px;
}

.chart-card--full canvas {
  max-height: 280px;
}

/* Pipeline stage — fix class mismatch: JS outputs .pipeline-stage, CSS had .stage-chip */
.pipeline-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  min-width: 110px;
  cursor: default;
  flex-shrink: 0;
  transition: box-shadow var(--transition), transform var(--transition);
  border-top: 3px solid var(--border);
}

.pipeline-stage:hover {
  box-shadow: var(--shadow-md);
  -webkit-transform: translateY(-1px);
  transform: translateY(-1px);
}

.pipeline-stage__count {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.pipeline-stage__label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 0.25rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Pipeline status colour accents */
.pipeline-stage--broken        { border-top-color: #ef4444; }
.pipeline-stage--waiting_parts { border-top-color: #f59e0b; }
.pipeline-stage--repairing     { border-top-color: #3b82f6; }
.pipeline-stage--in_stock      { border-top-color: #22c55e; }
.pipeline-stage--sold          { border-top-color: #6b7280; }
.pipeline-stage--returned      { border-top-color: #eab308; }
.pipeline-stage--scrapped      { border-top-color: #94a3b8; }
.pipeline-stage--lost          { border-top-color: #78716c; }

/* ------------------------------------------------------------
   28. LOGIN SCREEN
   ------------------------------------------------------------ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
  padding: 1.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.login-overlay--visible {
  display: flex;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  padding: 2.5rem 2rem 2rem;
  animation: modalIn 250ms cubic-bezier(.34,1.56,.64,1);
}

.login-card__logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2rem;
  text-align: center;
  line-height: 1.3;
}

.login-card__logo svg {
  color: var(--primary);
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.login-field label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.login-field input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: var(--card-bg);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  /* Prevent iOS zoom on focus */
  -webkit-appearance: none;
  appearance: none;
}

.login-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.login-error {
  color: var(--danger);
  font-size: 0.875rem;
  min-height: 1.25rem;
  margin-bottom: 0.5rem;
}

.login-btn {
  width: 100%;
  justify-content: center;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border-radius: var(--radius);
  min-height: 48px;
}

/* Login — mobile (< 480px) */
@media (max-width: 479px) {
  .login-overlay {
    padding: 1rem;
    align-items: flex-start;
    padding-top: 15vh;
  }

  .login-card {
    padding: 2rem 1.5rem 1.75rem;
    border-radius: var(--radius);
  }

  .login-card__logo {
    font-size: 1rem;
    margin-bottom: 1.5rem;
  }

  .login-card__logo svg {
    width: 36px;
    height: 36px;
  }
}

/* Login — tablet / iPad */
@media (min-width: 480px) and (max-width: 1023px) {
  .login-card {
    max-width: 420px;
    padding: 3rem 2.5rem 2.5rem;
  }

  .login-card__logo svg {
    width: 44px;
    height: 44px;
  }

  .login-card__logo {
    font-size: 1.15rem;
    margin-bottom: 2.25rem;
  }

  .login-field input {
    padding: 0.85rem 1rem;
  }

  .login-btn {
    padding: 1rem;
    font-size: 1.05rem;
    min-height: 52px;
  }
}

/* Sidebar footer (logout button) */
.sidebar__footer {
  padding: 0.625rem;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.nav-link--footer,
.nav-link--logout {
  color: var(--sidebar-muted);
  width: 100%;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.nav-link--footer:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.nav-link--logout:hover {
  background: rgba(220,38,38,.15);
  color: #fca5a5;
}

/* Tablet: full sidebar footer buttons */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar__footer {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
}

/* ------------------------------------------------------------
   PROFIT VISIBILITY TOGGLE
   ------------------------------------------------------------ */
.profit-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.35rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}
.profit-toggle:hover {
  color: var(--text);
  border-color: var(--text-secondary);
  background: var(--bg);
}
.profit-toggle.active {
  color: var(--primary);
  border-color: var(--primary);
}

/* Warranty badges */
.warranty-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.55em;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
}
.warranty-badge--ok      { background: var(--success-light); color: var(--success); }
.warranty-badge--warning { background: var(--warning-light); color: var(--warning); }
.warranty-badge--expired { background: var(--danger-light); color: var(--danger); }

/* Stock aging badges */
.aging-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1em 0.4em;
  border-radius: var(--radius-pill);
  font-size: 0.65rem;
  font-weight: 700;
  margin-left: 0.35rem;
  vertical-align: middle;
}
.aging-badge--30 { background: #fef3c7; color: #92400e; }
.aging-badge--60 { background: #ffedd5; color: #9a3412; }
.aging-badge--90 { background: #fee2e2; color: #991b1b; }

/* Bulk action bar */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  width: 100%;
  margin-top: 0.25rem;
}
.bulk-bar__count {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

/* Phone table checkboxes */
.phone-select-cb,
#phones-select-all {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Date range bar */
.date-range-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.date-range-custom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.date-range-custom span {
  color: var(--text-secondary);
  font-size: 0.875rem;
}
.form-input--sm {
  height: 34px;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
}

/* Profit badges */
.profit-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.55em;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.profit-badge--positive { background: var(--success-light); color: var(--success); }
.profit-badge--negative { background: var(--danger-light); color: var(--danger); }

.profit-detail { font-weight: 600; }
.profit-detail--positive span { color: var(--success); }
.profit-detail--negative span { color: var(--danger); }

body.profit-hidden .sensitive {
  /* em-based blur scales with the font-size of the surrounding text so large
     bento numbers blur proportionally heavier than table cells */
  -webkit-filter: blur(0.45em);
  filter: blur(0.45em);
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}
body.profit-hidden #chart-monthly-bar {
  -webkit-filter: blur(12px);
  filter: blur(12px);
  pointer-events: none;
}
body.profit-hidden #chart-channel-pie {
  -webkit-filter: blur(12px);
  filter: blur(12px);
  pointer-events: none;
}

/* IMEI check banner */
.imei-check-banner {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.imei-check-banner--checking {
  background: var(--info-light);
  color: var(--info);
}
.imei-check-banner--clean {
  background: var(--success-light);
  color: var(--success);
}
.imei-check-banner--blacklisted {
  background: var(--danger-light);
  color: var(--danger);
}
.imei-check-banner--icloud_locked {
  background: var(--warning-light);
  color: var(--warning);
}
.imei-check-banner--unknown {
  background: var(--warning-light);
  color: var(--warning);
}
.imei-check-banner--error {
  background: var(--danger-light);
  color: var(--danger);
}
.imei-check-banner .spinner-sm {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  -webkit-animation: spin .6s linear infinite;
  animation: spin .6s linear infinite;
}
@-webkit-keyframes spin { to { -webkit-transform: rotate(360deg); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* IMEI status badge (passport + list) */
.imei-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.imei-badge--clean { background: var(--success-light); color: var(--success); }
.imei-badge--blacklisted { background: var(--danger-light); color: var(--danger); }
.imei-badge--icloud_locked { background: var(--warning-light); color: var(--warning); }
.imei-badge--unknown { background: var(--warning-light); color: var(--warning); }

/* IMEI check dot in phones list */
.imei-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.imei-dot--clean { background: var(--success); }
.imei-dot--blacklisted { background: var(--danger); }
.imei-dot--icloud_locked { background: var(--warning); }
.imei-dot--unknown { background: var(--warning); }

/* Sortable column headers */
.sortable-th {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: color var(--transition), background var(--transition);
}
.sortable-th:hover {
  color: var(--primary);
  background: var(--primary-light);
}
.sortable-th .sort-arrow {
  font-size: 0.7em;
  margin-left: 0.25em;
  opacity: 0.7;
  color: var(--primary);
}

/* Parts grouped by model */
.parts-group-header {
  cursor: pointer;
  background: var(--bg);
  border-left: 3px solid var(--primary);
}
.parts-group-header:hover {
  background: var(--primary-light);
}
.parts-group-header td {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
}
.parts-group__toggle {
  display: inline-block;
  width: 1em;
  transition: transform var(--transition);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.parts-group-header.collapsed .parts-group__toggle {
  -webkit-transform: rotate(-90deg);
  transform: rotate(-90deg);
}
.parts-group__count {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}
.parts-group__low {
  color: var(--danger);
  font-weight: 600;
}

/* IMEI verification on invoice */
.invoice-doc__presale {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--success);
  border-radius: var(--radius);
  background: var(--success-light);
}
.invoice-doc__presale.presale--blacklisted {
  border-color: var(--danger);
  background: var(--danger-light);
}
.invoice-doc__presale.presale--blacklisted h3 { color: var(--danger); }
.invoice-doc__presale.presale--icloud_locked {
  border-color: var(--warning);
  background: var(--warning-light);
}
.invoice-doc__presale.presale--icloud_locked h3 { color: var(--warning); }
.invoice-doc__presale.presale--unknown {
  border-color: var(--warning);
  background: var(--warning-light);
}
.invoice-doc__presale.presale--unknown h3 { color: var(--warning); }
.invoice-doc__presale h3 {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--success);
  margin: 0 0 0.625rem;
}
.presale-check {
  font-size: 0.8125rem;
  padding: 0.25rem 0;
}
.presale-timestamp {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Invoice edit form */
.invoice-edit-form {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
@media print {
  .invoice-edit-form,
  .invoice-print-bar { display: none !important; }
}

/* Inline quantity input for parts tables */
.inline-qty { width: 55px; text-align: center; padding: 2px 4px; }

/* ------------------------------------------------------------
   DARK MODE OVERRIDES — matches Next.js rebuild design
   Navy-slate palette, not grey. Premium tech dashboard feel.
   ------------------------------------------------------------ */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #1e293b;
  color: #f8fafc;
  border-color: #334155;
}
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(29,78,216,.15);
}
[data-theme="dark"] .topbar {
  background: #0f172a;
  border-color: #1e293b;
}
[data-theme="dark"] .data-table th {
  background: #020817;
  color: #94a3b8;
  border-color: #1e293b;
}
[data-theme="dark"] .data-table td {
  border-color: #1e293b;
}
[data-theme="dark"] .data-table tbody tr:nth-child(even) td {
  background: rgba(15,23,42,.5);
}
[data-theme="dark"] .data-table tbody tr:hover td {
  background: rgba(29,78,216,.08);
}
/* Group header rows — navy-slate with purple left accent */
[data-theme="dark"] .parts-group-header {
  background: #0f172a;
  border-left-color: var(--primary);
}
[data-theme="dark"] .parts-group-header:hover {
  background: #1e293b;
}
[data-theme="dark"] .parts-group-header td {
  color: #f8fafc;
}
[data-theme="dark"] .modal-content {
  background: #0f172a;
  border: 1px solid #1e293b;
}
[data-theme="dark"] .modal-backdrop {
  background: rgba(2,8,23,.8);
}
[data-theme="dark"] .login-overlay {
  background: #020817;
}
[data-theme="dark"] .login-card {
  background: #0f172a;
  border: 1px solid #1e293b;
}
[data-theme="dark"] .stat-card {
  border-color: #1e293b;
  background: #0f172a;
}
/* Status badges — vibrant colors visible on dark backgrounds */
[data-theme="dark"] .badge--broken        { background: rgba(239,68,68,.25); color: #fca5a5; border: 1px solid rgba(239,68,68,.4); }
[data-theme="dark"] .badge--waiting_parts { background: rgba(245,158,11,.25); color: #fcd34d; border: 1px solid rgba(245,158,11,.4); }
[data-theme="dark"] .badge--repairing     { background: rgba(59,130,246,.25); color: #93c5fd; border: 1px solid rgba(59,130,246,.4); }
[data-theme="dark"] .badge--in_stock      { background: rgba(34,197,94,.3); color: #4ade80; border: 1px solid rgba(34,197,94,.5); }
[data-theme="dark"] .badge--sold          { background: rgba(168,85,247,.35); color: #e9d5ff; border: 1px solid rgba(168,85,247,.6); font-weight: 700; }
[data-theme="dark"] .badge--returned      { background: rgba(234,179,8,.25); color: #fde047; border: 1px solid rgba(234,179,8,.4); }
[data-theme="dark"] .badge--scrapped      { background: rgba(100,116,139,.3); color: #cbd5e1; border: 1px solid rgba(100,116,139,.4); }
[data-theme="dark"] .badge--lost          { background: rgba(220,38,38,.3); color: #fca5a5; border: 1px solid rgba(220,38,38,.5); }
[data-theme="dark"] .badge--completed     { background: rgba(34,197,94,.2); color: #86efac; border: 1px solid rgba(34,197,94,.3); }
[data-theme="dark"] .badge--abandoned     { background: rgba(239,68,68,.2); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
[data-theme="dark"] .badge--warranty_return { background: rgba(245,158,11,.2); color: #fcd34d; border: 1px solid rgba(245,158,11,.3); }
[data-theme="dark"] .badge--in_progress   { background: rgba(59,130,246,.2); color: #93c5fd; border: 1px solid rgba(59,130,246,.3); }
[data-theme="dark"] .badge--paid          { background: rgba(34,197,94,.2); color: #86efac; border: 1px solid rgba(34,197,94,.3); }
[data-theme="dark"] .badge--unpaid        { background: rgba(245,158,11,.2); color: #fcd34d; border: 1px solid rgba(245,158,11,.3); }
[data-theme="dark"] .badge--refunded      { background: rgba(234,179,8,.2); color: #fde047; border: 1px solid rgba(234,179,8,.3); }
[data-theme="dark"] .badge--outcome-completed    { background: rgba(34,197,94,.2); color: #86efac; border: 1px solid rgba(34,197,94,.3); }
[data-theme="dark"] .badge--outcome-abandoned    { background: rgba(239,68,68,.2); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
[data-theme="dark"] .badge--outcome-warranty_return { background: rgba(245,158,11,.2); color: #fcd34d; border: 1px solid rgba(245,158,11,.3); }
[data-theme="dark"] .badge--outcome-pending      { background: rgba(100,116,139,.2); color: #94a3b8; border: 1px solid rgba(100,116,139,.3); }
[data-theme="dark"] .status-badge {
  font-weight: 600;
}
[data-theme="dark"] .nav-link:hover {
  background: #1e293b;
}
[data-theme="dark"] .select {
  background: #1e293b;
  color: #f8fafc;
  border-color: #334155;
}
[data-theme="dark"] .btn--secondary {
  background: #1e293b;
  color: #f8fafc;
  border-color: #334155;
}
[data-theme="dark"] .btn--secondary:hover {
  background: #334155;
}
/* Search inputs */
[data-theme="dark"] .search-input,
[data-theme="dark"] .form-input {
  background: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}
/* Date range bar */
[data-theme="dark"] .date-range-bar {
  background: #0f172a;
  border-color: #1e293b;
}
/* Chart canvases */
[data-theme="dark"] .chart-card {
  background: #0f172a;
  border-color: #1e293b;
}
/* Pipeline cards */
[data-theme="dark"] .pipeline-card {
  background: #0f172a;
  border-color: #1e293b;
}
/* Tabs / filters */
[data-theme="dark"] .status-filter .btn {
  background: #1e293b;
  color: #94a3b8;
  border-color: #334155;
}
[data-theme="dark"] .status-filter .btn.active,
[data-theme="dark"] .status-filter .btn--active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}
.pagination__info {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.btn--sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

/* Theme toggle button */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  margin-right: 8px;
}
.theme-toggle:hover {
  color: var(--primary);
  border-color: var(--primary);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* ---- MARGIN BADGE ---- */

.margin-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.margin-badge--green {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.margin-badge--amber {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

.margin-badge--red {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

/* ---- PROFIT CARD (Phone Passport) ---- */

.profit-card {
  margin-top: 1.25rem;
  padding: 1rem;
  background: var(--card-bg, var(--bg));
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
}

.profit-card .section-title {
  margin-bottom: 0.75rem;
}

.profit-card__rows {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.profit-card__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  font-size: 0.875rem;
}

.profit-card__row--total {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  margin-top: 0.25rem;
  font-weight: 600;
}

.profit-card__row--profit {
  border-top: 2px solid var(--border);
  padding-top: 0.625rem;
  margin-top: 0.375rem;
  font-weight: 700;
  font-size: 1rem;
}

.profit-card__row--profit.profit-detail--positive span:last-child {
  color: var(--success, #16a34a);
}

.profit-card__row--profit.profit-detail--negative span:last-child {
  color: var(--danger, #dc2626);
}

.profit-card__row--unsold span:last-child {
  color: var(--text-secondary);
}

/* ---- P&L SECTION ---- */

.pnl-section {
  margin-top: 2rem;
}

.pnl-section__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pnl-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pnl-chart-wrap {
  margin-bottom: 1.5rem;
}

.pnl-table-wrap {
  overflow-x: auto;
}

.pnl-table .text-right {
  text-align: right;
}

.pnl-table tbody tr:hover {
  background: var(--bg-hover, rgba(0,0,0,0.02));
}

.pnl-table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border);
}

.pnl-total--positive {
  color: var(--success, #16a34a);
}

.pnl-total--negative {
  color: var(--danger, #dc2626);
}

.select--sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
}

/* ────────────────────────────────────────────────────────────────────────────
   ROLE-BASED ACCESS CONTROL
   ──────────────────────────────────────────────────────────────────────────── */

/* Technician role: hide financial columns in phone list */
body.role-technician .col-cost,
body.role-technician .col-profit { display: none !important; }

/* Technician role: hide financial content in phone detail/passport */
body.role-technician .sensitive { display: none !important; }

/* Technician role: hide admin-only form fields (purchase cost, supplier, purchase source) */
body.role-technician .field-admin-only { display: none !important; }

/* Technician role: hide supplier nav link */
body.role-technician [data-view="suppliers"] { display: none !important; }

/* Technician role: hide settings nav link */
body.role-technician [data-view="settings"] { display: none !important; }

/* Technician role: hide delete buttons */
body.role-technician .btn--danger { display: none !important; }

/* Technician role: hide dashboard nav (techs go to phones) */
body.role-technician [data-view="dashboard"] { display: none !important; }

/* Technician role: hide POS/invoices nav */
body.role-technician [data-view="pos"] { display: none !important; }

/* Technician role: hide P&L section and CSV export buttons */
body.role-technician .pnl-section { display: none !important; }
body.role-technician #phones-export-csv { display: none !important; }
body.role-technician .margin-badge { display: none !important; }
body.role-technician [data-sort="margin"] { display: none !important; }

/* Role badge in topbar */
.topbar__user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: 1rem;
}

.topbar__username {
  font-size: 0.875rem;
  color: var(--text-secondary, #6b7280);
}

.role-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.role-badge--admin {
  background: var(--primary, #2563eb);
  color: #fff;
}

.role-badge--technician {
  background: #f59e0b;
  color: #fff;
}

/* Settings tabs */
.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border, #e5e7eb);
  margin-bottom: 1.5rem;
}

.settings-tab {
  padding: 0.75rem 1.5rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary, #6b7280);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.settings-tab:hover {
  color: var(--text, #111827);
}

.settings-tab--active {
  color: var(--primary, #2563eb);
  border-bottom-color: var(--primary, #2563eb);
}

.settings-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.settings-section__header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

.activity-filters {
  display: flex;
  gap: 0.5rem;
}

.activity-filters select {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  background: var(--bg, #fff);
}

/* User status indicators */
.status-active {
  color: #059669;
  font-weight: 500;
}

.status-inactive {
  color: #dc2626;
  font-weight: 500;
}

/* Settings view layout */
.view__header {
  margin-bottom: 1.5rem;
}

.view__header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.settings-section {
  margin-bottom: 2rem;
}

/* ---- Photo Grid ---- */
.photos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.photos-column__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.photos-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.photo-thumb {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border, #e2e8f0);
  cursor: pointer;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb__delete {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(239,68,68,0.9);
  color: #fff;
  border: none;
  font-size: 12px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.photo-thumb:hover .photo-thumb__delete {
  display: flex;
}

.photos-upload-zone {
  padding: 0.75rem;
  border: 2px dashed var(--border, #e2e8f0);
  border-radius: 8px;
  text-align: center;
}

.photos-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.photo-preview {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 4px;
  overflow: hidden;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview__remove {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  font-size: 11px;
  cursor: pointer;
  line-height: 1;
}

/* ---- Annotation Modal ---- */
.modal--annotation {
  max-width: 90vw;
  max-height: 90vh;
  padding: 1rem;
}

.annotation-container {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 70vh;
  overflow: hidden;
}

.annotation-container img {
  max-width: 100%;
  max-height: 70vh;
  display: block;
}

#annotation-canvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
  width: 100%;
  height: 100%;
}

.annotation-toolbar {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.75rem 0 0;
}

.photo-thumb__annotate {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(59,130,246,0.9);
  color: #fff;
  border: none;
  font-size: 12px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.photo-thumb:hover .photo-thumb__annotate {
  display: flex;
}

.photo-thumb__badge {
  position: absolute;
  bottom: 2px;
  left: 2px;
  font-size: 9px;
  background: rgba(59,130,246,0.85);
  color: #fff;
  padding: 1px 4px;
  border-radius: 3px;
}

/* Lightbox */
.modal--lightbox {
  background: rgba(0,0,0,0.95);
  max-width: 90vw;
  max-height: 90vh;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal--lightbox img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
}

.modal--lightbox .modal__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  color: #fff;
  font-size: 2rem;
  z-index: 10;
}

/* ------------------------------------------------------------
   BOTTOM TAB BAR (mobile only)
   ------------------------------------------------------------ */
.bottom-tab-bar {
  display: none;
}

.more-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 250;
}
.more-sheet-overlay.is-open {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.more-sheet {
  background: var(--card-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 400px;
  padding: 1rem 0 calc(1rem + env(safe-area-inset-bottom, 0px));
}

.more-sheet__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  min-height: 44px;
}
.more-sheet__item:hover,
.more-sheet__item:active {
  background: var(--primary-light);
}

/* ------------------------------------------------------------
   PHONE CARDS (mobile list)
   ------------------------------------------------------------ */
.phone-cards-list {
  display: none;
}

.phone-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  min-height: 44px;
  transition: box-shadow 150ms ease;
}
.phone-card:hover,
.phone-card:active {
  box-shadow: var(--shadow-md);
}

.phone-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.phone-card__imei {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.phone-card__body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
}

.phone-card__model {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
}

.phone-card__meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ------------------------------------------------------------
   CONSOLIDATED MOBILE BREAKPOINT (< 768px)
   ------------------------------------------------------------ */
@media (max-width: 767px) {
  /* Bottom tab bar */
  .bottom-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    z-index: 200;
    box-shadow: 0 -2px 8px rgba(0,0,0,.06);
  }

  .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .tab-item--active {
    color: var(--primary);
  }

  .tab-item svg {
    width: 20px;
    height: 20px;
  }

  /* Hide hamburger on mobile (tab bar replaces it) */
  #hamburger-btn {
    display: none !important;
  }

  /* Hide sidebar on mobile */
  .sidebar {
    transform: translateX(-100%);
    pointer-events: none;
  }

  /* Main content adjustments */
  .main {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }

  /* Show cards, hide tables on mobile */
  .phone-cards-list {
    display: block;
  }
}

/* ------------------------------------------------------------
   TABLET BREAKPOINT (768px - 1023px)
   ------------------------------------------------------------ */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar {
    width: 180px;
  }
  .main {
    margin-left: 180px;
  }
  .sidebar .nav-link span {
    font-size: 0.8125rem;
  }
}

/* Touch targets (min 44px) — buttons, nav, inputs */
.btn, button, a.nav-link, .tab-item, .phone-card, .more-sheet__item {
  min-height: 44px;
}
select, input:not([type="checkbox"]):not([type="radio"]), textarea {
  min-height: 44px;
}
@media (max-width: 767px) {
  input[type="checkbox"], input[type="radio"] {
    min-width: 24px;
    min-height: 24px;
  }
}

/* ------------------------------------------------------------
   SKELETON LOADING SCREENS
   ------------------------------------------------------------ */
.skeleton {
  background: var(--border);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,.15) 50%,
    transparent 100%
  );
  animation: skeleton-shimmer 1.4s infinite;
}

@keyframes skeleton-shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

.skeleton-row td {
  padding: 0.75rem 1rem;
}

.skeleton-cell {
  height: 16px;
  display: block;
}

.skeleton-card {
  height: 72px;
  margin-bottom: 0.5rem;
  border-radius: var(--radius);
}

.skeleton-stat {
  height: 100px;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

/* ------------------------------------------------------------
   VIEW TRANSITIONS
   ------------------------------------------------------------ */
.view--active {
  animation: viewFadeIn 200ms ease forwards;
}

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

/* Modal slide-up enhancement for mobile */
@media (max-width: 767px) {
  .modal-overlay.is-open .modal {
    animation: modalSlideUp 220ms cubic-bezier(.34,1.56,.64,1);
  }
}

@keyframes modalSlideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
