/* ============================================================
       TPC COMMERCIAL APP — Design System v3
       Palette: deep navy-purple, neon teal + violet accents
    ============================================================ */
    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

    :root {
      --bg:        #0d0a1a;
      --surface:   #161b27;
      --surface-2: #1e2535;
      --surface-3: #252d3f;
      --border:    #2a3347;
      --border-2:  #3a4560;
      --text:      #e8edf5;
      --text-2:    #a8b5cc;
      --muted:     #6b7a96;
      --accent:    #00d4f5;
      --accent-dk: #00a8c5;
      --accent-lt: #00d4f515;
      --green:     #00e5a0;
      --green-lt:  #00e5a012;
      --green-dk:  #00b87f;
      --danger:    #ff4d6a;
      --danger-lt: #ff4d6a14;
      --warn:      #ffaa00;
      --warn-lt:   #ffaa0014;
      --purple:    #b060ff;
      --purple-lt: #b060ff14;
      --shadow-sm: 0 2px 8px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.2);
      --shadow-md: 0 6px 20px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.25);
      --shadow-lg: 0 12px 40px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.3);
      --radius:    10px;
      --radius-lg: 14px;
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      font-family: 'Inter', system-ui, -apple-system, sans-serif;
      background: linear-gradient(135deg, #0d0a1a 0%, #150d2e 40%, #1a1040 70%, #120a2a 100%);
      background-attachment: fixed;
      color: var(--text);
      font-size: 14px;
      line-height: 1.5;
      min-height: 100vh;
    }

    .app { max-width: 1480px; margin: 0 auto; padding: 0 20px 32px; }
    h1, h2, h3, h4 { margin-top: 0; font-weight: 700; color: var(--text); }
    h2 { font-size: 20px; }
    h3 { font-size: 16px; }

    /* ---- Topbar ---- */
    .topbar {
      display: flex; justify-content: space-between; align-items: center;
      gap: 12px; padding: 0 24px; margin: 0 -20px 24px;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      box-shadow: 0 2px 20px rgba(0,0,0,.4);
      flex-wrap: nowrap;
      position: sticky; top: 0; z-index: 40;
      min-height: 56px; height: 56px;
    }
    .topbar h1 {
      font-size: 18px; font-weight: 700; margin: 0;
      color: var(--accent);
      display: flex; align-items: center; gap: 10px;
      letter-spacing: -.02em;
    }
    .topbar h1::before {
      content: '';
      display: inline-block; width: 3px; height: 22px;
      background: linear-gradient(180deg, var(--accent), var(--purple));
      border-radius: 2px;
      box-shadow: 0 0 8px var(--accent);
    }
    .topbar .muted { font-size: 12px; color: var(--muted); }
    .topbar .actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

    /* ---- Cards ---- */
    .card {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius-lg); padding: 20px;
      margin-bottom: 16px; box-shadow: var(--shadow-md);
    }
    .card h3 { margin-bottom: 14px; color: var(--text); font-size: 15px; }

    /* ---- Layout helpers ---- */
    .row { display: flex; gap: 12px; flex-wrap: wrap; }
    .field {
      display: flex; flex-direction: column; gap: 5px;
      min-width: 180px; flex: 1 1 220px;
    }
    label { font-size: 12px; color: var(--text-2); font-weight: 500; }

    /* ---- Inputs ---- */
    input, select, textarea {
      background: var(--surface-2); color: var(--text);
      border: 1.5px solid var(--border); border-radius: 8px;
      padding: 9px 12px; font-size: 14px; font-family: inherit;
      transition: border-color .15s, box-shadow .15s;
    }
    input:focus, select:focus, textarea:focus {
      outline: none; border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(0,212,245,.15);
    }
    input[type="number"] { -moz-appearance: textfield; }
    input[readonly] {
      background: var(--surface-2); color: var(--muted);
      border-color: var(--border); cursor: not-allowed;
    }

    /* ---- Buttons ---- */
    button {
      background: linear-gradient(135deg, var(--accent), var(--accent-dk)); color: #001a22;
      border: none; border-radius: 8px;
      padding: 9px 16px; font-size: 13px; font-weight: 600;
      cursor: pointer; font-family: inherit;
      transition: all .15s;
      white-space: nowrap;
    }
    button:hover { filter: brightness(1.12); box-shadow: 0 0 14px rgba(0,212,245,.35); }
    button:active { transform: translateY(1px); }
    button.secondary {
      background: var(--surface-2); color: var(--text-2);
      border: 1.5px solid var(--border);
    }
    button.secondary:hover { background: var(--surface-3); border-color: var(--accent); color: var(--accent); box-shadow: 0 0 8px rgba(0,212,245,.15); }
    button.danger { background: var(--danger); color: #fff; }
    button.danger:hover { filter: brightness(1.15); box-shadow: 0 0 12px rgba(255,77,106,.4); }
    button.warn { background: var(--warn); color: #001a22; }
    button.warn:hover { filter: brightness(1.15); box-shadow: 0 0 12px rgba(255,170,0,.4); }
    button.accent { background: linear-gradient(135deg, var(--green), var(--green-dk)); color: #001a22; }
    button.accent:hover { filter: brightness(1.12); box-shadow: 0 0 14px rgba(0,229,160,.35); }
    button.small { padding: 6px 11px; font-size: 12px; border-radius: 6px; }

    /* Button group — visually joined set of related actions */
    .btn-group {
      display: inline-flex; gap: 0; border-radius: 8px;
      overflow: hidden; box-shadow: var(--shadow-sm);
    }
    .btn-group button { border-radius: 0; border-right: 1px solid rgba(0,0,0,.25); box-shadow: none; }
    .btn-group button:first-child { border-radius: 8px 0 0 8px; }
    .btn-group button:last-child  { border-radius: 0 8px 8px 0; border-right: none; }
    .btn-group button.secondary { border-right: 1px solid var(--border); }

    /* Actions bar on page headers */
    .actions {
      display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    }
    .actions-divider {
      width: 1px; height: 28px; background: var(--border);
      align-self: center; flex-shrink: 0;
    }

    /* ---- Breadcrumb ---- */
    .breadcrumb {
      font-size: 12px; color: var(--muted); margin-bottom: 16px;
      display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
    }
    .breadcrumb a {
      color: var(--accent); cursor: pointer; text-decoration: none;
      font-weight: 500; transition: text-shadow .15s;
    }
    .breadcrumb a:hover { text-shadow: 0 0 8px rgba(0,212,245,.5); }
    .breadcrumb a:hover { text-decoration: underline; }
    .breadcrumb::after { display: none; } /* remove old slash */

    /* ---- Project tiles ---- */
    .project-list {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
      gap: 16px;
    }
    .project-tile {
      background: var(--surface); border: 1.5px solid var(--border);
      border-radius: var(--radius-lg); padding: 18px; cursor: pointer;
      transition: border-color .15s, box-shadow .15s, transform .15s;
      box-shadow: var(--shadow-sm);
    }
    .project-tile:hover {
      border-color: var(--accent); box-shadow: 0 0 20px rgba(0,212,245,.15), var(--shadow-md);
      transform: translateY(-2px);
    }
    .project-tile h3 {
      margin: 0 0 6px; font-size: 15px; color: var(--text);
    }

    /* ---- Typography helpers ---- */
    .muted { color: var(--muted); font-size: 13px; }
    .small { font-size: 12px; color: var(--muted); }

    /* ---- Pills / badges ---- */
    .pill {
      display: inline-block; padding: 2px 9px; border-radius: 999px;
      background: var(--surface-3); border: 1px solid var(--border);
      font-size: 11px; color: var(--text-2); font-weight: 500;
    }
    .pill.green { background: rgba(0,229,160,.12); color: var(--green); border-color: rgba(0,229,160,.3); }
    .pill.blue  { background: var(--accent-lt); color: var(--accent); border-color: rgba(0,212,245,.3); }

    /* ---- Navigation pills (item type selector) ---- */
    .items-nav {
      display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px;
    }
    .items-nav button {
      background: var(--surface-2); color: var(--text-2);
      border: 1.5px solid var(--border); padding: 7px 13px; font-size: 12px;
      font-weight: 500;
    }
    .items-nav button:hover { background: var(--accent-lt); border-color: var(--accent); color: var(--accent); }
    .items-nav button.active {
      background: var(--accent); color: #fff; border-color: var(--accent);
    }
    .items-nav button.muted-btn { opacity: .6; }

    /* ---- Summary stats grid ---- */
    .summary-grid {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
      gap: 12px; margin-bottom: 16px;
    }
    .stat {
      background: var(--surface-2); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 14px 16px;
      box-shadow: var(--shadow-sm);
      transition: border-color .15s;
    }
    .stat:hover { border-color: var(--accent); }
    .stat .label {
      font-size: 11px; color: var(--muted); text-transform: uppercase;
      letter-spacing: .05em; font-weight: 600;
    }
    .stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; color: var(--text); }
    .stat .value.green { color: var(--green); }
    .stat .value.blue  { color: var(--accent); }

    /* ---- Tables ---- */
    .table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow-md); }
    table { width: 100%; border-collapse: collapse; font-size: 13px; }
    th, td {
      border-bottom: 1px solid var(--border);
      padding: 8px 12px; text-align: left; vertical-align: middle;
      white-space: nowrap;
    }
    th {
      background: var(--surface-3); font-size: 11px; font-weight: 700;
      text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
      position: sticky; top: 0; border-bottom: 1px solid var(--border-2);
    }
    tr:last-child td { border-bottom: none; }
    tbody tr:hover { background: var(--surface-2); }
    tbody tr:nth-child(even) { background: rgba(255,255,255,.02); }
    tbody tr:nth-child(even):hover { background: var(--surface-2); }
    .num { text-align: right; font-variant-numeric: tabular-nums; }
    .totals-row td { font-weight: 700; background: var(--accent-lt) !important; color: var(--accent); }

    /* ---- Modals ---- */
    .modal-backdrop {
      position: fixed; inset: 0; background: rgba(5,8,18,.7);
      backdrop-filter: blur(4px);
      display: flex; align-items: center; justify-content: center;
      z-index: 50;
    }
    .modal {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius-lg); padding: 24px;
      max-width: 620px; width: 94%;
      max-height: 90vh; overflow-y: auto;
      box-shadow: var(--shadow-lg);
    }
    .modal h2 { margin-bottom: 16px; font-size: 18px; }
    .modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

    /* ---- Auth overlay ---- */
    .auth-overlay {
      position: fixed; inset: 0;
      background: linear-gradient(135deg, #080d17 0%, #130d2a 50%, #0a1525 100%);
      display: flex; align-items: center; justify-content: center;
      z-index: 100; padding: 20px;
    }
    .auth-card {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius-lg); padding: 32px; max-width: 380px; width: 100%;
      box-shadow: var(--shadow-lg);
    }
    .auth-card h1 {
      margin: 0 0 4px; font-size: 24px;
      background: linear-gradient(90deg, var(--accent), var(--green));
      -webkit-background-clip: text; background-clip: text; color: transparent;
    }
    .auth-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
    .auth-card .field { margin-bottom: 14px; }
    .auth-card .field > input { width: 100%; padding: 11px 13px; font-size: 14px; }
    .auth-card .auth-error {
      background: var(--danger-lt); color: var(--danger); border: 1px solid rgba(255,77,106,.3);
      padding: 9px 13px; border-radius: 8px; font-size: 13px;
      margin-bottom: 14px; display: none;
    }
    .auth-card .auth-error.show { display: block; }
    .auth-card button { width: 100%; padding: 12px; font-size: 15px; }
    .auth-card .footer { margin-top: 16px; font-size: 11px; color: var(--muted); text-align: center; }

    /* ---- Session badge (topbar) ---- */
    .session-badge {
      display: inline-flex; align-items: center; gap: 6px;
      background: var(--surface-2); border: 1px solid var(--border);
      border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 500;
    }
    .session-badge .dot {
      width: 7px; height: 7px; border-radius: 50%; background: var(--green);
      box-shadow: 0 0 6px var(--green);
    }

    /* ---- User management rows ---- */
    .user-row {
      display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 10px;
      align-items: center; padding: 10px 14px;
      background: var(--surface-2); border: 1px solid var(--border);
      border-radius: var(--radius); margin-bottom: 8px;
    }
    .user-row .name { font-weight: 600; font-size: 14px; }
    .user-row .name .badge {
      display: inline-block; background: rgba(0,229,160,.15); color: var(--green);
      border-radius: 4px; padding: 1px 7px; font-size: 10px; margin-left: 6px; font-weight: 700;
    }
    .user-row .pw-cell { font-size: 13px; color: var(--muted); }
    .user-row .actions-cell { display: flex; gap: 6px; }

    /* ---- Tab inputs ---- */
    .tab-input { width: 80px; }
    .tab-input.wide { width: 110px; }
    .tab-input.narrow { width: 60px; }
    .tab-input.text { width: 130px; }

    /* ---- Big nav buttons (project summary) ---- */
    .big-nav {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px;
    }
    .big-nav-btn {
      background: var(--surface-2); color: var(--text);
      border: 1.5px solid var(--border); border-radius: var(--radius-lg);
      padding: 22px 20px; text-align: left;
      display: flex; flex-direction: column; gap: 6px;
      cursor: pointer; font-weight: 700; font-family: inherit;
      transition: transform .12s, border-color .12s, box-shadow .12s;
      box-shadow: var(--shadow-sm);
    }
    .big-nav-btn:hover {
      transform: translateY(-2px); border-color: var(--accent);
      box-shadow: 0 0 20px rgba(0,212,245,.15), var(--shadow-md);
    }
    .big-nav-btn.accent { background: var(--green-lt); border-color: rgba(0,229,160,.3); color: var(--green); }
    .big-nav-btn.accent:hover { border-color: var(--green); }
    .big-nav-btn.warn   { background: var(--warn-lt); border-color: rgba(255,170,0,.3); color: var(--warn); }
    .big-nav-btn.warn:hover { border-color: var(--warn); }
    .big-nav-title { font-size: 18px; }
    .big-nav-sub   { font-size: 12px; opacity: .7; font-weight: 400; }

    /* ---- Item cards ---- */
    .items-list { display: flex; flex-direction: column; gap: 10px; }
    .item-card {
      background: var(--surface); border: 1.5px solid var(--border);
      border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
    }
    .item-card.has-warning { border-color: var(--warn); }
    .item-card.has-warning .item-card-head { border-left: 4px solid var(--warn); }
    .item-card-head {
      display: flex; justify-content: space-between; align-items: center;
      gap: 12px; padding: 10px 16px;
      background: var(--surface-3); border-bottom: 1px solid var(--border);
    }
    .item-card-head .title { font-weight: 600; font-size: 13px; display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
    .item-card-head .title .num-badge {
      display: inline-block; background: var(--accent); color: #fff;
      border-radius: 5px; padding: 1px 8px; margin-right: 4px; font-size: 11px; font-weight: 700;
    }
    .item-card-head .price { font-weight: 700; color: var(--green); font-size: 15px; }
    .item-card-body { padding: 14px 16px; }
    .field-grid {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
      gap: 10px 14px; margin-bottom: 12px;
    }
    .field-grid .field { min-width: 0; gap: 4px; flex: initial; }
    .field-grid .field label {
      font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
    }
    .field-grid .field input, .field-grid .field select {
      width: 100%; padding: 7px 10px; font-size: 13px;
    }
    .checkbox-field {
      display: flex; align-items: center; gap: 8px;
      background: var(--surface-2); border: 1px solid var(--border);
      border-radius: 8px; padding: 7px 11px; font-size: 13px;
    }
    .checkbox-field input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }

    /* Warn badges on items */
    .warn-badge {
      display: inline-block; background: rgba(255,170,0,.12); color: var(--warn);
      border: 1px solid rgba(255,170,0,.35); border-radius: 4px;
      padding: 1px 6px; font-size: 11px; font-weight: 600; margin-left: 4px;
    }

    /* Multi-select checkbox */
    .item-select-cb { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); margin-right: 4px; }

    /* ---- Totals strip on item cards ---- */
    .totals-strip {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
      gap: 8px; background: var(--surface-2); border: 1px solid var(--border);
      border-radius: 8px; padding: 10px 14px; margin-bottom: 10px;
    }
    .totals-strip .tcell { display: flex; flex-direction: column; gap: 2px; }
    .totals-strip .tcell .label {
      font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
    }
    .totals-strip .tcell .value {
      font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text);
    }
    .totals-strip .tcell .value.blue  { color: var(--accent); }
    .totals-strip .tcell .value.green { color: var(--green); }

    /* ---- Grand totals bar ---- */
    .grand-totals {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
      gap: 8px; background: var(--green-lt); border: 1px solid rgba(0,229,160,.25);
      border-radius: 8px; padding: 12px 16px; margin-top: 12px;
    }
    .grand-totals .tcell .label { color: var(--green-dk); font-size: 10px; text-transform: uppercase; letter-spacing:.04em; font-weight:600; }
    .grand-totals .tcell .value { color: var(--green); font-size: 14px; font-weight: 700; }

    /* ---- Cost group accordions ---- */
    details.cost-group {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 8px; margin-bottom: 6px; overflow: hidden;
    }
    details.cost-group > summary {
      list-style: none; cursor: pointer; padding: 9px 14px;
      display: flex; justify-content: space-between; align-items: center;
      background: var(--surface-3); user-select: none;
      font-weight: 600; font-size: 13px;
    }
    details.cost-group > summary::-webkit-details-marker { display: none; }
    details.cost-group > summary:hover { background: var(--surface-2); }
    details.cost-group > summary .chev {
      display: inline-block; width: 14px; text-align: center;
      transition: transform .15s; color: var(--muted);
    }
    details.cost-group[open] > summary .chev { transform: rotate(90deg); }
    details.cost-group > summary .total { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; }
    .cost-grid {
      padding: 10px 14px;
      display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px;
    }
    .cost-grid .ccell {
      display: flex; justify-content: space-between; align-items: center;
      padding: 6px 10px; background: var(--surface-3); border: 1px solid var(--border);
      border-radius: 6px; font-size: 12px;
    }
    .cost-grid .ccell .label { color: var(--muted); }
    .cost-grid .ccell .value { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }

    /* ---- Empty state ---- */
    .item-empty {
      padding: 32px; text-align: center; color: var(--muted);
      background: var(--surface-2); border: 1.5px dashed var(--border-2);
      border-radius: var(--radius);
    }

    /* ---- Master pricing ---- */
    .master-group { margin-bottom: 12px; }
    .master-group-head {
      display: flex; justify-content: space-between; align-items: center;
      padding: 10px 16px; background: var(--surface-3); border: 1px solid var(--border);
      border-bottom: none; border-radius: 8px 8px 0 0;
      cursor: pointer; user-select: none;
    }
    .master-group-head h3 { margin: 0; font-size: 14px; color: var(--accent-dk); }
    .master-group-head .chev { transition: transform .15s; color: var(--muted); }
    .master-group.collapsed .chev { transform: rotate(-90deg); }
    .master-group.collapsed .master-rows { display: none; }
    .master-rows {
      background: var(--surface); border: 1px solid var(--border);
      border-top: none; border-radius: 0 0 8px 8px; overflow: hidden;
    }
    .master-row {
      display: grid;
      grid-template-columns: minmax(160px,1.6fr) minmax(110px,1fr) minmax(110px,.9fr);
      gap: 10px; align-items: center; padding: 8px 16px;
      border-bottom: 1px solid var(--border);
    }
    .master-row:last-child { border-bottom: none; }
    .master-row:hover { background: var(--surface-2); }
    .master-row .label-cell input { width: 100%; padding: 7px 9px; font-size: 13px; }
    .master-row .rate-cell-input { display: flex; align-items: center; gap: 6px; }
    .master-row .rate-cell-input span { color: var(--muted); font-size: 13px; }
    .master-row .rate-cell-input input { flex: 1; padding: 7px 9px; font-size: 13px; text-align: right; }
    .master-row .unit-cell select { width: 100%; padding: 7px 9px; font-size: 13px; }
    .master-row-header {
      display: grid;
      grid-template-columns: minmax(160px,1.6fr) minmax(110px,1fr) minmax(110px,.9fr);
      gap: 10px; padding: 7px 16px;
      background: var(--bg); border-bottom: 1px solid var(--border);
      font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
    }
    @media (max-width: 720px) {
      .master-row, .master-row-header { grid-template-columns: 1fr; gap: 4px; }
      .master-row-header { display: none; }
      .master-row .rate-cell-input input { text-align: left; }
    }

    /* ---- Type picker (new project) ---- */
    .type-picker {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
      gap: 10px; margin-top: 12px;
    }
    .type-tile {
      background: var(--surface-2); border: 1.5px solid var(--border);
      border-radius: var(--radius); padding: 16px; text-align: center;
      cursor: pointer; transition: all .15s; font-weight: 600;
    }
    .type-tile:hover { border-color: var(--accent); background: var(--accent-lt); box-shadow: 0 0 12px rgba(0,212,245,.15); }
    .type-tile.active { border-color: var(--green); background: var(--green-lt); color: var(--green); box-shadow: 0 0 12px rgba(0,229,160,.2); }

    /* ---- Sort/filter bar ---- */
    .sort-filter-bar {
      display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: flex-end;
    }
    .sort-filter-bar .field { flex: 0 1 180px; }
    .sort-filter-bar .field label { font-size: 11px; }
    .sort-filter-bar .field input, .sort-filter-bar .field select {
      width: 100%; padding: 7px 10px; font-size: 13px;
    }

    /* ---- Bulk edit bar ---- */
    .bulk-bar {
      display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
      background: rgba(255,170,0,.08); border: 1.5px solid rgba(255,170,0,.3);
      border-radius: 8px; padding: 10px 14px; margin-bottom: 12px;
    }
    .bulk-bar .field { flex: 0 1 180px; }
    .bulk-bar .field label { font-size: 11px; }
    .bulk-bar .field input, .bulk-bar .field select { width: 100%; padding: 6px 8px; font-size: 13px; }

    /* ---- Snapshots ---- */
    .snapshot-row {
      display: flex; justify-content: space-between; align-items: center;
      padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--border);
      border-radius: 8px; margin-bottom: 6px; font-size: 13px;
    }
    .snapshot-row .snap-title { font-weight: 600; }
    .snapshot-row .snap-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
    .snapshot-row .snap-val { font-variant-numeric: tabular-nums; color: var(--green); font-weight: 700; }

    /* ---- Gantt ---- */
    .gantt-wrap { overflow-x: auto; margin-top: 12px; }
    .gantt-table { border-collapse: collapse; font-size: 12px; width: 100%; }
    .gantt-table th, .gantt-table td { border: 1px solid var(--border); padding: 5px 10px; white-space: nowrap; }
    .gantt-table th { background: var(--surface-3); }
    .gantt-bar-cell { min-width: 500px; position: relative; }
    .gantt-bar-bg { position: relative; height: 22px; width: 100%; }
    .gantt-bar {
      position: absolute; height: 100%; border-radius: 4px;
      display: flex; align-items: center; padding: 0 8px;
      font-size: 11px; font-weight: 500; white-space: nowrap;
      overflow: hidden; text-overflow: ellipsis; cursor: default;
    }
    .gantt-bar.prod    { background: rgba(0,212,245,.18); color: var(--accent); border: 1px solid rgba(0,212,245,.5); }
    .gantt-bar.install { background: rgba(0,229,160,.15); color: var(--green);  border: 1px solid rgba(0,229,160,.45); }

    /* ---- Commercial table ---- */
    #commercialTable input {
      width: 100%; min-width: 90px; padding: 6px 8px; font-size: 12px;
      background: var(--surface-2);
    }
    #commercialTable input[disabled] {
      background: var(--surface-2); color: var(--text-2); font-weight: 600; cursor: not-allowed;
    }
    #commercialTable input[disabled].autofilled { background: rgba(0,212,245,.1); color: var(--accent); }
    #commercialTable td { padding: 5px 8px; }
    #commercialTable th { font-size: 11px; }
    #commercialTable tbody tr:nth-child(even) input[disabled] { background: rgba(0,212,245,.07); }

    /* ---- Session timeout toast ---- */
    .timeout-toast {
      position: fixed; bottom: 24px; right: 24px;
      background: var(--warn); color: #fff;
      border-radius: 10px; padding: 14px 18px;
      font-weight: 700; font-size: 14px;
      box-shadow: var(--shadow-lg); z-index: 200;
      display: flex; gap: 12px; align-items: center;
    }
    .timeout-toast button {
      background: rgba(255,255,255,.25); color: #fff; border: none;
      border-radius: 6px; padding: 6px 12px; cursor: pointer; font-weight: 700;
    }

    /* ---- Warning badge ---- */
    .item-card.has-warning { border-color: var(--warn); }

    /* ---- Order Book KPIs ---- */
    .ob-kpi-banner {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
      gap: 12px; margin-bottom: 16px;
    }
    .ob-kpi {
      background: var(--surface); border: 1px solid var(--border);
      border-radius: var(--radius-lg); padding: 16px 18px;
      position: relative; overflow: hidden;
      transition: transform .15s, box-shadow .15s;
      box-shadow: var(--shadow-sm);
    }
    .ob-kpi:hover { transform: translateY(-2px); box-shadow: 0 0 20px rgba(0,212,245,.1), var(--shadow-md); }
    .ob-kpi::before {
      content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
      background: var(--kpi-accent, var(--accent));
    }
    .ob-kpi .kpi-label {
      font-size: 11px; color: var(--muted); text-transform: uppercase;
      letter-spacing: .06em; margin-bottom: 6px; font-weight: 600;
    }
    .ob-kpi .kpi-value {
      font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text);
    }
    .ob-kpi .kpi-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
    .ob-kpi .kpi-bar {
      height: 4px; background: var(--border); border-radius: 2px; margin-top: 10px;
    }
    .ob-kpi .kpi-bar-fill {
      height: 100%; border-radius: 2px;
      background: var(--kpi-accent, var(--accent));
      transition: width .8s cubic-bezier(.4,0,.2,1);
    }

    .ob-charts-row {
      display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
      gap: 16px; margin-bottom: 16px;
    }
    .ob-chart-card { padding: 0; }
    .ob-chart-title { margin: 0 0 12px; font-size: 14px; color: var(--accent); font-weight: 600; }

    .ob-forecast-row {
      display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px;
    }
    .ob-forecast-card { padding: 20px; }
    @media (max-width: 900px) { .ob-forecast-row { grid-template-columns: 1fr; } }

    /* ---- Production forecast table ---- */
    #prodForecastTable { min-width: 100%; }
    #prodForecastTable th, #prodForecastTable td { white-space: nowrap; }
    .prod-week-input {
      width: 62px; text-align: right; padding: 4px 6px; font-size: 13px;
      font-variant-numeric: tabular-nums;
    }
    .prod-week-input.manual { background: rgba(0,212,245,.12); color: var(--accent); border-color: var(--accent); }
    .prod-week-input.past   { background: rgba(0,229,160,.1); color: var(--green); border-color: rgba(0,229,160,.4); }
    .prod-week-total-ok   { color: var(--green); font-weight:700; }
    .prod-week-total-warn { color: var(--warn);  font-weight:700; }

    /* ---- Forecast drill-down ---- */
    .fd-project-row {
      display: grid; grid-template-columns: 200px 1fr 160px;
      align-items: center; gap: 14px; padding: 12px 0;
      border-bottom: 1px solid var(--border);
    }
    .fd-project-row:last-child { border-bottom: none; }
    .fd-project-name { font-size: 13px; font-weight: 600; color: var(--text); }
    .fd-project-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
    .fd-bar-track { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
    .fd-bar-fill { height: 100%; border-radius: 5px; background: var(--accent); transition: width .8s ease; }
    .fd-bar-fill.behind { background: var(--danger); box-shadow: 0 0 6px rgba(255,77,106,.4); }
    .fd-bar-fill.ahead  { background: var(--green); box-shadow: 0 0 6px rgba(0,229,160,.4); }
    .fd-stat { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }

    /* ---- Ob progress bars ---- */
    .ob-progress-wrap { margin-top: 8px; }
    .ob-progress-row {
      display: flex; justify-content: space-between; align-items: center;
      margin-bottom: 8px; font-size: 13px;
    }
    .ob-progress-label { color: var(--muted); flex: 1; }
    .ob-progress-bar {
      flex: 2; height: 6px; background: var(--border); border-radius: 3px;
      margin: 0 10px; overflow: hidden;
    }
    .ob-progress-bar-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width .8s ease; }
    .ob-progress-val { font-variant-numeric: tabular-nums; min-width: 60px; text-align: right; }

    /* ---- Password input wrapper ---- */
    /* ── Password row: input + toggle button side by side ── */
    .pw-row {
      display: flex !important;
      flex-direction: row !important;
      align-items: center !important;
      gap: 8px !important;
      width: 100% !important;
    }
    .pw-row input {
      flex: 1 1 auto !important;
      width: 0 !important;
      min-width: 0 !important;
      max-width: none !important;
      padding: 9px 12px !important;
    }
    .pw-toggle {
      flex: 0 0 36px !important;
      width: 36px !important;
      height: 36px !important;
      min-width: 36px !important;
      max-width: 36px !important;
      background: var(--surface-2);
      color: var(--muted);
      border: 1.5px solid var(--border);
      border-radius: 8px;
      cursor: pointer;
      font-size: 14px;
      display: flex; align-items: center; justify-content: center;
      transition: color .15s, border-color .15s;
      padding: 0;
    }
    .pw-toggle:hover  { color: var(--accent); border-color: var(--accent); background: var(--surface-2); box-shadow: none; filter: none; transform: none; }
    .pw-toggle:active { transform: none; }


    /* ---- Right-click context menu on project tile ---- */
    .ctx-menu {
      position: fixed; z-index: 500;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 10px; box-shadow: var(--shadow-lg);
      padding: 6px; min-width: 180px; animation: ctxFadeIn .12s ease;
    }
    @keyframes ctxFadeIn { from{opacity:0;transform:scale(.96)} to{opacity:1;transform:scale(1)} }
    .ctx-menu button {
      display: flex; align-items: center; gap: 10px; width: 100%;
      background: none; border: none; border-radius: 7px;
      padding: 8px 12px; font-size: 13px; color: var(--text);
      text-align: left; cursor: pointer; font-weight: 500;
    }
    .ctx-menu button:hover { background: var(--surface-2); color: var(--accent); box-shadow: none; filter: none; transform: none; }
    .ctx-menu button.danger-item:hover { color: var(--danger); }
    .ctx-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
    .tile-modified { font-size: 11px; color: var(--muted); margin-top: 4px; }
    .tile-modified.recent { color: var(--green); }
    .tile-alert { display: inline-flex; align-items: center; gap: 4px;
      background: rgba(255,170,0,.15); border: 1px solid rgba(255,170,0,.4);
      color: var(--warn); border-radius: 6px; padding: 2px 8px;
      font-size: 11px; font-weight: 600; margin-top: 6px; }

    /* ---- Global search ---- */
    .global-search-wrap { position: relative; flex: 0 1 280px; }
    .global-search-wrap input { width: 100%; padding: 8px 36px 8px 14px;
      background: var(--surface-2); border: 1.5px solid var(--border);
      border-radius: 8px; color: var(--text); font-size: 13px; }
    .global-search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,212,245,.12); }
    .global-search-wrap .search-icon {
      position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
      color: var(--muted); pointer-events: none; font-size: 14px; }
    #globalSearchResults {
      position: absolute; top: calc(100% + 6px); left: 0; right: 0;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 10px; box-shadow: var(--shadow-lg);
      z-index: 200; max-height: 360px; overflow-y: auto; padding: 4px; }
    .search-result { padding: 9px 12px; border-radius: 7px; cursor: pointer;
      font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
    .search-result:hover { background: var(--surface-2); }
    .search-result .sr-title { font-weight: 600; color: var(--text); }
    .search-result .sr-sub   { font-size: 11px; color: var(--muted); }
    .search-result .sr-match { color: var(--accent); font-weight: 600; }

    /* ---- Variation log ---- */
    .variation-row {
      display: grid; grid-template-columns: 1fr 110px 110px 90px auto;
      gap: 8px; align-items: center; padding: 8px 10px;
      background: var(--surface-2); border: 1px solid var(--border);
      border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
    .variation-row.v-pending  { border-color: rgba(255,170,0,.4); }
    .variation-row.v-approved { border-color: rgba(0,229,160,.3); }
    .variation-status { display: inline-block; padding: 2px 8px; border-radius: 999px;
      font-size: 11px; font-weight: 600; }
    .variation-status.pending  { background: rgba(255,170,0,.15); color: var(--warn); }
    .variation-status.approved { background: rgba(0,229,160,.12); color: var(--green); }
    .variation-status.rejected { background: rgba(255,77,106,.12); color: var(--danger); }

    /* ---- Unsaved changes indicator ---- */
    #unsavedDot {
      width: 8px; height: 8px; border-radius: 50%;
      background: var(--warn); display: none;
      box-shadow: 0 0 6px var(--warn);
    }

    /* ---- Theme toggle ---- */
    .theme-toggle {
      background: var(--surface-2); border: 1.5px solid var(--border);
      border-radius: 999px; padding: 5px 10px;
      font-size: 14px; cursor: pointer; color: var(--text);
    }
    .theme-toggle:hover { border-color: var(--accent); background: var(--surface-2); box-shadow: none; filter: none; transform: none; }

    /* ---- Light mode ---- */
    body.light-mode {
      --bg: #f0f2f5; --surface: #ffffff; --surface-2: #f8f9fb;
      --surface-3: #eef0f4; --border: #dde1e9; --border-2: #c8cdd8;
      --text: #1a2030; --text-2: #4a5568; --muted: #8492a6;
      --accent: #0882a0; --accent-dk: #066480; --accent-lt: #e0f5fb;
      --green: #16a34a; --green-lt: #dcfce7; --green-dk: #14532d;
      --danger: #dc2626; --danger-lt: #fee2e2;
      --warn: #d97706; --warn-lt: #fef3c7;
      --shadow-sm: 0 1px 3px rgba(0,0,0,.06); --shadow-md: 0 4px 12px rgba(0,0,0,.08);
      --shadow-lg: 0 10px 30px rgba(0,0,0,.10);
      background: linear-gradient(135deg,#eef2f7 0%,#e8ecf4 100%) fixed;
    }
    body.light-mode .topbar { background: #fff; }
    body.light-mode .auth-overlay { background: linear-gradient(135deg,#dde4f0 0%,#c8d3e8 100%); }
    body.light-mode table th { color: #4a5568; }
    body.light-mode tbody tr:hover { background: #f0f4f8; }
    body.light-mode .ctx-menu { background:#fff; }


    /* ── F1: Status badge on project tile ── */
    .status-badge {
      display: inline-block; padding: 3px 10px; border-radius: 999px;
      font-size: 11px; font-weight: 700; letter-spacing:.04em;
    }
    .status-tendering  { background:rgba(56,189,248,.15); color:#38bdf8; border:1px solid rgba(56,189,248,.3); }
    .status-awarded    { background:rgba(0,229,160,.12);  color:var(--green); border:1px solid rgba(0,229,160,.3); }
    .status-on-hold    { background:rgba(255,170,0,.12);  color:var(--warn);  border:1px solid rgba(255,170,0,.3); }
    .status-complete   { background:rgba(148,163,184,.12);color:var(--muted); border:1px solid rgba(148,163,184,.3);}
    .status-lost       { background:rgba(255,77,106,.12); color:var(--danger);border:1px solid rgba(255,77,106,.3); }
    .status-filter-bar { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; align-items:center; }
    .status-filter-btn {
      padding:5px 14px; border-radius:999px; font-size:12px; font-weight:600;
      background:var(--surface-2); border:1.5px solid var(--border); color:var(--text-2); cursor:pointer;
    }
    .status-filter-btn.active { background:var(--accent); color:#001a22; border-color:var(--accent); }

    /* ── F2: Budget vs actual ── */
    .budget-row {
      display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr));
      gap:10px; margin-top:10px;
    }
    .budget-cell {
      background:var(--surface-2); border:1px solid var(--border);
      border-radius:8px; padding:10px 14px;
    }
    .budget-cell.over  { border-color:rgba(255,77,106,.5); background:rgba(255,77,106,.06); }
    .budget-cell.under { border-color:rgba(0,229,160,.4);  background:rgba(0,229,160,.05); }
    .budget-label { font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; font-weight:600; }
    .budget-value { font-size:16px; font-weight:700; margin-top:3px; font-variant-numeric:tabular-nums; }

    /* ── F4: Cash flow chart card ── */
    .cashflow-card { padding:20px; }

    /* ── F8: Actual production inputs ── */
    .prod-week-input.actual { background:rgba(176,96,255,.12); color:var(--purple); border-color:rgba(176,96,255,.4); }

    /* ---- Delete row button ---- */
    .delete-row {
      background: none; color: var(--muted); border: none;
      padding: 4px 6px; cursor: pointer; font-size: 14px; border-radius: 6px;
      transition: background .12s, color .12s;
    }
    .delete-row:hover { background: rgba(255,77,106,.12); color: var(--danger); box-shadow: none; }

    /* ---- Expandable KPI — removed placeholder ---- */
    /* ---- Misc ---- */
    .hidden { display: none !important; }

    /* ---- Print ---- */
    @media print {
      :root { --bg:#fff;--surface:#fff;--surface-2:#f8f8f8;--surface-3:#f0f0f0;--border:#ddd;--text:#000;--text-2:#333;--muted:#666; }
      body { background: white !important; color: black !important; }
      .topbar, .breadcrumb, .actions, button, select,
      #page-home, #page-summary, #page-project, #page-tracker,
      #page-commercial, #page-master { display: none !important; }
      #page-orderbook { display: block !important; }
      .ob-kpi { background: #f8fafc !important; border: 1px solid #e2e8f0 !important; break-inside: avoid; }
      .card { background: white !important; border: 1px solid #e2e8f0 !important; break-inside: avoid; }
      th, td { border-color: #e2e8f0 !important; }
      .ob-kpi-banner { grid-template-columns: repeat(3,1fr); }
      .ob-charts-row, .ob-forecast-row { grid-template-columns: 1fr 1fr; }
      h3 { color: black !important; }
    }
