:root, [data-theme="light"] {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem;
  --color-bg:#f7f6f2; --color-surface:#f9f8f5; --color-surface-2:#fbfbf9; --color-border:#d4d1ca;
  --color-text:#28251d; --color-text-muted:#6f6d68; --color-text-faint:#a8a59e; --color-text-inverse:#f9f8f4;
  --color-primary:#01696f; --color-primary-hover:#0c4e54; --color-primary-highlight:#d6e7e4;
  --color-success:#437a22; --color-warning:#964219; --color-danger:#9c3b30;
  --radius-md:.625rem; --radius-lg:.875rem; --radius-xl:1.125rem;
  --shadow-sm:0 1px 2px rgba(34,31,24,.06),0 8px 24px rgba(34,31,24,.04); --shadow-md:0 10px 30px rgba(34,31,24,.08);
  --font-body:'Satoshi','Inter',sans-serif;
  --overlay-bg: rgba(247,246,242,.9);
  --focus-ring: rgba(1,105,111,.16);
  --status-pending-bg: rgba(150,66,25,.14);
  --status-approved-bg: rgba(67,122,34,.14);
  --status-draft-bg: rgba(168,165,158,.22);
  --status-revision-bg: rgba(156,59,48,.14);
  --status-rejected-bg: rgba(156,59,48,.2);
  --notice-success-bg: rgba(67,122,34,.14);
  --notice-success-border: rgba(67,122,34,.35);
}
[data-theme="dark"] {
  --color-bg:#171614; --color-surface:#1c1b19; --color-surface-2:#201f1d; --color-border:#3b3935;
  --color-text:#ede9e1; --color-text-muted:#b7b3aa; --color-text-faint:#817d75; --color-text-inverse:#161513;
  --color-primary:#5ea7af; --color-primary-hover:#81bac0; --color-primary-highlight:#263638;
  --color-success:#8bc06f; --color-warning:#d09568; --color-danger:#e0958a;
  --shadow-sm:0 1px 2px rgba(0,0,0,.24),0 8px 24px rgba(0,0,0,.2); --shadow-md:0 10px 30px rgba(0,0,0,.32);
  --overlay-bg: rgba(23,22,20,.9);
  --focus-ring: rgba(94,167,175,.2);
  --status-pending-bg: rgba(208,149,104,.16);
  --status-approved-bg: rgba(139,192,111,.16);
  --status-draft-bg: rgba(129,125,117,.24);
  --status-revision-bg: rgba(224,149,138,.16);
  --status-rejected-bg: rgba(224,149,138,.22);
  --notice-success-bg: rgba(139,192,111,.16);
  --notice-success-border: rgba(139,192,111,.4);
}
*,*::before,*::after{box-sizing:border-box} html,body{height:100%;margin:0;overflow-x:hidden;width:100%}
body{font-family:var(--font-body);font-size:var(--text-base);background:var(--color-bg);color:var(--color-text)}
button,a,input,select,textarea{font:inherit;color:inherit}
a{text-decoration:none}

/* Shell layout */
.dashboard{display:grid;grid-template-columns:280px 1fr;grid-template-rows:76px 1fr;height:100vh;height:100dvh;overflow:hidden}
.sidebar{grid-row:1/-1;background:var(--color-surface);border-right:1px solid rgba(40,37,29,.08);padding:var(--space-5);overflow:auto}
.brand{display:flex;align-items:center;gap:var(--space-3);font-weight:700;margin-bottom:var(--space-8)}
.brand-mark{width:42px;height:42px;border-radius:12px;background:var(--color-primary);display:grid;place-items:center;color:var(--color-text-inverse);box-shadow:var(--shadow-sm)}
.helper{font-size:var(--text-xs);color:var(--color-text-muted)}
.nav-section-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.12em;color:var(--color-text-faint);margin:0 0 var(--space-3)}
.nav{display:grid;gap:8px;margin-bottom:var(--space-6)}
.nav a{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:var(--radius-md);color:var(--color-text-muted);font-size:var(--text-sm);font-weight:600}
.nav a.active,.nav a:hover{background:var(--color-primary-highlight);color:var(--color-text)}
.header{display:flex;align-items:center;justify-content:space-between;padding:0 var(--space-6);border-bottom:1px solid rgba(40,37,29,.08);background:var(--overlay-bg)}
.header h2{font-size:var(--text-lg);margin:0}
.header-meta{font-size:var(--text-xs);color:var(--color-text-muted)}
.header-actions{display:flex;align-items:center;gap:var(--space-3)}
.header-left{display:flex;align-items:center;gap:var(--space-3);min-width:0}
.header-left > div{min-width:0}
.menu-toggle{display:none;width:44px;height:44px;border-radius:999px;border:1px solid var(--color-border);background:var(--color-surface);align-items:center;justify-content:center;cursor:pointer;flex-shrink:0;font-size:1.1rem;color:var(--color-text)}
.sidebar-backdrop{display:none;position:fixed;top:0;right:0;bottom:0;left:0;background:rgba(20,18,14,.45);z-index:45;border:none}
.sidebar-backdrop.open{display:block}
.pill{padding:10px 12px;border-radius:999px;background:var(--color-surface);border:1px solid var(--color-border);font-size:var(--text-xs);font-weight:700}
.theme-toggle{width:44px;height:44px;border-radius:999px;border:1px solid var(--color-border);background:var(--color-surface);display:grid;place-items:center;cursor:pointer}
.btn{border:none;border-radius:var(--radius-md);padding:12px 14px;font-weight:700;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:8px;min-width:0;max-width:100%}
.btn-secondary{background:var(--color-surface-2);border:1px solid var(--color-border)}
.btn-primary{background:var(--color-primary);color:var(--color-text-inverse)}
.btn-primary:hover{background:var(--color-primary-hover)}
.btn-danger{background:transparent;border:1px solid var(--color-danger);color:var(--color-danger)}
.btn-sm{padding:8px 10px;font-size:var(--text-xs)}
.main{overflow:auto;padding:var(--space-6);display:grid;gap:var(--space-6)}
.panel{background:var(--color-surface);border:1px solid rgba(40,37,29,.08);border-radius:var(--radius-xl);box-shadow:var(--shadow-sm)}
.panel-pad{padding:var(--space-6)}
.eyebrow{font-size:var(--text-xs);letter-spacing:.12em;text-transform:uppercase;color:var(--color-text-muted);margin-bottom:var(--space-4)}

