/* Job Cards 19.6 — new look (navy + brand lime). Loaded last on every page, so it only restyles; no layout logic depends on it. */

:root {
  --v2-navy: #0E1F3D;
  --v2-navy2: #16305C;
  --v2-navy3: #1F3F75;
  --v2-lime: #8DC63F;
  --v2-lime-ink: #3F6B0E;
  --v2-lime-soft: #EEF6E2;
  --v2-blue: #2457D6;
  --v2-blue-soft: #EEF3FF;
  --v2-bg: #F4F6FA;
  --v2-surface: #FFFFFF;
  --v2-surface2: #EEF1F6;
  --v2-line: #E3E8F0;
  --v2-text: #0E1F3D;
  --v2-muted: #586174;
  --v2-red: #B42318;
  --v2-red-soft: #FFECEA;
  --v2-amber: #8A4205;
  --v2-amber-soft: #FFF4E0;
  --v2-green: #1A6B33;
  --v2-green-soft: #E8F6EC;
  --v2-shadow: 0 1px 2px rgba(14, 31, 61, .05), 0 8px 24px rgba(14, 31, 61, .07);
  --v2-shadow-lg: 0 16px 40px rgba(14, 31, 61, .18);

  /* The older style sheets read these names — point them at the new palette. */
  --navy: var(--v2-text);
  --ink: var(--v2-text);
  --muted: var(--v2-muted);
  --line: var(--v2-line);
  --orange: var(--v2-lime);
  --blue: var(--v2-blue);
  --forest: var(--v2-navy);
  --forest2: var(--v2-navy2);
  --lime: var(--v2-lime);
  --lime-soft: var(--v2-lime-soft);
  --soft: var(--v2-muted);
  --card: var(--v2-surface);
  --page: var(--v2-bg);
  --ring: var(--v2-shadow);
  --p-line: var(--v2-line);
  --p-tint: var(--v2-bg);
  --p-shadow: var(--v2-shadow-lg);
  --info: var(--v2-blue);
  --info-bg: var(--v2-blue-soft);
  accent-color: var(--v2-navy);
  background: var(--v2-bg);
  color: var(--v2-text);
}
body { background: var(--v2-bg); color: var(--v2-text); }
:focus-visible { outline: 2.5px solid var(--v2-blue) !important; outline-offset: 2px; }

/* ---------- Buttons, fields ---------- */
button, .button { border-radius: 14px; }
button.primary, .primary, .login-box button.primary, #job-form button[type=submit] {
  background: var(--v2-navy) !important; border-color: var(--v2-navy) !important; color: #fff !important;
  box-shadow: 0 6px 16px rgba(14, 31, 61, .18);
  transition: transform .12s ease, background .2s ease;
}
button.primary:active, .primary:active { transform: scale(.97); background: var(--v2-navy2) !important; }
button:disabled { opacity: .55; }
input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea {
  border-color: #DCE2EC; border-radius: 14px; background-color: var(--v2-surface); color: var(--v2-text);
}
input:focus, select:focus, textarea:focus { outline: 0 !important; border-color: var(--v2-blue) !important; box-shadow: 0 0 0 4px rgba(36, 87, 214, .12) !important; }
.eyebrow, .workshop-kicker { color: var(--v2-lime-ink); }

