:root {
  --bg: #F4F3EF; --card: #FFFFFF; --ink: #1B1E22; --ink2: #3F4349; --muted: #5C6066; --line: #E1DED6; --line2: #ECEAE4;
  --head: #16241D; --head2: #2E4A3C; --headtext: #D5DED8;
  --pri: #1F5F46; --pri-d: #174A36; --pri-l: #F1F7F3; --wa: #156B3A;
  --red: #A62424; --red-bg: #F6D9D9; --amber: #7F4306; --amber-bg: #FBE5C3; --blue: #1C4A84; --blue-bg: #DCE7F6;
  --green: #195E37; --green-bg: #D3ECDC; --grey-bg: #E6E3DB; --note-bg: #FFF4DE; --note: #6A3E05;
  --r: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 'IBM Plex Sans', system-ui, sans-serif; }
a { color: var(--pri); }
a:hover { color: var(--pri-d); }
h1 { font-size: 26px; margin: 0; line-height: 1.2; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: 'IBM Plex Mono', monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--red); min-height: 1em; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.gap6 { gap: 6px; }

/* ---------- login ---------- */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--head); }
.login { width: 100%; max-width: 360px; background: var(--card); border-radius: 14px; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.login h1 span, .brand span { font-weight: 400; color: #7A8F84; }

/* ---------- header / nav ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: 10px 24px; background: var(--head); color: #F4F3EF; }
.brand { font-weight: 700; font-size: 18px; color: #F4F3EF; text-decoration: none; }
.brand span { color: #B9C7BF; }
.topnav { display: flex; flex-wrap: wrap; gap: 2px; }
.topnav a { color: var(--headtext); text-decoration: none; padding: 8px 12px; border-radius: 7px; font-weight: 500; }
.topnav a:hover { background: #24382E; color: #fff; }
.topnav a.on { background: var(--head2); color: #fff; }
.topnav .badge, .botnav .badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: #C98A2E; color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--headtext); }
.storepick select { background: #24382E; color: #fff; border: 1px solid #3C5a4c; border-radius: 7px; min-height: 36px; padding: 0 8px; font: inherit; }
.linkbtn { background: none; border: 0; color: var(--headtext); font: inherit; text-decoration: underline; cursor: pointer; padding: 6px 0; min-height: 36px; }
.botnav { display: none; }
main { max-width: 1440px; margin: 0 auto; padding: 20px 24px 60px; outline: none; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 8px; font: 600 14px/1.1 inherit; font-family: inherit; text-decoration: none; border: 1px solid #C9C6BD; background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--pri); color: var(--ink); }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.pri:hover { background: var(--pri-d); color: #fff; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.danger { color: var(--red); border-color: #E2B9B9; }
.btn.ghost { border-style: dashed; color: var(--ink2); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.full { width: 100%; }
.btn:disabled { background: #F1F0EC; color: #8A8D92; border-color: var(--line); cursor: default; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button, .chip { min-height: 40px; padding: 0 13px; border-radius: 8px; border: 1px solid #C9C6BD; background: #fff; font: 600 13px inherit; font-family: inherit; color: var(--ink); cursor: pointer; }
.seg button.on, .chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip { border-radius: 999px; }
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #4A4E54; font-weight: 500; min-width: 0; }
.fld input, .fld select, .fld textarea, input.in, select.in, textarea.in {
  min-height: 42px; width: 100%; padding: 0 11px; border: 1px solid #C9C6BD; border-radius: 8px; font: 14px inherit; font-family: inherit; color: var(--ink); background: #fff; }
.fld textarea, textarea.in { padding: 9px 11px; min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid #6FA58A; outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink2); min-height: 36px; }
.check input { width: 18px; height: 18px; }

/* ---------- surfaces ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; min-width: 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; min-width: 0; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 24px; font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.cols > .main { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.cols > .side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 18px; margin-bottom: 16px; }
.pagehead .sub { font-size: 13px; color: var(--muted); }
.banner { border-radius: 10px; padding: 11px 14px; line-height: 1.5; }
.banner.info { background: #EEF4FB; color: #1C3F6E; }
.banner.warn { background: var(--note-bg); color: var(--note); }
.banner.bad { background: var(--red-bg); color: #7C1C1C; }
.banner.ok { background: var(--green-bg); color: var(--green); }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); }
.k { font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; font-size: 13px; }
.kv .full { grid-column: 1 / -1; }

.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.s-booked { background: var(--grey-bg); color: #3A3D42; }
.s-received { background: var(--blue-bg); color: var(--blue); }
.s-in_progress { background: var(--amber-bg); color: var(--amber); }
.s-waiting_parts { background: var(--red-bg); color: #922020; }
.s-ready { background: var(--green-bg); color: var(--green); }
.s-delivered { background: #EDEDED; color: #45484D; }
.s-cancelled { background: #EDEDED; color: #8A8D92; text-decoration: line-through; }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line2); font-size: 13px; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
.tablebox { overflow-x: auto; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #FAFAF7; }

/* ---------- board ---------- */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: #EBE9E3; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.kcol > .h { display: flex; justify-content: space-between; align-items: center; }
.jcard { display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; text-decoration: none; color: var(--ink); }
.jcard:hover { border-color: var(--pri); color: var(--ink); }
.jcard .t { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.jcard .n { font-weight: 600; margin-top: 3px; }
.jcard .b { font-size: 13px; color: var(--ink2); }
.jcard .w { font-size: 12px; margin-top: 5px; color: var(--pri); font-weight: 500; }
.late { color: var(--red) !important; font-weight: 600; }
.mchips { display: none; }
.loadbar { height: 10px; border-radius: 5px; background: #ECEAE4; overflow: hidden; margin-top: 8px; }
.loadbar > div { height: 100%; }

/* ---------- calendar ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.day { background: #EBE9E3; border-radius: 12px; padding: 9px; display: flex; flex-direction: column; gap: 7px; min-height: 380px; }
.day.today { outline: 2px solid var(--pri); }
.day.closed { background: #E2E0DA; opacity: .75; }
.day .dh { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; }
.bk { display: block; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 12px; }
.bk:hover { border-color: var(--pri); color: var(--ink); }
.bk .n { font-weight: 600; font-size: 13px; }

/* ---------- new job / job card ---------- */
.step { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; margin: 0 0 12px; }
.stepnum { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid #D8D5CD; border-radius: 10px; padding: 11px 12px; cursor: pointer; background: #fff; text-align: left; font: inherit; color: inherit; }
.opt.sel { border: 2px solid var(--pri); background: var(--pri-l); padding: 10px 11px; }
.opt .t { font-weight: 600; display: block; }
.opt .s { font-size: 13px; color: #4A4E54; display: block; }
.pgrid th, .pgrid td { padding: 6px 5px; border: 0; }
.pcell { width: 100%; min-height: 40px; border: 1px solid #DAD7CF; border-radius: 7px; background: #fff; font: 13px inherit; font-family: inherit; cursor: pointer; }
.pcell.mine { border-color: #9DBFAE; background: var(--pri-l); }
.pcell.sel { background: var(--pri); border-color: var(--pri); color: #fff; font-weight: 600; }
.lines .ln { display: grid; grid-template-columns: 26px minmax(0, 1fr) 70px 96px 36px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line2); }
.lines .ln.nochk { grid-template-columns: minmax(0, 1fr) 70px 96px 36px; }
.lines .ln input[type=number] { min-height: 36px; padding: 0 6px; border: 1px solid #D1CEC6; border-radius: 6px; width: 100%; font: 13px inherit; font-family: inherit; text-align: right; }
.lines .ln input[type=checkbox] { width: 20px; height: 20px; }
.x { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); min-height: 36px; }
.x:hover { color: var(--red); }
.tot { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.tot.big { font-weight: 700; font-size: 18px; border-top: 1px solid var(--line); padding-top: 9px; margin-top: 4px; }
.steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.stepbtn { min-height: 56px; border-radius: 8px; padding: 7px 8px; text-align: left; font: inherit; cursor: pointer; background: #fff; border: 1px dashed #C9C6BD; color: var(--muted); }
.stepbtn b { display: block; font-size: 13px; }
.stepbtn span { display: block; font-size: 11px; margin-top: 2px; }
.stepbtn.done { background: #E3EFE8; border: 1px solid #B9D5C5; color: var(--pri-d); }
.stepbtn.cur { background: var(--ink); border: 1px solid var(--ink); color: #fff; }
.timeline { display: flex; flex-direction: column; gap: 10px; font-size: 13px; line-height: 1.5; }
.timeline .it { white-space: pre-wrap; }
.searchlist { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; }
.searchlist button { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line2); background: #fff; padding: 10px 12px; font: 13px inherit; font-family: inherit; cursor: pointer; min-height: 42px; }
.searchlist button:hover { background: var(--pri-l); }

/* ---------- lists ---------- */
.item { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line2); }
.item:last-child { border-bottom: 0; }
.item .who2 { flex: 1 1 240px; min-width: 0; }
.item .acts { display: flex; flex-wrap: wrap; gap: 6px; }
.bubble { background: #E3F3E8; border-radius: 12px 12px 12px 4px; padding: 11px 13px; font-size: 13px; line-height: 1.55; white-space: pre-line; }

/* ---------- stats ---------- */
.bars { display: grid; gap: 6px; align-items: end; height: 220px; border-bottom: 1px solid #D9D6CE; }
.bars > div { display: flex; flex-direction: column-reverse; height: 100%; }
.barlbl { display: grid; gap: 6px; margin-top: 6px; }
.barlbl div { text-align: center; font-size: 11px; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.delta-up { color: var(--green); } .delta-dn { color: var(--red); }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20, 24, 22, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 14px 14px; overflow-y: auto; }
.modal .box { width: 100%; max-width: 520px; background: #fff; border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.modal .box.wide { max-width: 720px; }
.toast { position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; max-width: 92vw; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.toast.bad { background: #8E1F1F; }
.spinner { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- print ---------- */
.print-only { display: none; }
@media print {
  body { background: #fff; }
  #app, #modal, #toast, #login { display: none !important; }
  .print-only { display: block; font-size: 12pt; color: #000; }
  .print-only table td, .print-only table th { border-bottom: 1px solid #999; font-size: 11pt; padding: 5px 6px; }
  @page { margin: 12mm; }
}

/* ---------- phone ---------- */
@media (max-width: 760px) {
  .top { padding: 10px 14px; gap: 6px 12px; }
  .topnav, #whoName { display: none; }
  .who { gap: 10px; }
  main { padding: 14px 14px 96px; }
  h1 { font-size: 22px; }
  .panel { padding: 14px; }
  .botnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .botnav a, .botnav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 58px; text-decoration: none; color: var(--muted); font: 600 11px inherit; font-family: inherit; background: none; border: 0; cursor: pointer; }
  .botnav a.on { color: var(--pri); }
  .botnav a.plus { color: #fff; background: var(--pri); margin: 6px; border-radius: 12px; min-height: 46px; font-size: 13px; }
  .kanban { display: flex; flex-direction: column; overflow: visible; }
  .kcol { background: none; padding: 0; min-height: 0; }
  .kanban.f .kcol.off { display: none; }
  .mchips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  .mchips .chip { flex: none; }
  .week { display: flex; flex-direction: column; overflow: visible; }
  .day { min-height: 0; }
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .lines .ln { grid-template-columns: 26px minmax(0, 1fr) 54px 80px 30px; gap: 6px; }
  .lines .ln.nochk { grid-template-columns: minmax(0, 1fr) 54px 80px 30px; }
  .btn { min-height: 46px; }
  .hide-m { display: none !important; }
  .toast { bottom: 80px; }
}
@media (min-width: 761px) { .show-m { display: none !important; } }
