:root {
  --sea: #0f4c5c; --sea-2: #16697a; --sea-tint: #e4f0f2;
  --sand: #f4ede1; --sand-2: #e9dcc3; --terra: #c4673c;
  --ink: #1d2a2f; --muted: #6b7a80; --line: #e3e7e8; --bg: #f7f5f0; --card: #ffffff;
  --green: #2e8b57; --amber: #c98a12; --red: #c0392b; --blue: #2c6fb7;
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h2 { font-size: 20px; margin: 4px 0 14px; }
h3 { font-size: 15px; color: var(--sea); text-transform: uppercase; letter-spacing: .04em; }
small { display: block; color: var(--muted); font-size: 12.5px; }
a { color: var(--sea-2); }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; } .pad { padding: 18px; }
.red-t { color: var(--red); } .green-t { color: var(--green); }
.grow { flex: 1; }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; background: var(--sea); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand small { color: #cfe3e7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--sand-2); color: var(--sea); font-weight: 800; }
.logo.lg { width: 64px; height: 64px; font-size: 30px; border-radius: 16px; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.top .ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.icon-btn { position: relative; background: transparent; border: 0; font-size: 18px; padding: 4px 6px; cursor: pointer; }
.badge { position: absolute; top: -2px; right: -4px; background: var(--terra); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 5px; }

/* tabs */
.tabs { position: sticky; top: 54px; z-index: 9; display: flex; gap: 4px; overflow-x: auto; background: var(--card); border-bottom: 1px solid var(--line); padding: 0 10px; }
.tabs a { padding: 12px 12px; white-space: nowrap; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--sea); border-color: var(--terra); }

.view { max-width: 980px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }

/* cards */
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; text-decoration: none; color: inherit; }
.card.hero { background: linear-gradient(135deg, var(--sea), var(--sea-2)); color: #fff; border: 0; }
.card.hero small, .card.hero p { color: #d7eaee; margin: 0; }
.card.hero h2 { margin: 2px 0; font-size: 24px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; text-decoration: none; color: var(--ink); }
.kpi b { display: block; font-size: 28px; color: var(--sea); }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi.warn { border-color: var(--sand-2); background: var(--sand); }
.kpi.warn b { color: var(--terra); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.line-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0; font-size: 14px; }
.stockhint { font-size: 13px; background: var(--sea-tint); padding: 6px 10px; border-radius: 8px; margin: 6px 0; }
.zone-row { display: grid; grid-template-columns: 230px 1fr 48px; align-items: center; gap: 10px; padding: 7px 0; }
.zone-name small { display: inline; margin-left: 4px; }
.pct { text-align: right; }
.bar { height: 9px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 6px 0; }
.bar span { display: block; height: 100%; background: var(--sea-2); border-radius: 6px; }
.bar.warn span { background: var(--terra); }
.task { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0 3px 10px; border-left: 2px solid var(--sand-2); margin: 3px 0; }
.pkg { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.pkg:last-child { border-bottom: 0; }
.mline { padding: 8px 0; border-bottom: 1px solid var(--line); }
.mline:last-child { border-bottom: 0; }
.steps { display: flex; gap: 4px; margin-top: 6px; }
.steps i { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--sea-2); }
.load { margin: 10px 0; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
pre.wa { white-space: pre-wrap; background: #eef8ef; border: 1px solid #cfe9d3; border-radius: 10px; padding: 10px; font: 13px/1.45 ui-monospace, Menlo, monospace; margin: 10px 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; }
td small { display: inline; }
.r { text-align: right; }
details { margin-top: 8px; } summary { cursor: pointer; color: var(--sea-2); font-weight: 600; }
.notif b { display: block; }

/* chips */
.chip { display: inline-block; white-space: nowrap; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 20px; background: var(--line); color: var(--ink); }
.chip.amber { background: #fbefd5; color: #8a5d00; } .chip.blue { background: #e1ecf8; color: #1f5590; }
.chip.teal { background: var(--sea-tint); color: var(--sea); } .chip.green { background: #dff1e6; color: #1f6b40; }
.chip.red { background: #f8e0dc; color: #9b2c1f; } .chip.grey { background: #eceeef; color: #555; }
.chip.big { font-size: 16px; padding: 10px 18px; }

/* forms + buttons */
button, .btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; display: inline-block; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--sea); color: #fff; border-color: var(--sea); }
button.danger { color: var(--red); border-color: #f0c9c2; }
button.ghost { background: transparent; } button.sm { padding: 5px 10px; font-size: 13px; }
button.big { font-size: 18px; padding: 16px 34px; border-radius: 14px; }
.btn.wa-btn { background: #25d366; color: #fff; border-color: #25d366; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid #cdd5d7; border-radius: 9px; background: #fff; width: 100%; color: var(--ink); }
.qty-in { width: 96px; }
.actions select, .line-head select { width: auto; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; align-items: end; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form .full { grid-column: 1 / -1; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.form label.check input { width: auto; }
.form > button { grid-column: 1 / -1; padding: 12px; }
.pick { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick input { width: 20px; height: 20px; margin-top: 3px; flex: none; }
.photo-btn { display: inline-block; padding: 9px 14px; border: 1px dashed var(--sea-2); color: var(--sea-2); border-radius: 10px; cursor: pointer; font-weight: 600; margin-top: 8px; }
.photo-btn input { display: none; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 6px 10px; font-size: 13px; }
.seg button.on { background: var(--green); color: #fff; } .seg button.on.off { background: var(--red); }
.catalogue { max-height: 320px; overflow-y: auto; margin-top: 8px; }
.add { display: flex; gap: 6px; } .add .qty-in { width: 80px; }

/* login */
.login { max-width: 640px; margin: 0 auto; padding: 32px 16px; }
.login-head { text-align: center; margin-bottom: 24px; }
.login-head h1 { margin-top: 12px; color: var(--sea); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.user-card { text-align: left; padding: 14px; background: var(--card); }
.user-card:hover { border-color: var(--sea-2); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(80px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; opacity: 0; transition: .25s; z-index: 50; max-width: 90vw; }
.toast.show { transform: translateX(-50%); opacity: 1; }

@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .zone-row { grid-template-columns: 110px 1fr 40px; }
  .form { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .top .ghost.sm { padding: 4px 7px; }
  .brand small { max-width: 150px; }
}

/* language switch: ID | EN */
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.lang button { border: 0; border-radius: 0; padding: 5px 10px; font-size: 13px; background: transparent; color: var(--muted); }
.lang button.on { background: var(--sea); color: #fff; }
.top .lang { border-color: rgba(255,255,255,.35); background: transparent; }
.top .lang button { color: #cfe3e7; }
.top .lang button.on { background: var(--sand-2); color: var(--sea); }
.login .lang { margin-bottom: 14px; }
.login-foot { display: flex; justify-content: center; gap: 8px; align-items: center; }
.login-foot .lang { margin: 0; }

/* ===================== icons, header menu ===================== */
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.top { padding-top: max(10px, env(safe-area-inset-top, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; color: #fff; border-radius: 10px; text-decoration: none; list-style: none; }
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:active { background: rgba(255,255,255,.12); }
.badge { top: 4px; right: 2px; }
.who { min-width: 0; }
.who b, .who small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { flex: none; }
.wide-only { display: flex; gap: 6px; align-items: center; }
.narrow-only { display: none; }
.menu { position: relative; }
.menu summary { cursor: pointer; }
.menu-pop { position: absolute; right: 0; top: 50px; width: 220px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(15,76,92,.18); padding: 14px; display: grid; gap: 10px; z-index: 30; }
.menu-pop .lang { justify-self: start; }
.menu-pop button { width: 100%; }
.quick { display: flex; gap: 8px; }
.quick button { flex: 1; }

/* tabs: icon + label (desktop: under the header) */
.tabs a { display: flex; align-items: center; gap: 6px; }
.tabs .ic { width: 18px; height: 18px; }

/* ===================== phones ===================== */
@media (max-width: 760px) {
  html, body { font-size: 16px; }
  .wide-only { display: none; }
  .narrow-only { display: block; }
  .top { padding-bottom: 8px; }
  .logo { width: 32px; height: 32px; }
  .who b { font-size: 15px; } .who small { font-size: 12px; color: #cfe3e7; }

  /* bottom tab bar, within thumb reach */
  .tabs { position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 20; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0;
          padding: 4px 4px max(6px, env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); border-bottom: 0; box-shadow: 0 -4px 16px rgba(15,76,92,.07); overflow: visible; }
  .tabs a { flex-direction: column; justify-content: center; gap: 2px; min-height: 54px; padding: 4px 2px; border-bottom: 0; border-radius: 10px; font-size: 11.5px; text-align: center; line-height: 1.15; }
  .tabs a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabs.n6 a { font-size: 10.5px; }
  .tabs a.on { color: var(--sea); background: var(--sea-tint); }
  .tabs .ic { width: 23px; height: 23px; }
  .view { padding: 14px max(14px, env(safe-area-inset-left, 0px)) calc(96px + env(safe-area-inset-bottom, 0px)); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

  /* finger-sized controls; 16px text stops iPhone zooming into fields */
  button, .btn, select, input:not([type=checkbox]):not([type=radio]), textarea { min-height: 46px; font-size: 16px; }
  button.sm, .lang button { min-height: 44px; min-width: 44px; }
  .seg button { min-height: 42px; padding: 6px 12px; }
  .qty-in { width: 100px; }
  .actions { gap: 8px; }
  .actions > button, .actions > .btn, .actions > select, .actions > input.grow { flex: 1 1 140px; text-align: center; }
  .actions > .qty-in { flex: 0 0 100px; }
  .pick { padding: 12px 0; } .pick input { width: 24px; height: 24px; }
  .photo-btn { display: block; text-align: center; padding: 14px; font-size: 16px; }
  .line-head { flex-wrap: wrap; }
  .line-head > select { width: 100%; }
  .facts { flex-direction: column; gap: 4px; }
  .row .seg { flex: none; }
  .add .qty-in { width: 84px; }
  .add button { min-width: 46px; }
  h2 { font-size: 21px; }
  .card { padding: 14px; border-radius: 14px; }
  table { font-size: 14px; }
  .card table { display: block; overflow-x: auto; }
  .kpi b { font-size: 26px; }
  .zone-row { grid-template-columns: 1fr 64px; row-gap: 2px; }
  .zone-row .bar { grid-column: 1 / -1; grid-row: 2; }
  .zone-row .pct { grid-row: 1; grid-column: 2; }
  .user-card { min-height: 64px; }
  .form label.check { min-height: 46px; } .form label.check input { width: 24px; height: 24px; }
}
.top .menu-pop .lang { border-color: var(--line); background: #fff; }
.top .menu-pop .lang button { color: var(--muted); }
.top .menu-pop .lang button.on { background: var(--sea); color: #fff; }

/* ===================== live: sign in, setup ===================== */
.signin { max-width: 420px; margin: 16px auto; grid-template-columns: 1fr; }
.subtabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.subtabs button { white-space: nowrap; border-radius: 20px; padding: 8px 14px; }
.subtabs button.on { background: var(--sea); color: #fff; border-color: var(--sea); }
.ok-card { border-color: #bfe3cc; background: #f1faf4; }
.pin-row { display: flex; gap: 6px; } .pin-row input { flex: 1; } .pin-row button { flex: none; }
.urow { padding: 10px 0; border-bottom: 1px solid var(--line); } .urow:last-child { border-bottom: 0; }
.urow.inactive { opacity: .55; }
label.check.small { flex-direction: row; display: flex; align-items: center; gap: 6px; }
@media (max-width: 760px) { .pin-row button { min-width: 110px; } }
button.link { background: none; border: 0; padding: 0; min-height: 0; color: var(--sea-2); text-decoration: underline; font: inherit; font-size: inherit; cursor: pointer; }
.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.more-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 18px; color: var(--sea); }
.more-tile .ic { width: 28px; height: 28px; }
.more-tile b { color: var(--ink); font-size: 16px; }
.new-pkg summary { cursor: pointer; color: var(--sea); list-style: none; padding: 4px 0; }
.new-pkg summary::-webkit-details-marker { display: none; }
.actions label.grow { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.actions label.grow select { width: 100%; }
/* users list: compact action row */
.urow .actions > button { flex: 1 1 0; min-width: 0; padding: 8px 6px; font-size: 14px; }
@media (max-width: 760px) { .urow .actions > button { min-height: 42px; } }
.edit-user { background: var(--sea-tint); border-radius: 12px; padding: 12px; margin-top: 10px; }
.edit-user .actions > button { flex: 1 1 0; }
[hidden] { display: none !important; }

.tr-row { display: flex; gap: 6px; align-items: stretch; }
.tr-row input { flex: 1; min-width: 0; }
.tr-btn { flex: none; padding: 0 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
input.flash { background: #e6f4ea; transition: background .2s; }