/* Welcome + today's snapshot (reused by any role's landing page) */
.welcome{display:grid;grid-template-columns:1.2fr .8fr;gap:var(--space-6)}
.welcome h1{font-size:var(--text-xl);margin:0 0 var(--space-3)}
.welcome p{margin:0;color:var(--color-text-muted);max-width:58ch}
.quick-actions{display:flex;gap:var(--space-3);margin-top:var(--space-6);flex-wrap:wrap}
.mini-list{display:grid;gap:var(--space-4)}
.mini-item{display:flex;justify-content:space-between;gap:var(--space-4);padding-bottom:var(--space-4);border-bottom:1px solid rgba(40,37,29,.08)}
.mini-item:last-child{border-bottom:none;padding-bottom:0}
.mini-title{font-weight:700;font-size:var(--text-sm)}
.mini-sub{font-size:var(--text-xs);color:var(--color-text-muted);margin-top:4px}
.amount{font-weight:800;font-variant-numeric:tabular-nums lining-nums}

/* Stat cards (reused by any dashboard) */
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:var(--space-4)}
.stat{padding:var(--space-5)}
.stat-label{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.08em;color:var(--color-text-muted);margin-bottom:8px}
.stat-value{font-size:clamp(1.4rem,2vw,2rem);font-weight:900;font-variant-numeric:tabular-nums lining-nums}
.stat-note{margin-top:8px;font-size:var(--text-xs);color:var(--color-text-muted)}

/* Section head + table (reused by any list/queue page) */
.section-head{display:flex;justify-content:space-between;align-items:center;padding:var(--space-5) var(--space-6);border-bottom:1px solid rgba(40,37,29,.08);flex-wrap:wrap;gap:var(--space-3)}
.section-head h3{margin:0;font-size:var(--text-base)}
table{width:100%;border-collapse:collapse}
th,td{padding:14px 16px;text-align:left;font-size:var(--text-sm)}
th{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.08em;color:var(--color-text-muted);border-bottom:1px solid rgba(40,37,29,.08)}
td{border-bottom:1px solid rgba(40,37,29,.06)}
tr:last-child td{border-bottom:none}

/* Status pills (reused across enquiries/invoices) */
.status{display:inline-flex;align-items:center;gap:8px;padding:8px 10px;border-radius:999px;font-size:var(--text-xs);font-weight:700}
.status.pending{background:var(--status-pending-bg);color:var(--color-warning)}
.status.approved{background:var(--status-approved-bg);color:var(--color-success)}
.status.draft{background:var(--status-draft-bg);color:var(--color-text-muted)}
.status.revision{background:var(--status-revision-bg);color:var(--color-danger)}
.status.rejected{background:var(--status-rejected-bg);color:var(--color-danger)}

/* Filter tabs (reused for any filterable queue) */
.tabs{display:flex;gap:8px;flex-wrap:wrap}
.tab{border:1px solid var(--color-border);background:var(--color-surface-2);padding:8px 14px;border-radius:999px;font-size:var(--text-xs);font-weight:700;cursor:pointer;color:var(--color-text-muted)}
.tab.active{background:var(--color-primary);border-color:var(--color-primary);color:var(--color-text-inverse)}