/* ---------- Login ---------- */
body.login-page { background: var(--v2-bg); }
.login-box { border: 1px solid var(--v2-line); border-radius: 28px; box-shadow: var(--v2-shadow); }
.login-box > img { width: 96px; padding: 10px; border-radius: 24px; background: #fff; box-shadow: 0 6px 16px rgba(14, 31, 61, .08); }
.login-box h1 { color: var(--v2-text); font-size: 30px; }
.login-box input { min-height: 56px; font-size: 16px; }
.login-box button.primary { min-height: 56px; font-size: 17px; border-radius: 16px; }
.login-box .eyebrow { color: var(--v2-lime-ink); }

/* ---------- Workshop dashboard ---------- */
.workshop-hero { background: var(--v2-navy) !important; border-radius: 28px; box-shadow: 0 16px 32px rgba(14, 31, 61, .20); }
.workshop-hero::after { border-color: rgba(141, 198, 63, .18) !important; }
.workshop-hero p { color: #B7C2D6 !important; }
.workshop-kicker { color: #B9E082 !important; }
.hero-actions .primary, #workshop-new { background: var(--v2-lime) !important; border-color: var(--v2-lime) !important; color: var(--v2-navy) !important; font-weight: 700; box-shadow: 0 8px 20px rgba(110, 160, 40, .35); }
.workshop-metric, .workshop-currency, .pipeline-step, .workshop-ticket, .workshop-toolbar input, .workshop-toolbar select {
  border-color: var(--v2-line) !important; background: var(--v2-surface); border-radius: 20px;
}
.workshop-metric { box-shadow: none; transition: transform .15s ease, box-shadow .2s ease; }
.workshop-metric:active { transform: scale(.98); }
.workshop-metric-symbol { border-radius: 12px; background: var(--v2-blue-soft) !important; color: var(--v2-blue) !important; }
.metric-overdue .workshop-metric-symbol { background: var(--v2-red-soft) !important; color: var(--v2-red) !important; }
.metric-ready .workshop-metric-symbol { background: var(--v2-green-soft) !important; color: var(--v2-green) !important; }
.metric-balance .workshop-metric-symbol { background: var(--v2-amber-soft) !important; color: var(--v2-amber) !important; }
.workshop-metric[aria-pressed=true] { border-color: var(--v2-navy) !important; box-shadow: 0 0 0 1px var(--v2-navy) !important; }
.currency-heading > b { background: var(--v2-surface2); }
.currency-foot b { color: var(--v2-green); }
.stage-0 { --stage: #8A93A5; } .stage-1 { --stage: #2457D6; } .stage-2 { --stage: #D9822B; }
.stage-3 { --stage: #6431C9; } .stage-4 { --stage: #2E9E50; } .stage-5 { --stage: #586174; }
.text-button, #go-board { color: var(--v2-blue) !important; }
.workshop-ticket { box-shadow: none; }
.workshop-ticket.ticket-late { border-color: #F3C9C6 !important; }
.late-label { background: var(--v2-red-soft) !important; color: var(--v2-red) !important; border-radius: 10px; }
.ticket-number { font-family: ui-monospace, 'SF Mono', Menlo, monospace; direction: ltr; color: var(--v2-muted); }
.ticket-open { color: var(--v2-text) !important; }

/* ---------- Global search ---------- */
.pro-search { background: var(--v2-surface) !important; border: 1px solid var(--v2-line); box-shadow: 0 4px 12px rgba(14, 31, 61, .05) !important; border-radius: 16px; }
.pro-search:focus-within { border-color: var(--v2-blue); box-shadow: 0 0 0 4px rgba(36, 87, 214, .12) !important; }
.pro-search input { color: var(--v2-text) !important; }
.pro-search input::placeholder { color: #7A8396 !important; }
.pro-search-icon { color: var(--v2-muted) !important; }
.pro-search .pro-mic { background: var(--v2-blue-soft) !important; color: var(--v2-blue) !important; border-radius: 12px; }
.pro-voice-fab { background: var(--v2-navy) !important; color: #fff !important; border: 0 !important; box-shadow: var(--v2-shadow-lg) !important; }

/* ---------- Dialogs ---------- */
dialog { border-radius: 24px !important; }
dialog::backdrop { background: rgba(10, 22, 40, .55) !important; backdrop-filter: blur(2px); }

/* ---------- Engineer page ---------- */
.engineer-header { background: var(--v2-navy) !important; }
.job-tile, .job-sheet, .empty { border-color: var(--v2-line) !important; border-radius: 20px; }
.status { background: var(--v2-blue-soft); color: #1D47B8; border-radius: 10px; }
.job-title { border-bottom-color: var(--v2-lime) !important; }
th { background: var(--v2-bg); }
.eng-tabbar { background: rgba(255, 255, 255, .96) !important; border-top: 1px solid var(--v2-line); }

/* =====================================================================
   Phone layout (≤ 760px): top app bar, bottom tab bar, "more" sheet.
   The tab bar and sheet are added by mobile-v2.js; without it nothing below shows.
   ===================================================================== */
.v2-appbar, .v2-tabbar, .v2-sheet, .v2-scrim { display: none; }

@media (max-width: 760px) {
  body.v2 { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

  /* Top app bar: the sidebar shrinks to the logo, name and bell. */
  body.v2 .sidebar {
    position: sticky !important; top: 0; z-index: 40; height: auto !important; width: auto !important;
    display: flex !important; flex-direction: row !important; align-items: center; gap: 12px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px !important;
    background: rgba(244, 246, 250, .92) !important; backdrop-filter: saturate(1.4) blur(14px);
    border: 0 !important; border-bottom: 1px solid var(--v2-line) !important; box-shadow: none !important;
  }
  body.v2 .sidebar .brand { flex-direction: row !important; align-items: center; gap: 12px; padding: 0 !important; text-align: start !important; flex: 1; min-width: 0; text-decoration: none; }
  body.v2 .sidebar .brand-logo-wrap { width: 44px; height: 44px; padding: 4px !important; border-radius: 14px !important; flex-shrink: 0; display: grid; place-items: center; box-shadow: 0 2px 8px rgba(14, 31, 61, .08) !important; }
  body.v2 .sidebar .brand-logo { width: 36px !important; height: 36px !important; max-height: none !important; }
  body.v2 .sidebar .brand-name { color: var(--v2-text) !important; font-size: 17px !important; font-weight: 700; line-height: 1.25; display: flex; flex-direction: column; }
  body.v2 .sidebar .brand-name small { color: var(--v2-muted) !important; font-size: 12px !important; font-weight: 400; }
  body.v2 .sidebar .nav, body.v2 .sidebar .nav-label, body.v2 .sidebar .side-bottom, body.v2 .sidebar .side-note, body.v2 .sidebar .user { display: none !important; }
  .v2-appbar { display: flex; gap: 8px; }
  .v2-icon-btn {
    position: relative; width: 44px; height: 44px; padding: 0 !important; border-radius: 14px !important;
    background: var(--v2-surface) !important; border: 1px solid var(--v2-line) !important; color: var(--v2-text) !important;
    display: grid !important; place-items: center; box-shadow: none !important;
  }
  .v2-dot { position: absolute; top: 9px; left: 10px; min-width: 10px; height: 10px; border-radius: 6px; background: #E5484D; border: 2px solid var(--v2-surface); }

  /* The crowded tools row moves into the "more" sheet. */
  body.v2 .topbar { display: none !important; }
  body.v2 .app { padding-top: 0 !important; }
  body.v2 main { padding: 0 16px !important; }
  body.v2 .pro-search { margin: 12px 16px 4px !important; }

  /* Dashboard on the phone */
  body.v2 .workshop-hero { margin: 8px 0 16px !important; padding: 22px 20px !important; }
  body.v2 .workshop-hero h1 { font-size: 24px !important; }
  body.v2 .hero-actions { width: 100%; display: grid !important; grid-template-columns: 1fr auto; }
  body.v2 .hero-actions button { min-height: 48px; }
  body.v2 .workshop-metrics { gap: 12px !important; }
  body.v2 .workshop-metric { padding: 14px !important; border-radius: 20px !important; }
  body.v2 .workshop-metric strong { font-size: 30px !important; }
  body.v2 .workshop-pipeline { display: flex !important; overflow-x: auto; gap: 8px !important; margin: 0 -16px; padding: 0 16px 4px; scroll-snap-type: x mandatory; scrollbar-width: none; }
  body.v2 .workshop-pipeline::-webkit-scrollbar { display: none; }
  body.v2 .pipeline-step { flex: 0 0 auto; min-width: 116px; scroll-snap-align: start; border-radius: 18px !important; }
  body.v2 .workshop-ticket { border-radius: 22px !important; padding: 16px !important; }
  body.v2 footer.no-print { padding-bottom: 8px; }

  /* Voice button sits above the tab bar, away from the + button. */
  body.v2 .pro-voice-fab { bottom: calc(108px + env(safe-area-inset-bottom)) !important; left: 16px !important; right: auto !important; width: 52px !important; height: 52px !important; border-radius: 18px !important; }

  body.v2 .pro-voice-fab { z-index: 45 !important; }
  body.v2-sheet-open .pro-voice-fab { opacity: 0; pointer-events: none; }
  .v2-sheet .cloud-top-actions > button.v2-hide { display: none !important; }
  body.v2 .workshop-ticket select { background-color: var(--v2-surface2) !important; border-color: transparent !important; min-height: 44px; }

  /* Bottom tab bar */
  .v2-tabbar {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center;
    padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .96); backdrop-filter: saturate(1.4) blur(16px);
    border-top: 1px solid var(--v2-line);
  }
  .v2-tab {
    all: unset; box-sizing: border-box; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 11px; font-weight: 500; color: var(--v2-muted); cursor: pointer; position: relative; border-radius: 14px;
    -webkit-tap-highlight-color: transparent; transition: color .2s ease;
  }
  .v2-tab svg { width: 24px; height: 24px; transition: transform .2s ease; }
  .v2-tab[aria-current=page] { color: var(--v2-text); font-weight: 700; }
  .v2-tab[aria-current=page]::before { content: ''; position: absolute; top: -9px; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--v2-lime); }
  .v2-tab:active svg { transform: scale(.9); }
  .v2-tab:focus-visible { outline: 2.5px solid var(--v2-blue); }
  .v2-fab-wrap { display: flex; justify-content: center; }
  .v2-fab {
    all: unset; box-sizing: border-box; width: 60px; height: 60px; margin-top: -30px; border-radius: 22px; cursor: pointer;
    background: var(--v2-lime); color: var(--v2-navy); display: grid; place-items: center;
    border: 4px solid var(--v2-bg); box-shadow: 0 10px 24px rgba(110, 160, 40, .40); transition: transform .12s ease;
  }
  .v2-fab:active { transform: scale(.94); }
  .v2-fab:focus-visible { outline: 2.5px solid var(--v2-blue); outline-offset: 2px; }
  .v2-fab svg { width: 26px; height: 26px; }
  .v2-badge { position: absolute; top: 2px; left: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; background: #E5484D; color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }

  /* "More" sheet */
  .v2-scrim { display: block; position: fixed; inset: 0; z-index: 60; background: rgba(10, 22, 40, .45); opacity: 0; pointer-events: none; transition: opacity .25s ease; }
  .v2-sheet {
    display: flex; flex-direction: column; gap: 20px; position: fixed; z-index: 61; left: 0; right: 0; bottom: 0;
    max-height: 86vh; overflow-y: auto; overscroll-behavior: contain;
    padding: 12px 20px calc(28px + env(safe-area-inset-bottom)); background: var(--v2-bg);
    border-radius: 28px 28px 0 0; box-shadow: 0 -16px 40px rgba(14, 31, 61, .18);
    transform: translateY(105%); transition: transform .32s cubic-bezier(.2, .9, .3, 1.05); visibility: hidden;
  }
  body.v2-sheet-open .v2-scrim { opacity: 1; pointer-events: auto; }
  body.v2-sheet-open .v2-sheet { transform: none; visibility: visible; }
  body.v2-sheet-open { overflow: hidden; }
  .v2-grabber { width: 40px; height: 5px; border-radius: 3px; background: #CBD3E0; margin: 0 auto 4px; }
  .v2-sheet-head { display: flex; align-items: center; justify-content: space-between; }
  .v2-sheet-head h2 { margin: 0; font-size: 22px; color: var(--v2-text); }
  .v2-sheet h3 { margin: 0 4px -8px; font-size: 13px; font-weight: 700; color: var(--v2-muted); }
  .v2-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .v2-tile, .v2-sheet .cloud-top-actions > button, .v2-sheet .side-bottom > a, .v2-sheet .side-bottom > button {
    all: unset; box-sizing: border-box; cursor: pointer; min-height: 88px; padding: 12px 8px; border-radius: 20px;
    background: var(--v2-surface); border: 1px solid var(--v2-line); color: var(--v2-text);
    display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    font-size: 12.5px; font-weight: 600; text-align: center; line-height: 1.35; position: relative;
    transition: transform .12s ease, background .2s ease;
  }
  .v2-tile:active, .v2-sheet .cloud-top-actions > button:active { transform: scale(.96); background: var(--v2-surface2); }
  .v2-sheet .cloud-top-actions { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: auto !important; margin: 0 !important; }
  .v2-sheet .cloud-top-actions .pro-sep { display: none !important; }
  .v2-sheet .cloud-top-actions > button.primary { background: var(--v2-navy) !important; color: #fff !important; border-color: var(--v2-navy) !important; box-shadow: none; }
  .v2-sheet #cloud-logout { color: var(--v2-red) !important; background: var(--v2-red-soft) !important; border-color: transparent !important; }
  .v2-sheet .side-bottom { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; position: static !important; padding: 0 !important; border: 0 !important; background: none !important; }
  .v2-sheet .side-bottom > a, .v2-sheet .side-bottom > button { min-height: 56px; flex-direction: row; text-decoration: none; }
  .v2-ico { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--v2-blue-soft); color: var(--v2-blue); flex-shrink: 0; }
  .v2-ico svg { width: 22px; height: 22px; }
  .v2-ico.t-red { background: var(--v2-red-soft); color: var(--v2-red); }
  .v2-ico.t-green { background: var(--v2-green-soft); color: var(--v2-green); }
  .v2-ico.t-amber { background: var(--v2-amber-soft); color: var(--v2-amber); }
  .v2-ico.t-purple { background: #F2ECFF; color: #6431C9; }
  .v2-ico.t-navy { background: var(--v2-surface2); color: var(--v2-text); }
  .v2-sheet .primary .v2-ico { background: rgba(255, 255, 255, .14); color: #fff; }
  #cloud-logout .v2-ico { background: transparent; color: var(--v2-red); }
  .v2-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 16px; background: var(--v2-surface2); }
  .v2-seg button { all: unset; box-sizing: border-box; min-height: 44px; border-radius: 12px; text-align: center; font-size: 14px; font-weight: 600; color: var(--v2-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
  .v2-seg button[aria-pressed=true] { background: var(--v2-surface); color: var(--v2-text); box-shadow: 0 2px 6px rgba(14, 31, 61, .12); }
  .v2-seg svg { width: 18px; height: 18px; }
  .v2-close { all: unset; cursor: pointer; width: 44px; height: 44px; border-radius: 14px; background: var(--v2-surface); border: 1px solid var(--v2-line); display: grid; place-items: center; color: var(--v2-text); box-sizing: border-box; }
}

@media print { .v2-tabbar, .v2-sheet, .v2-scrim, .v2-appbar { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .v2-sheet, .v2-scrim, .v2-tab svg, .v2-fab, .workshop-metric { transition: none !important; } }

/* =====================================================================
   Night mode — <html data-theme="dark">, or "auto" following the phone.
   ===================================================================== */
html[data-theme=dark] {
  --v2-bg: #0A111F; --v2-surface: #131D2F; --v2-surface2: #1C2840; --v2-line: #24324B;
  --v2-text: #EEF2F8; --v2-muted: #A3AEC2; --v2-blue: #8FAEFF; --v2-blue-soft: rgba(127, 160, 255, .14);
  --v2-lime-ink: #B9E082; --v2-red: #FF8A80; --v2-red-soft: rgba(229, 72, 77, .16);
  --v2-amber: #F5C27A; --v2-amber-soft: rgba(245, 180, 91, .14); --v2-green: #7DD69A; --v2-green-soft: rgba(125, 214, 154, .14);
  --v2-shadow: 0 1px 2px rgba(0, 0, 0, .3); --v2-shadow-lg: 0 16px 40px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
html[data-theme=dark] .workshop-hero { background: #1A2D52 !important; }
html[data-theme=dark] :is(.workshop-metric, .workshop-currency, .pipeline-step, .workshop-ticket, .job-tile, .job-sheet, .empty, .login-box,
  .workshop-toolbar input, .workshop-toolbar select, dialog, .pro-search-results, .card, .panel, section.card, article, .editor-section, .section,
  .metric, .table-wrap, .office-dialog, .phone-dialog, .chat-panel, .stats-dialog, .pro-late-row, .rem-row, .op-row) {
  background-color: var(--v2-surface) !important; color: var(--v2-text) !important; border-color: var(--v2-line) !important;
}
html[data-theme=dark] :is(input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea) { background-color: var(--v2-surface2) !important; color: var(--v2-text) !important; border-color: var(--v2-line) !important; }
html[data-theme=dark] :is(h1, h2, h3, h4, b, strong, label, dt, dd, td, .ticket-open) { color: var(--v2-text); }
html[data-theme=dark] :is(p, small, .muted, .ticket-machine, .ticket-facts, th) { color: var(--v2-muted) !important; }
html[data-theme=dark] th, html[data-theme=dark] tr:nth-child(even) td { background: var(--v2-surface2) !important; }
html[data-theme=dark] button:not(.primary):not(.v2-tab):not(.v2-fab):not(.pro-mic):not(.pro-voice-fab) { background-color: var(--v2-surface2); color: var(--v2-text); border-color: var(--v2-line); }
html[data-theme=dark] body.v2 .sidebar { background: rgba(10, 17, 31, .9) !important; }
html[data-theme=dark] .v2-tabbar { background: rgba(16, 25, 40, .96); }
html[data-theme=dark] .v2-tab[aria-current=page] { color: #B9E082; }
html[data-theme=dark] .currency-heading > b { color: var(--v2-text); }
html[data-theme=dark] img.brand-logo, html[data-theme=dark] .login-box > img { background: #fff; }
html[data-theme=dark] .v2-sheet #pro-late { background: var(--v2-red-soft) !important; color: var(--v2-red) !important; border-color: transparent !important; }
html[data-theme=dark] :is(button.primary, .primary, .login-box button.primary) { background: var(--v2-lime) !important; border-color: var(--v2-lime) !important; color: #0E1F3D !important; }

/* Desktop / tablet: navy side menu to match. */
@media (min-width: 761px) {
  .sidebar { background: var(--v2-navy) !important; border-color: var(--v2-navy) !important; }
  .sidebar .nav.active { background: rgba(141, 198, 63, .16) !important; color: #fff !important; box-shadow: inset -3px 0 0 var(--v2-lime) !important; }
  .topbar { background: var(--v2-surface) !important; border-color: var(--v2-line) !important; }
}
