:root {
  --navy: #1f5c80;
  --navy-ink: #123a52;
  --orange: #e8722f;
  --bg: #fbf7f1;
  --surface: #ffffff;
  --surface-2: #f3eee6;
  --ink: #1d2430;
  --muted: #5d6675;
  --line: #e2dbd0;
  --ok: #1d7a46;
  --warn: #a35c00;
  --bad: #b3261e;
  --info: #1f5c80;
  --radius: 12px;
  --tap: 44px;
  color-scheme: light;
  font-family: "Noto Sans", "Noto Sans Telugu", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c; --surface: #1b2129; --surface-2: #242c36; --ink: #e9edf2; --muted: #a3adba;
    --line: #313b47; --ok: #4cc283; --warn: #f0a443; --bad: #ff7b72; --info: #7cb8e0; --navy: #2d6f96;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161c; --surface: #1b2129; --surface-2: #242c36; --ink: #e9edf2; --muted: #a3adba;
  --line: #313b47; --ok: #4cc283; --warn: #f0a443; --bad: #ff7b72; --info: #7cb8e0; --navy: #2d6f96;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
select { max-width: 100%; min-width: 0; text-overflow: ellipsis; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 16px 0 8px; }
p { margin: 0 0 12px; }
a { color: var(--info); }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }

.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--navy); color: #fff;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; margin-right: auto; }
.brand strong { font-size: 1.15rem; letter-spacing: .06em; }
.tagline { font-size: .75rem; opacity: .85; }
.topbar select { min-height: 40px; border-radius: 8px; border: 0; padding: 0 10px; max-width: 46vw; }
.icon-btn { min-width: var(--tap); min-height: var(--tap); border: 0; border-radius: 10px;
  background: rgba(255,255,255,.12); color: #fff; font-size: 1.1rem; cursor: pointer; }
#menu-btn { display: none; }

.sync { font-size: .82rem; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.15); }
.sync.offline { background: #f0a443; color: #241500; }
.sync.failed { background: #ff7b72; color: #2a0000; }

.layout { display: flex; min-height: calc(100vh - 60px); }
.nav { width: 230px; flex: none; padding: 12px; border-right: 1px solid var(--line); background: var(--surface); }
.nav a { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 12px; border-radius: 10px;
  color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--surface-2); font-weight: 600; box-shadow: inset 3px 0 0 var(--orange); }
.nav .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 12px 4px; }
.view { flex: 1; min-width: 0; padding: 20px 16px 48px; max-width: 1100px; outline: none; }

@media (max-width: 820px) {
  #menu-btn { display: inline-block; }
  .nav { position: fixed; inset: 60px 0 0 0; width: auto; z-index: 9; overflow: auto; }
  .nav:not(.open) { display: none; }
  .tagline { display: none; }
}

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 16px; min-height: 96px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.tile:hover { border-color: var(--orange); }
.tile .big { font-size: 1.6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

form .fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--ink); min-height: var(--tap); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); min-height: var(--tap);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
input[type="checkbox"] { width: 24px; height: 24px; min-height: 0; accent-color: var(--navy); }
textarea { min-height: 80px; }
button, .btn { font: inherit; min-height: var(--tap); padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  background: var(--navy); color: #fff; cursor: pointer; font-weight: 600; }
button.secondary { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
button.danger { background: var(--bad); }
button.accent { background: var(--orange); }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); }
.pill.info { color: var(--info); } .pill.neutral { color: var(--muted); }

.banner { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; border-left: 4px solid var(--warn); background: var(--surface-2); }
.banner.bad { border-color: var(--bad); }
.banner.ok { border-color: var(--ok); }

.step { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step .num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; }
.step .te { display: block; color: var(--muted); font-size: .92rem; }

