/* TrinetraQ Project Control — theme derived from the TrinetraQ logo
   Navy/black base, brand blue / orange / green accents, brushed-steel neutrals */
:root {
  --navy-950: #070b14;
  --navy-900: #0b1220;
  --navy-800: #111b2e;
  --navy-700: #1a2740;
  --steel-300: #c9ced6;
  --steel-400: #a4abb6;
  --blue: #1e6fe0;
  --blue-600: #1759b8;
  --blue-50: #eaf2fd;
  --orange: #f07f1a;
  --orange-50: #fef1e5;
  --green: #5fa832;
  --green-50: #eaf6e2;
  --red: #d33b3b;
  --red-50: #fdecec;
  --amber: #c98a06;
  --amber-50: #fdf5e1;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #16202f;
  --muted: #5d6878;
  --line: #e1e5ec;
  --line-2: #eef1f5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.ic { flex-shrink: 0; vertical-align: -3px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }
.pre { white-space: pre-line; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
  color: var(--steel-300); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40;
  border-right: 1px solid #0e1626;
}
.brand { padding: 18px 18px 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand img { width: 54px; height: auto; }
.brand .name { font-weight: 700; letter-spacing: .08em; color: #e8ebf0; font-size: 15px; }
.brand .name span { color: var(--blue); }
.brand .sub { font-size: 10.5px; letter-spacing: .14em; color: var(--steel-400); text-transform: uppercase; }
.brand-bar { display: flex; height: 3px; }
.brand-bar i { flex: 1; } .brand-bar i:nth-child(1) { background: var(--blue); } .brand-bar i:nth-child(2) { background: var(--orange); } .brand-bar i:nth-child(3) { background: var(--green); }
.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: #6c7788; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: #c3c9d3; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(30,111,224,.16); color: #fff; box-shadow: inset 3px 0 0 var(--blue); }
.nav a .badge { margin-left: auto; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.06); font-size: 11px; color: #6c7788; }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 30; }
.topbar .crumb { font-weight: 600; font-size: 15px; }
.topbar .spacer { flex: 1; }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 8px; color: var(--muted); border: 1px solid transparent; background: none; cursor: pointer; }
.icon-btn:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.icon-btn .dot { position: absolute; top: 5px; right: 5px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--orange); color: #fff; font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.userchip { display: flex; align-items: center; gap: 10px; padding-left: 12px; border-left: 1px solid var(--line); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy-800); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; border: 2px solid var(--blue); }
.userchip .n { font-weight: 600; font-size: 13px; line-height: 1.2; }
.userchip .r { font-size: 11.5px; color: var(--muted); }
.menu-toggle { display: none; }
.content { padding: 24px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards / grid ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.mt { margin-top: 18px; }

.stat { padding: 16px 18px; position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--muted); }
.stat::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--blue); }
.stat.orange::before { background: var(--orange); } .stat.green::before { background: var(--green); } .stat.red::before { background: var(--red); } .stat.steel::before { background: var(--steel-400); }
.stat a { color: inherit; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #f8f9fb; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.t tbody tr:hover td { background: #fafbfd; }
table.t tr:last-child td { border-bottom: 0; }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tfoot td { font-weight: 700; background: #f8f9fb; border-top: 1px solid var(--line); }
table.t td.title a { font-weight: 600; color: var(--text); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* Comparative */
table.cmp th, table.cmp td { border: 1px solid var(--line); }
table.cmp th { text-align: center; }
table.cmp th.vendor { background: var(--navy-800); color: #fff; text-transform: none; font-size: 12.5px; letter-spacing: 0; }
table.cmp th.vendor.l1 { background: var(--green); }
table.cmp td.lowest { background: var(--green-50); font-weight: 600; }
table.cmp td.over { color: var(--red); font-weight: 600; }
table.cmp td.nq { color: var(--muted); font-style: italic; text-align: center; }
table.cmp tr.sum td { background: #f8f9fb; font-weight: 600; }
table.cmp tr.grand td { background: var(--navy-900); color: #fff; font-weight: 700; }
table.cmp tr.grand td.selected { background: var(--blue); }
table.cmp col.sel, table.cmp td.sel { background: rgba(30,111,224,.06); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.st-grey { background: #eef0f4; color: #4a5566; }
.st-blue { background: var(--blue-50); color: var(--blue-600); }
.st-green { background: var(--green-50); color: #3f7a1c; }
.st-orange { background: var(--orange-50); color: #b85c07; }
.st-amber { background: var(--amber-50); color: #946400; }
.st-red { background: var(--red-50); color: #b02525; }
.badge.solid { background: var(--orange); color: #fff; }
.pill-rank { font-weight: 700; padding: 1px 7px; border-radius: 5px; font-size: 11px; background: var(--steel-300); color: var(--navy-900); }
.pill-rank.L1 { background: var(--green); color: #fff; }

.progress { height: 6px; background: #e8ebf0; border-radius: 4px; overflow: hidden; min-width: 70px; }
.progress > i { display: block; height: 100%; background: var(--blue); border-radius: 4px; }
.progress.done > i { background: var(--green); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
label.lbl { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 5px; color: #344054; }
label.lbl .req { color: var(--red); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid #cfd5de; border-radius: 8px; padding: 8px 11px; font: inherit; color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,111,224,.15); }
.input.sm { padding: 5px 8px; font-size: 13px; }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--blue); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .input { width: auto; min-width: 150px; }
.multi { max-height: 220px; overflow-y: auto; border: 1px solid #cfd5de; border-radius: 8px; padding: 6px 10px; }
.multi .check { padding: 5px 0; border-bottom: 1px solid var(--line-2); }
.multi .check:last-child { border: 0; }
.seg { display: inline-flex; border: 1px solid #cfd5de; border-radius: 8px; overflow: hidden; }
.seg label { padding: 7px 14px; cursor: pointer; font-weight: 500; border-right: 1px solid #cfd5de; }
.seg label:last-child { border-right: 0; }
.seg input { display: none; }
.seg input:checked + span { color: var(--blue); }
.seg label:has(input:checked) { background: var(--blue-50); color: var(--blue-600); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 15px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; line-height: 1.3; }
.btn:hover { text-decoration: none; filter: brightness(.96); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-dark { background: var(--navy-800); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-warn { background: var(--orange); color: #fff; }
.btn-danger { background: #fff; color: var(--red); border-color: #f0c4c4; }
.btn-danger:hover { background: var(--red-50); }
.btn-ghost { background: #fff; color: var(--text); border-color: #cfd5de; }
.btn-ghost:hover { background: #f6f7f9; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-link { background: none; border: 0; color: var(--blue); cursor: pointer; font: inherit; padding: 0; }
form.inline { display: inline; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 18px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid; }
.alert-success { background: var(--green-50); border-color: #c7e6b2; color: #2f5f12; }
.alert-danger { background: var(--red-50); border-color: #f3c3c3; color: #8f1d1d; }
.alert-warning { background: var(--amber-50); border-color: #f0dca4; color: #7a5200; }
.alert-info { background: var(--blue-50); border-color: #c7dcf8; color: #174a93; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--blue); border-color: var(--blue); }
.tabs .count { background: #eef0f4; color: var(--muted); font-size: 11px; padding: 0 7px; border-radius: 10px; }

/* Definition list */
dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 12.5px; }
dl.kv dd { margin: 0; font-weight: 500; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li:last-child { border-color: transparent; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--blue); }
.timeline li.ok::before { border-color: var(--green); background: var(--green); }
.timeline li.bad::before { border-color: var(--red); background: var(--red); }
.timeline .when { font-size: 12px; color: var(--muted); }

/* Workflow stepper */
.stepper { display: flex; gap: 0; margin-bottom: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stepper .s { flex: 1; padding: 12px 14px; display: flex; gap: 10px; align-items: center; border-right: 1px solid var(--line); font-weight: 600; color: var(--muted); font-size: 13px; }
.stepper .s:last-child { border-right: 0; }
.stepper .n { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #eef0f4; font-size: 12px; flex-shrink: 0; }
.stepper .s.done { color: #3f7a1c; } .stepper .s.done .n { background: var(--green); color: #fff; }
.stepper .s.now { color: var(--blue-600); background: var(--blue-50); } .stepper .s.now .n { background: var(--blue); color: #fff; }
.stepper .s.bad { color: #b02525; background: var(--red-50); } .stepper .s.bad .n { background: var(--red); color: #fff; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--navy-950); }
.login-hero { background: radial-gradient(1000px 600px at 30% 40%, #13213b 0%, var(--navy-950) 60%); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; color: var(--steel-300); text-align: center; }
.login-hero img { width: min(420px, 80%); }
.login-hero .tag { margin-top: 10px; letter-spacing: .14em; font-size: 12px; text-transform: uppercase; color: var(--steel-400); }
.login-hero .mods { display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; justify-content: center; }
.login-hero .mods span { border: 1px solid rgba(255,255,255,.12); border-radius: 999px; padding: 5px 13px; font-size: 12px; }
.login-side { background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 30px; }
.login-card { width: 100%; max-width: 390px; }
.login-card h1 { font-size: 24px; }
.login-card .card { padding: 26px; margin-top: 18px; }
.login-card .foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------- Print documents (PO / WO / GRN / Comparative) ---------- */
.doc { background: #fff; max-width: 900px; margin: 0 auto; padding: 32px 38px; border: 1px solid var(--line); box-shadow: var(--shadow); color: #111; font-size: 12.5px; }
.doc.wide { max-width: 1400px; }
.doc-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding-bottom: 12px; border-bottom: 3px solid var(--navy-900); }
.doc-head .co { display: flex; gap: 14px; align-items: center; }
.doc-head .co img { width: 86px; background: #0b1220; border-radius: 6px; padding: 4px; }
.doc-head .co .cn { font-size: 18px; font-weight: 800; letter-spacing: .02em; color: var(--navy-900); }
.doc-head .co .ca { font-size: 11.5px; color: #444; }
.doc-head .dt { text-align: right; }
.doc-head .dt .t { font-size: 18px; font-weight: 800; color: var(--blue-600); letter-spacing: .04em; text-transform: uppercase; }
.doc-letterhead img { width: 100%; display: block; }
.doc-bar { display: flex; height: 4px; margin-bottom: 14px; } .doc-bar i { flex: 1; } .doc-bar i:nth-child(1) { background: var(--blue); } .doc-bar i:nth-child(2) { background: var(--orange); } .doc-bar i:nth-child(3) { background: var(--green); }
.doc .boxes { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #bbb; margin: 14px 0; }
.doc .boxes > div { padding: 10px 12px; }
.doc .boxes > div + div { border-left: 1px solid #bbb; }
.doc .boxes h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #555; margin-bottom: 4px; }
.doc table.d { width: 100%; border-collapse: collapse; margin: 8px 0; }
.doc table.d th, .doc table.d td { border: 1px solid #bbb; padding: 6px 8px; vertical-align: top; }
.doc table.d th { background: #eef1f5; font-size: 11px; text-transform: uppercase; }
.doc table.d .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc .terms { margin-top: 12px; }
.doc .terms h4 { font-size: 12px; text-transform: uppercase; margin-bottom: 6px; }
.doc .sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 50px; text-align: center; }
.doc .sign div { border-top: 1px solid #555; padding-top: 6px; font-weight: 600; }
.doc .sign small { display: block; font-weight: 400; color: #555; }
.doc .foot { margin-top: 18px; font-size: 10.5px; color: #666; text-align: center; border-top: 1px solid #ddd; padding-top: 6px; }
.print-bar { max-width: 900px; margin: 0 auto 14px; display: flex; gap: 8px; justify-content: flex-end; }
.print-bar.wide { max-width: 1400px; }

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  .sidebar, .topbar, .print-bar, .no-print, .alert { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .doc table.d tr { page-break-inside: avoid; }
  .landscape { size: A4 landscape; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .g2, .g3, .form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .userchip .n, .userchip .r { display: none; }
  .login-page { grid-template-columns: 1fr; }
  .login-hero { padding: 30px 20px 10px; }
  .login-hero .mods { display: none; }
  .stepper { flex-direction: column; }
  .stepper .s { border-right: 0; border-bottom: 1px solid var(--line); }
  dl.kv { grid-template-columns: 1fr; }
  .doc { padding: 16px; }
  .doc .boxes { grid-template-columns: 1fr; }
  .doc .boxes > div + div { border-left: 0; border-top: 1px solid #bbb; }
}

.input.over { border-color: var(--red); color: var(--red); background: var(--red-50); }
.flag { color: var(--red); font-size: 11px; font-weight: 600; }
a.card.stat { display: block; color: inherit; text-decoration: none; }
a.card.stat:hover { border-color: #c9d6ea; }
/* Cards inside grids are spaced by the grid gap, not margins */
.grid > .card + .card, .grid > .card { margin-top: 0; }
.grid > div > .card + .card { margin-top: 18px; }
/* Blend the logo's black background into dark surfaces */
.login-hero img, .brand img { mix-blend-mode: lighten; }
@media (max-width: 520px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat .value { font-size: 22px; } }
.filters .input { height: 38px; }

/* ---------- Assets ---------- */
[hidden] { display: none !important; }
.asset-tiles { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.asset-tiles .tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; color: inherit; text-decoration: none; }
.asset-tiles .tile:hover { border-color: #c9d6ea; }
.asset-tiles .tile.on { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(30,111,224,.15); }
.asset-tiles .label { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.asset-tiles .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.asset-tiles .hint { font-size: 11.5px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; padding: 0; }
.dot.st-green { background: var(--green); } .dot.st-blue { background: var(--blue); } .dot.st-amber { background: var(--amber); }
.dot.st-orange { background: var(--orange); } .dot.st-red { background: var(--red); }
.asset-head { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: start; }
.asset-photo { width: 180px; height: 180px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.empty-photo { display: flex; align-items: center; justify-content: center; background: #f1f4f8; color: var(--steel-400); }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
@media (max-width: 1200px) { .asset-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .asset-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .asset-head { grid-template-columns: 1fr; }
  .asset-photo { width: 100%; height: 200px; }
}
.asset-tiles > .card + .card { margin-top: 0; }

/* ---------- Company switcher ---------- */
.company-switch { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 0 4px 0 10px; height: 38px; color: var(--muted); background: #fff; max-width: 400px; }
.company-switch select { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--text); padding: 6px 4px; max-width: 340px; cursor: pointer; }
.company-switch select:focus { outline: none; }
.company-switch:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,111,224,.15); }
.company-switch.single span { font-weight: 600; color: var(--text); padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 860px) { .company-switch { max-width: 150px; } .company-switch select { max-width: 110px; } .company-switch.single span { max-width: 100px; } }

/* ---------- User access ---------- */
.access-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.access-legend > div { display: flex; flex-direction: column; gap: 2px; }
.access-table td.center, .access-table th.center { text-align: center; }
.access-table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--blue); }
.access-box { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; background: #fafbfd; }
@media (max-width: 860px) { .access-legend { grid-template-columns: 1fr 1fr; } }
.doc-head .co img[src^="/files/"] { background: #fff; border: 1px solid #ddd; height: 64px; width: auto; max-width: 140px; object-fit: contain; }

/* ---------- Delivery challans ---------- */
.dc-stamp { display: inline-block; margin: 0 0 10px; padding: 4px 12px; border: 2px solid #b85c07; color: #b85c07; font-weight: 800; letter-spacing: .08em; border-radius: 4px; font-size: 12px; }
.dc-stamp.grey { border-color: #777; color: #555; }
.dc-stamp.cancel { border-color: #b02525; color: #b02525; }
.action-card { max-width: 900px; margin: 0 auto 16px; }
@media (max-width: 560px) {
  .topbar { gap: 8px; }
  .topbar .crumb { display: none; }
  .company-switch { max-width: 170px; padding-left: 8px; }
  .company-switch select { max-width: 130px; }
  .userchip { padding-left: 6px; gap: 6px; }
}
/* Grid columns may shrink below their content; wide tables scroll inside their card */
.grid > * { min-width: 0; }
@media (max-width: 1100px) { .g-main { grid-template-columns: minmax(0, 1fr); } }
.asset-tiles.tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.asset-tiles.tiles-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 860px) {
  .asset-tiles.tiles-4, .asset-tiles.tiles-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Printed documents scroll sideways on a phone instead of widening the page */
  .doc { overflow-x: auto; }
  .filters > div { min-width: 0; max-width: 100%; }
  .filters .input { min-width: 0; width: 100%; }
  .multi { grid-template-columns: 1fr !important; }
}

/* ---------- DPR ---------- */
table.t.compact th { padding: 8px 10px; }
table.t.compact td { padding: 7px 10px; }
.icon-btn.sm { width: 28px; height: 28px; font-size: 10px; }
.opt-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfd; }
.opt-row .input.sm { max-width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 14px; background: #eef2f8; font-size: 12.5px; }
.chip b { color: var(--navy-900); }
a.chip:hover { text-decoration: none; background: var(--blue-50); }
.chip.on { background: var(--blue); color: #fff; } .chip.on b { color: #fff; }
.pager { display: flex; gap: 4px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.pager a { min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); padding: 0 8px; }
.pager a.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.pager a:hover { text-decoration: none; }
.fmt-sec .removing, tr.removing td { opacity: .4; }
tr.removing input[name$="[name]"] { text-decoration: line-through; }
.fmt-sec.removing { opacity: .5; }
.fmt-items td { padding: 5px 6px !important; }
.dpr-sec .card-head h2 small { font-weight: 500; color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.dpr-rows td { padding: 6px 6px !important; vertical-align: middle !important; }
.dpr-rows .input.sm { min-width: 0; }
.dpr-rows .info { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.kpi-ring { display: flex; align-items: center; gap: 14px; }
.kpi-ring svg { flex: none; }
.bar { height: 8px; background: #e8ebf0; border-radius: 5px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: 5px; }
.bar.done > i { background: var(--green); } .bar.low > i { background: var(--orange); }
.secdots { display: inline-flex; gap: 4px; vertical-align: middle; }
.secdot { width: 22px; height: 8px; border-radius: 3px; background: #e3e7ee; }
.secdot.progress { background: var(--amber); } .secdot.done { background: var(--green); }
.legend-dots { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend-dots span { display: inline-flex; gap: 6px; align-items: center; }
.doc.dpr { max-width: 1250px; font-size: 11.5px; }
.doc.dpr h3 { font-size: 13px; margin: 18px 0 6px; color: var(--navy-900); text-transform: uppercase; letter-spacing: .03em; }
.doc.dpr table { width: 100%; border-collapse: collapse; }
.doc.dpr th { background: #1f3a63; color: #fff; font-weight: 600; padding: 5px 6px; border: 1px solid #c9d1dc; font-size: 10.5px; }
.doc.dpr td { padding: 4px 6px; border: 1px solid #c9d1dc; vertical-align: top; }
.doc.dpr td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc.dpr tr.tot td { background: #f1f4f8; font-weight: 700; }
.doc.dpr .kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.doc.dpr .kpis div { background: #eef3fb; border-radius: 6px; padding: 8px 10px; text-align: center; }
.doc.dpr .kpis b { display: block; font-size: 18px; color: var(--navy-900); }
.doc.dpr .sigs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 30px; }
.doc.dpr .sigs div { border-top: 1px solid #555; padding-top: 4px; text-align: center; font-weight: 600; }
@media print { .doc.dpr { font-size: 9.5px; padding: 0; } .doc.dpr h3 { break-after: avoid; } .doc.dpr table { break-inside: auto; } .doc.dpr tr { break-inside: avoid; } }
@media (max-width: 700px) { .doc.dpr .kpis { grid-template-columns: 1fr 1fr; } .opt-row { flex-direction: column; align-items: stretch; } }
@media (max-width: 700px) {
  .dpr-rows thead { display: none; }
  .dpr-rows, .dpr-rows tbody { display: block; }
  .dpr-rows tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .dpr-rows td { padding: 0 !important; border: 0 !important; }
  .dpr-rows td:nth-child(1), .dpr-rows td:nth-child(4), .dpr-rows td:nth-child(5) { grid-column: 1 / -1; }
  .dpr-rows td:nth-child(6) { grid-column: 1 / -1; text-align: right; }
  .dpr-sec .card-head h2 small { display: block; margin: 2px 0 0; }
}

/* ---------- DPR drill-down (Circle → Location → Task → Sub-component) ---------- */
.crumbs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; margin: -4px 0 10px; color: var(--muted); }
.crumbs a { display: inline-flex; gap: 5px; align-items: center; }
.pc-done { color: var(--green) !important; font-weight: 700; } .pc-part { color: #c46d0a !important; font-weight: 600; } .pc-zero { color: #8a94a3 !important; }
.sec-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.sec-kpis .card { padding: 12px 14px; margin: 0; }
.sec-kpis b { display: block; font-size: 22px; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.pick-table tbody tr[data-href], .circle-table tbody tr[data-href] { cursor: pointer; }
.pick-table tbody tr[data-href]:hover td, .circle-table tbody tr[data-href]:hover td { background: var(--blue-50); }
.task-row { cursor: pointer; }
.task-row:hover td, .task-row.open td { background: #f2f6fd; }
.task-row .caret { display: inline-block; width: 12px; color: var(--muted); font-size: 0; }
.task-row .caret::before { content: '▸'; font-size: 13px; }
.task-row.open .caret::before { content: '▾'; color: var(--blue); }
.task-panel > td { background: #f7f9fc; padding: 10px 14px 16px !important; border-left: 3px solid var(--blue); }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.sub-table { background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.sub-table td.files { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; min-width: 120px; }
.sub-table td.files img { width: 40px; height: 40px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); display: block; }
.filechip { display: inline-flex; gap: 3px; align-items: center; font-size: 11px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; }
.sub-table tr.is-na .iname { text-decoration: line-through; color: var(--muted); }
.flash-row td { animation: flashrow 2.5s ease-out; }
@keyframes flashrow { from { background: #fff3c4; } to { background: transparent; } }
.bulk-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; padding: 8px 10px; background: #fff; border: 1px dashed var(--line); border-radius: 8px; }
.bulk-bar .input.sm { width: auto; }
.bulk-bar label { display: inline-flex; gap: 6px; align-items: center; }
dialog.dlg { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(10, 20, 40, .35); }
dialog.dlg::backdrop { background: rgba(11, 18, 32, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 16px 18px 8px; border-bottom: 1px solid var(--line); }
.dlg-head h3 { margin: 2px 0 6px; font-size: 16px; }
.dlg-body { padding: 14px 18px; max-height: 70vh; overflow: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: #fafbfd; border-radius: 0 0 14px 14px; }
.loc-details summary { cursor: pointer; list-style: none; }
.loc-details summary::-webkit-details-marker { display: none; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 18px; padding-top: 0; }
.kv-grid div { display: flex; flex-direction: column; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; }
.gallery img, .gallery .pdfbox { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 6px; background: #f3f5f8; color: var(--muted); }
.gallery figcaption { display: flex; justify-content: space-between; gap: 6px; margin-top: 4px; }
@media (max-width: 760px) {
  .sub-table thead { display: none; }
  .sub-table, .sub-table tbody { display: block; }
  .sub-table tr { display: grid; grid-template-columns: 26px 1fr auto; gap: 4px 8px; padding: 10px; border-bottom: 1px solid var(--line); }
  .sub-table td { padding: 0 !important; border: 0 !important; }
  .sub-table td:nth-child(2) { display: none; }
  .sub-table td:nth-child(3) { grid-column: 2 / 3; }
  .sub-table td:nth-child(4), .sub-table td:nth-child(6), .sub-table td:nth-child(7), .sub-table td:nth-child(8) { grid-column: 2 / -1; }
  .sub-table td:nth-child(5) { grid-column: 3; grid-row: 1; }
  .sub-table td:nth-child(9) { grid-column: 2 / -1; text-align: right; }
  .task-panel > td { padding: 8px !important; }
  .panel-head { flex-direction: column; }
}
.circ-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--blue); box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px var(--blue); vertical-align: -2px; margin-right: 4px; }
.tot-row td { background: #f3f6fa; }
@media (max-width: 760px) {
  .task-table, .task-table tbody { display: block; }
  .task-table thead { display: none; }
  .task-table tr.task-row { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; padding: 12px; border-bottom: 1px solid var(--line); }
  .task-table tr.task-row td { padding: 0 !important; border: 0 !important; font-size: 13px; }
  .task-table tr.task-row td:nth-child(1) { display: none; }
  .task-table tr.task-row td:nth-child(2), .task-table tr.task-row td:nth-child(8) { grid-column: 1 / -1; }
  .task-table tr.task-row td:nth-child(4)::before { content: 'Plan: '; color: var(--muted); }
  .task-table tr.task-row td:nth-child(5)::before { content: 'to '; color: var(--muted); }
  .task-table tr.task-panel { display: block; }
  .task-table tr.task-panel[hidden] { display: none; }
  .task-table tr.task-panel > td { display: block; }
  .bulk-bar { flex-direction: column; align-items: stretch; }
}