/* Choice grid (reused for shipment type, template picks, etc.) */
.choice-grid{display:grid;gap:var(--space-3)}
.choice-btn{border:1px solid var(--color-border);background:var(--color-surface-2);padding:var(--space-4);border-radius:var(--radius-lg);text-align:left;cursor:pointer}
.choice-btn.active{border-color:var(--color-primary);background:var(--color-primary-highlight)}
.choice-btn span{display:block;font-size:var(--text-xs);color:var(--color-text-muted);margin-top:4px}

/* Form fields (reused for any data-entry page) */
.field{display:grid;gap:8px;margin-bottom:var(--space-4)}
.field label{font-size:var(--text-sm);font-weight:700}
.input,textarea,select{width:100%;border:1px solid var(--color-border);background:var(--color-surface-2);color:var(--color-text);padding:14px;border-radius:var(--radius-md);outline:none}
.input:focus,textarea:focus,select:focus{border-color:var(--color-primary);box-shadow:0 0 0 4px var(--focus-ring)}
textarea{resize:vertical;min-height:100px}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:var(--space-4)}
.form-section{margin-bottom:var(--space-6)}
.form-section:last-child{margin-bottom:0}
.form-section-title{font-weight:700;font-size:var(--text-sm);margin-bottom:var(--space-4)}


.sidebar::-webkit-scrollbar { display: none; }
.sidebar { scrollbar-width: none; }

/* Notice banner (confirmation messages) */
.notice{align-items:center;gap:12px;padding:var(--space-4) var(--space-5);border-radius:var(--radius-lg);font-size:var(--text-sm);font-weight:600}
.notice-success{background:var(--notice-success-bg);color:var(--color-success);border:1px solid var(--notice-success-border)}

/* Inline note preview under a reference/customer cell */
.note-preview{font-size:var(--text-xs);color:var(--color-text-muted);margin-top:4px;max-width:32ch}



/* ============================================================
   APPEND THIS to the END of shell.css (and index.css if separate)
   Do NOT delete existing rules — this only ADDS new ones, plus
   one small change to .sidebar (see note below).
   ============================================================ */

/* 1. Make the sidebar a column flex container so the footer
      badge sticks to the bottom, nav scrolls above it. */
.sidebar {
  display: flex;
  flex-direction: column;
}
.sidebar-scroll {
  flex: 1;
  overflow: auto;
}

/* 2. Nav icons (inline SVGs inside each <a>) */
.nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
}

/* 3. Footer role badge, pinned to bottom of sidebar */
.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-top: var(--space-4);
  margin-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}
.role-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--color-text);
  color: var(--color-text-inverse);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: var(--text-sm);
  flex-shrink: 0;
}
.role-info { display: flex; flex-direction: column; min-width: 0; }
.role-name { font-weight: 700; font-size: var(--text-sm); }
.role-sub { font-size: var(--text-xs); color: var(--color-text-muted); }
.role-logout {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: var(--color-text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.role-logout:hover { background: var(--color-surface-2); color: var(--color-text); }

.job-number-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.job-number-text {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  border-radius: 6px;
  color: var(--color-text-faint);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}

.copy-btn:hover {
  background: var(--color-primary-highlight);
  color: var(--color-primary);
}

.copy-btn.copied {
  color: var(--color-success);
}

.copy-btn::after {
  content: "Copied";
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--color-text);
  color: var(--color-text-inverse);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}

.copy-btn.copied::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1080px) {
  .role-info, .role-name + .role-sub { display: none; }
  .sidebar-footer { justify-content: center; }
}
@media (max-width: 720px) {
  .role-info { display: flex; }
  .sidebar-footer { justify-content: space-between; }
} 