.tree ul { list-style: none; margin: 0; padding-left: 22px; border-left: 1px dashed var(--line); }
.tree > ul { padding-left: 0; border: 0; }
.tree li { margin: 6px 0; }
.node { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 8px; background: var(--navy); color: #fff; }
.node.hub { background: var(--orange); border-radius: 999px; }
.node.spoke { background: transparent; color: var(--ink); border: 2px solid var(--orange); border-radius: 999px; }
.node .lvl { font-size: .7rem; opacity: .8; text-transform: uppercase; }

.timer { font-size: 2.4rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.kpi { font-size: 1.8rem; font-weight: 700; }
.scan video { width: 100%; max-width: 420px; border-radius: 10px; background: #000; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 10px; background: var(--ink); color: var(--bg);
  box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 20; }
.toast.bad { background: var(--bad); color: #fff; }

@media print {
  .topbar, .nav, .no-print, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .view { padding: 0; }
}

.login { max-width: 420px; margin: 8vh auto; }
.login .logo { font-size: 2rem; font-weight: 800; color: var(--navy); letter-spacing: .08em; }

/* Recipes + Cook on SmartChef */
.card.tile { display: flex; flex-direction: column; gap: 6px; min-height: 96px; }
.card.tile:hover { border-color: var(--navy, #2d6f96); }
.progress { height: 12px; border-radius: 999px; background: var(--surface-2, #eee6da); overflow: hidden; margin: 10px 0; }
.progress span { display: block; height: 100%; background: var(--ok); transition: width .4s ease; }
tr.current-step td { background: color-mix(in srgb, var(--ok) 14%, transparent); font-weight: 600; }
textarea.mono { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
@media (prefers-reduced-motion: reduce) { .progress span { transition: none; } }
/* Picker: searchable multi-select with chips */
.picker { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 8px; }
.picker-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip-sel { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 6px 4px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); max-width: 100%; }
.chip-sel > span { overflow-wrap: anywhere; }
.chip-sel button { min-height: 32px; min-width: 32px; padding: 0; border-radius: 50%; background: transparent; color: var(--muted); border: 0; font-size: 1rem; }
.chip-sel button:hover { background: var(--line); color: var(--ink); }
.chip-sel input[type=number] { width: 64px; min-height: 32px; padding: 2px 8px; }
.chip-sel label.opt { flex-direction: row; align-items: center; gap: 4px; font-size: .8rem; }
.chip-sel label.opt input { width: 18px; height: 18px; }
.picker-clear { min-height: 32px; padding: 0 12px; background: transparent; color: var(--muted); border: 1px dashed var(--line); font-weight: 500; }
.picker-box { position: relative; }
.picker-q { width: 100%; }
.picker-list { position: absolute; z-index: 15; left: 0; right: 0; top: calc(100% + 4px); max-height: 320px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 4px; }
.picker-opt { display: flex; justify-content: space-between; gap: 10px; min-height: var(--tap); align-items: center; padding: 6px 10px;
  border-radius: 8px; cursor: pointer; }
.picker-opt.on, .picker-opt:hover { background: var(--surface-2); }
.picker-none, .picker-more { padding: 8px 10px; }
.picker-all { width: 100%; margin-top: 4px; }

/* Wizard */
.wizard-steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 12px 0 16px; overflow-x: auto; }
.wizard-steps li { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.wizard-steps li .num { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; }
.wizard-steps li.on { border-color: var(--navy); color: var(--ink); font-weight: 600; }
.wizard-steps li.on .num { background: var(--navy); color: #fff; }
.wizard-steps li.done .num { background: var(--ok); color: #fff; }
@media (max-width: 700px) { .wizard-steps li:not(.on) .lbl { display: none; } .wizard-steps li:not(.on) { flex: 0 0 auto; } }
.wizard-nav { justify-content: space-between; }
.radio-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); margin-bottom: 8px; }
.radio-card { flex-direction: row; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); cursor: pointer; }
.radio-card.on { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.radio-card input { margin-top: 3px; width: 20px; height: 20px; min-height: 0; }
table.review th { width: 34%; }

/* Asset labels: screen grid; print 3 per row on A4 or one per 50x30 mm label */
.label-sheet { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.asset-label { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px dashed var(--line); border-radius: 8px;
  background: #fff; color: #000; break-inside: avoid; page-break-inside: avoid; }
.asset-label img { flex: none; image-rendering: pixelated; }
.asset-label-text { min-width: 0; line-height: 1.2; }
.asset-label-brand { font-weight: 800; letter-spacing: .08em; font-size: .8rem; }
.asset-label-code { font-size: 1.15rem; font-weight: 800; }
.asset-label-name { font-size: .85rem; font-weight: 600; overflow-wrap: anywhere; }
.asset-label-site { font-size: .72rem; }
@media print {
  .label-sheet { grid-template-columns: repeat(3, 1fr); gap: 4mm; }
  .asset-label { border: .2mm solid #999; height: 30mm; }
}

/* address search + generated ID */
.picker-box { display: block; }
span.picker-list { display: block; }
.addr { margin: 4px 0 8px; }
.addr .addr-gps { margin: 6px 0; }
.addr-card { border: 1px solid var(--line, #e3ddd2); border-radius: 10px; padding: 10px 12px; margin-top: 6px; }
input.readonly, input[readonly] { background: var(--soft, #f4f1ea); color: var(--muted, #555); }
.addr > label { display: block; width: 100%; }
.addr .addr-q { width: 100%; box-sizing: border-box; }

/* opening wizard: quantity per product, plan summary */
.qty-grid { display: grid; gap: 8px; }
.qty-row { display: grid; grid-template-columns: 1fr; gap: 6px 12px; border: 1px solid var(--line, #e3ddd2); border-radius: 10px; padding: 10px 12px; }
@media (min-width: 720px) { .qty-row { grid-template-columns: 1.2fr 1.4fr 1fr 1fr; align-items: end; } }
.plan-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.plan-sum .stat { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line, #e3ddd2); border-radius: 10px; padding: 10px 12px; }
.plan-sum .stat strong { font-size: 1.15rem; }
table.plan select { min-width: 9rem; }

/* R&D centre: tabs and rows editor (mobile-first: each row wraps its fields) */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line, #e3ddd2); margin: 4px 0 12px; }
.tabs a { padding: 10px 14px; text-decoration: none; color: inherit; white-space: nowrap; border-bottom: 3px solid transparent; }
.tabs a.on { border-bottom-color: var(--brand, #1f5f86); font-weight: 600; }
.rows-ed { display: grid; gap: 8px; margin: 6px 0 12px; }
.rows-body { display: grid; gap: 8px; }
.ed-row { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; border: 1px solid var(--line, #e3ddd2); border-radius: 10px; padding: 10px; }
.ed-row > label { display: flex; flex-direction: column; gap: 2px; flex: 1 1 140px; min-width: 0; margin: 0; }
.ed-row > label.wide { flex: 2 1 100%; }
.ed-row > label.narrow { flex: 0 1 90px; }
.ed-row > label.check { flex-direction: row; align-items: center; flex: 0 1 auto; }
.ed-row > label > span { font-size: .8rem; color: var(--muted, #666); }
.ed-row input, .ed-row select { width: 100%; box-sizing: border-box; }
.ed-num { font-weight: 600; color: var(--muted, #666); align-self: center; }
.ed-actions { display: flex; gap: 6px; margin-left: auto; }
@media (min-width: 900px) { .ed-row > label.wide { flex: 2 1 260px; } }
ol.proc-steps li { margin: 6px 0; }

.ed-more { flex: 1 1 100%; }
.ed-more-body { display: flex; flex-wrap: wrap; gap: 8px 10px; margin-top: 6px; }
.ed-more-body > label { display: flex; flex-direction: column; gap: 2px; flex: 1 1 140px; min-width: 0; margin: 0; }
.ed-more-body > label.wide { flex: 2 1 100%; }
.ed-more-body > label > span { font-size: .8rem; color: var(--muted, #666); }
.ed-row > label.narrow { flex: 1 1 70px; }

/* Address map picker */
.addr-btns { gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.map-modal { position: fixed; inset: 0; z-index: 2000; background: rgba(16, 24, 40, .55); display: flex; align-items: center; justify-content: center; padding: 12px; }
.map-box { background: var(--surface); color: var(--ink); border-radius: 14px; width: min(880px, 100%); max-height: 96vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(16, 24, 40, .35); }
.map-head, .map-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; }
.map-head { border-bottom: 1px solid var(--line); }
.map-foot { border-top: 1px solid var(--line); }
.map-foot .row { flex: 1 1 100%; flex-wrap: wrap; gap: 8px; }
.map-label { flex: 1 1 100%; min-height: 1.4em; }
.map-canvas { height: min(62vh, 560px); min-height: 280px; }
@media (max-width: 600px) { .map-modal { padding: 0; } .map-box { border-radius: 0; height: 100%; max-height: none; } .map-canvas { flex: 1; height: auto; } }

.map-search { flex: 1 1 100%; }
.map-search .map-q { width: 100%; box-sizing: border-box; }
.map-search .picker-list { z-index: 1000; }
.map-canvas { position: relative; z-index: 0; }

details.card-lite { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; }
details.card-lite > summary { cursor: pointer; }