@media (max-width:1080px){
  .dashboard{grid-template-columns:88px 1fr}
  .sidebar .label,.nav-section-title,.company-copy{display:none}
  .nav a{justify-content:center}
  .brand{justify-content:center}
  .welcome{grid-template-columns:1fr}
  .stats{grid-template-columns:repeat(2,1fr)}
  .form-grid{grid-template-columns:1fr}
}
@media (max-width:720px){
  .dashboard{display:block;height:auto;overflow:visible}
  .menu-toggle{display:inline-flex}
  .sidebar{
    display:flex;flex-direction:column;
    position:fixed;top:0;left:0;bottom:0;
    width:78vw;max-width:300px;
    height:100vh;height:100dvh;
    -webkit-overflow-scrolling:touch;
    transform:translateX(-105%);
    -webkit-transform:translateX(-105%);
    transition:transform .25s ease;
    z-index:999;box-shadow:var(--shadow-md);
  }
  .sidebar.open{transform:translateX(0);-webkit-transform:translateX(0)}
  .sidebar .label{display:inline}
  .nav-section-title,.company-copy{display:block}
  .nav a{justify-content:flex-start}
  .brand{justify-content:flex-start}
  .header{position:sticky;top:0;padding:10px var(--space-3);z-index:20;flex-wrap:wrap;row-gap:6px}
  .header-meta{display:none}
  .header-left,.header-actions{gap:8px}
  .menu-toggle,.theme-toggle{width:36px;height:36px}
  .pill{display:none}
  .header-actions .btn{padding:8px 10px;font-size:var(--text-xs)}
  .header h2{font-size:1.05rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:52vw}
  .main{padding:var(--space-4)}
  .stats{grid-template-columns:1fr}
  .btn{padding:10px 14px;font-size:var(--text-sm)}
  .quick-actions{gap:8px}
  table td:first-child,table th:first-child{position:sticky;left:0;background:var(--color-surface);border-right:1px solid rgba(40,37,29,.08)}
}
@media (max-width:480px){
  .panel-pad{padding:var(--space-4)}
  .btn{padding:8px 12px;font-size:var(--text-xs)}
  .stat-value{font-size:1.4rem}
}
@media (max-width: 720px) {
  .menu-toggle { width: 44px; height: 44px; }
  .role-logout { width: 40px; height: 40px; }
  .copy-btn { width: 34px; height: 34px; }
  .copy-btn svg { width: 16px; height: 16px; }
  .tab { padding: 10px 16px; min-height: 40px; display: inline-flex; align-items: center; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; padding: 9px 12px; }
  .nav a { min-height: 46px; }
}

/* 2. Header: stack cleanly on very small screens instead of squeezing */
@media (max-width: 480px) {
  .header {
    flex-wrap: wrap;
    padding: 10px 12px;
    row-gap: 8px;
  }
  .header h2 { font-size: 1rem; max-width: 60vw; }
  .header-meta { display: none; }
  .header-actions { gap: 6px; }
  .header-actions .btn { padding: 8px 10px; font-size: 12px; }
  .header-actions .pill { display: none; }
}

/* 3. Quick-action buttons: full width stacked on phones (easier tapping
      than 3 buttons squeezed and wrapped) */
@media (max-width: 640px) {
  .quick-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .quick-actions .btn { width: 100%; }
  .welcome { grid-template-columns: 1fr; }
}

/* 4. THE BIG ONE — convert data tables into stacked cards on phones.
      Requires adding data-label="Column Name" to every <td> (see below). */
@media (max-width: 720px) {
  table.mobile-cards,
  table.mobile-cards thead,
  table.mobile-cards tbody,
  table.mobile-cards th,
  table.mobile-cards td,
  table.mobile-cards tr {
    display: block;
    width: 100%;
  }

  table.mobile-cards thead { display: none; }

  table.mobile-cards tr {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
  }

  table.mobile-cards td {
    border-bottom: none;
    padding: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    text-align: right;
  }

  table.mobile-cards td::before {
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-text-muted);
    text-align: left;
    flex-shrink: 0;
  }

  /* First cell (job number) styled like a card title, not a label row */
  table.mobile-cards td:first-child {
    padding-bottom: 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
    justify-content: flex-start;
  }
  table.mobile-cards td:first-child::before { display: none; }

  /* Action cell (buttons) — stack full width, no label row */
  table.mobile-cards td.action-cell {
    justify-content: stretch;
    padding-top: 12px;
  }
  table.mobile-cards td.action-cell::before { display: none; }
  table.mobile-cards td.action-cell > div {
    width: 100%;
  }
  table.mobile-cards td.action-cell .btn { flex: 1; }

  /* sticky-column rule from the old layout no longer applies */
  table.mobile-cards td:first-child,
  table.mobile-cards th:first-child {
    position: static;
    background: transparent;
    border-right: none;
  }
}

/* 5. Stat cards: keep 2-per-row down to 400px, then single column */
@media (max-width: 400px) {
  .stats { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.5rem; }
}

/* 6. Sidebar drawer: slightly wider on very small phones for readability */
@media (max-width: 400px) {
  .sidebar { width: 86vw; }
}

.bottom-nav {
  display: none;
}

@media (max-width: 720px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64px;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -4px 16px rgba(0,0,0,.06);
    z-index: 80;
    align-items: center;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--color-text-muted);
    font-size: 10px;
    font-weight: 700;
    flex: 1;
    height: 100%;
    min-width: 44px;
  }

  .bottom-nav-item svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
  }

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

  .bottom-nav-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 999px;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    margin-top: -26px;
    box-shadow: 0 6px 16px rgba(1,105,111,.35);
    flex-shrink: 0;
    border: 4px solid var(--color-surface);
  }

  .bottom-nav-fab svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
  }

  /* Prevent page content from hiding behind the fixed bar */
  .main {
    padding-bottom: calc(var(--space-6) + 76px);
  }
}