/* Kaur Tailoring — Order system. Phone-first, big touch targets. */
:root {
  --bg: #FBF7F0;
  --card: #FFFFFF;
  --line: #E6DCD0;
  --ink: #2A2220;
  --muted: #5E5450;
  --brand: #7A1F2B;
  --brand-dark: #561520;
  --brand-soft: #F4E4E2;
  --ok: #165236;
  --ok-bg: #E3F1E8;
  --ok-solid: #1E6B47;
  --warn: #7A4A06;
  --warn-bg: #FBEFD9;
  --late: #8A2A12;
  --late-bg: #FBE3DC;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(42, 34, 32, .06), 0 4px 14px rgba(42, 34, 32, .05);
  --font: 'DM Sans', 'Noto Sans Gurmukhi', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(110px + var(--safe-b)); }
.boot { padding: 40px 20px; color: var(--muted); text-align: center; }

h1, h2, h3 { margin: 0; line-height: 1.2; }
.en { color: var(--muted); font-weight: 500; font-size: .82em; }
.pa { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 10px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 24px; flex: 1; min-width: 0; }
.topbar h1 .en { font-size: 15px; margin-left: 6px; }
.palang {
  flex: 0 0 auto; min-height: 48px; padding: 0 10px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.palang[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.login .palang { align-self: flex-end; }
.brandline { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); font-weight: 700; }

.iconbtn {
  width: 48px; height: 48px; flex: 0 0 48px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); text-decoration: none; cursor: pointer; padding: 0;
}
.iconbtn svg { width: 24px; height: 24px; }

/* ---------- Generic layout ---------- */
.section { padding: 14px 16px; }
.section > h2 { font-size: 19px; margin-bottom: 10px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px;
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* ---------- Buttons ---------- */
.btn {
  min-height: 52px; padding: 10px 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; font-weight: 700; font-size: 17px;
  text-decoration: none; cursor: pointer; text-align: center;
}
.btn svg { width: 22px; height: 22px; flex: 0 0 auto; }
.btn .en { color: inherit; opacity: .85; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-dark); }
.btn.ok { background: var(--ok-solid); border-color: var(--ok-solid); color: #fff; }
.btn.soft { background: var(--brand-soft); border-color: var(--brand-soft); color: var(--brand-dark); }
.btn.danger { color: var(--late); border-color: #E7B9AC; }
.btn.block { width: 100%; }
.btn.big { min-height: 64px; font-size: 19px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.linkbtn { background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; color: var(--brand); font: inherit; font-weight: 700; padding: 8px 14px; cursor: pointer; min-height: 44px; }

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + var(--safe-b));
}
.bottombar > * { max-width: 608px; margin: 0 auto; }

/* ---------- Forms ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
label.field .en { font-weight: 500; }
input, textarea, select {
  font: inherit; font-size: 18px; color: var(--ink);
  width: 100%; min-height: 52px; padding: 12px 14px;
  border-radius: 12px; border: 1.5px solid #D2C6B8; background: #fff;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus, .btn:focus-visible, .iconbtn:focus-visible, .chip:focus-visible, a:focus-visible {
  outline: 3px solid #C58A2B; outline-offset: 2px;
}
.hint { font-size: 14px; color: var(--muted); font-weight: 400; }
.money { position: relative; }
.money::before { content: '$'; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money input { padding-left: 28px; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1.5px solid #D2C6B8; border-radius: 14px; padding: 0 12px;
}
.search svg { width: 22px; height: 22px; color: var(--muted); flex: 0 0 auto; }
.search input { border: 0; padding-left: 0; min-height: 54px; }
.search input:focus { outline: none; }
.search:focus-within { outline: 3px solid #C58A2B; outline-offset: 2px; }

/* ---------- Tabs / chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 46px; padding: 0 16px; border-radius: 23px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 700; font-size: 16px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .count { font-size: 13px; background: var(--bg); border-radius: 10px; padding: 1px 7px; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip[aria-pressed="true"] .count { background: rgba(255,255,255,.2); color: #fff; }
.chip[aria-pressed="true"] .en { color: #fff; }
.chipgrid { display: flex; flex-wrap: wrap; gap: 8px; }
.chipgrid .chip { flex: 0 0 auto; }
.gcards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.chip.gcard { flex: none; flex-direction: column; justify-content: center; gap: 2px; min-height: 108px; padding: 8px 4px; border-radius: 14px; font-size: 15px; line-height: 1.2; text-align: center; }
.gcard .en { font-size: 12px; }
.gart { width: 44px; height: 44px; fill: currentColor; color: var(--brand); flex: 0 0 auto; }
.chip[aria-pressed="true"] .gart { color: #fff; }

/* ---------- Order cards (list) ---------- */
.list { display: flex; flex-direction: column; gap: 10px; padding: 4px 16px 16px; }
.ocard {
  display: grid; grid-template-columns: 64px 68px minmax(0, 1fr); gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; box-shadow: var(--shadow); color: inherit; text-decoration: none;
}
.tag {
  width: 64px; height: 68px; border-radius: 12px; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
}
.tag small { font-size: 11px; opacity: .9; margin-bottom: 3px; }
.tag b { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.thumb {
  width: 68px; height: 68px; border-radius: 12px; object-fit: cover; background: #EFE7DC;
  display: flex; align-items: center; justify-content: center; color: #A0938A;
}
.thumb svg { width: 26px; height: 26px; }
.ocard .name { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ocard .meta { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 4px;
  height: 26px; padding: 0 10px; border-radius: 13px; font-size: 13px; font-weight: 700; white-space: nowrap;
}
.pill svg { width: 14px; height: 14px; }
.pill.ready { background: var(--ok-bg); color: var(--ok); }
.pill.open { background: var(--warn-bg); color: var(--warn); }
.pill.late { background: var(--late-bg); color: var(--late); }
.pill.collected { background: #ECE8E4; color: #4A423E; }
.pill.cancelled { background: #ECE8E4; color: #4A423E; text-decoration: line-through; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ---------- Order detail ---------- */
.bigtag {
  margin: 14px 16px 0; border-radius: 20px; color: #fff; padding: 16px 18px;
  display: flex; align-items: center; gap: 16px;
}
.bigtag .num { font-size: 64px; font-weight: 700; line-height: .95; letter-spacing: -.03em; }
.bigtag .num small { display: block; font-size: 14px; font-weight: 600; letter-spacing: 0; opacity: .9; margin-bottom: 4px; }
.bigtag .status { font-size: 20px; font-weight: 700; }
.bigtag .sub { font-size: 15px; opacity: .92; }
.cust h2 { font-size: 22px; }
.actions3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.actions3 .btn { flex-direction: column; gap: 2px; font-size: 15px; min-height: 64px; padding: 8px 4px; }
.actions3 .btn .en { font-size: 12px; }

.item { padding: 0; overflow: hidden; }
.item .photos { display: flex; gap: 6px; overflow-x: auto; padding: 10px 10px 0; }
.item .photos img, .item .photos .thumb { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; flex: 0 0 auto; cursor: zoom-in; border: 0; padding: 0; }
.item .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.item .title { font-size: 18px; font-weight: 700; }
.item.is-ready { border-color: #9CCBB0; }
.measure { width: 100%; border-collapse: collapse; font-size: 17px; }
.measure th, .measure td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); font-weight: 600; }
.measure td { text-align: right; font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums; }
.measures { display: flex; flex-direction: column; gap: 10px; }
.forwho, .personhead { display: flex; align-items: center; gap: 6px; }
.forwho { background: var(--brand-soft); color: var(--brand-dark); border-radius: 10px; padding: 7px 10px; font-size: 16px; }
.forwho svg, .personhead svg { width: 18px; height: 18px; flex: 0 0 auto; }
.personhead { font-size: 18px; color: var(--brand-dark); }
.measure caption { text-align: left; font-weight: 700; padding: 6px 0 2px; }
/* Anything that opens more information must look like a button. */
details > summary {
  list-style: none; cursor: pointer; min-height: 52px; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--brand-soft);
  color: var(--brand-dark); font-weight: 700; font-size: 17px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: '▾'; font-size: 20px; }
details[open] > summary::after { content: '▴'; }
audio { width: 100%; height: 44px; }

.pay { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.pay div { background: var(--bg); border-radius: 12px; padding: 10px 4px; }
.pay b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.pay .due b { color: var(--late); }

.timeline { list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--muted); }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); }

/* ---------- Item editor ---------- */
.photogrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ph { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #EFE7DC; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph button {
  position: absolute; top: 4px; right: 4px; width: 40px; height: 40px; border-radius: 20px;
  border: 0; background: rgba(0,0,0,.6); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.ph button svg { width: 20px; height: 20px; }
.mgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mgrid label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 15px; }
.mgrid label .en { font-size: 12px; }
.mgrid input { text-align: center; font-size: 20px; font-weight: 700; }
.mart { display: block; width: 100%; height: 104px; padding: 4px; background: var(--bg); border-radius: 10px; color: var(--brand); }
.art-body { fill: #D8CCBE; }
.art-mark { fill: none; stroke: var(--brand); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.customrow { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 48px; gap: 8px; align-items: center; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; background: var(--card); }
legend { font-weight: 700; padding: 0 6px; font-size: 17px; }
.rec { display: flex; align-items: center; gap: 10px; }
.rec .dot { width: 12px; height: 12px; border-radius: 6px; background: #C0392B; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

.notice { border-radius: 14px; padding: 12px 14px; font-size: 15px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.info { background: var(--brand-soft); color: var(--brand-dark); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.match { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; width: 100%; text-align: left; font: inherit; cursor: pointer; min-height: 56px; color: inherit; }
.match:hover { border-color: var(--brand); }

/* ---------- Login ---------- */
.login { padding: 48px 20px; display: flex; flex-direction: column; gap: 16px; max-width: 420px; margin: 0 auto; }
.login h1 { font-size: 30px; }

/* ---------- Toast + lightbox ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: #2A2220; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lightbox button { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; }

/* ---------- Print slip ---------- */
#print-slip { display: none; }
@media print {
  @page { margin: 10mm; }
  body { background: #fff; }
  #app, #toast, .bottombar { display: none !important; }
  #print-slip { display: block !important; font-family: var(--font); color: #000; }
  .slip { border: 2px dashed #000; padding: 16px; max-width: 80mm; margin: 0 auto 10mm; page-break-inside: avoid; }
  .slip .no { font-size: 64px; font-weight: 700; text-align: center; line-height: 1; margin: 8px 0; }
  .slip h3 { text-align: center; font-size: 16px; }
  .slip p { margin: 4px 0; font-size: 14px; }
  .slip .cut { text-align: center; font-size: 12px; margin-top: 8px; }
  .msheet { font-size: 13px; }
  .msheet header { display: flex; align-items: center; gap: 16px; border-bottom: 2px solid #000; padding-bottom: 8px; }
  .msheet header .no { font-size: 44px; font-weight: 700; line-height: 1; }
  .msheet h3 { font-size: 20px; }
  .msheet p { margin: 2px 0; }
  .msheet .mblock { margin-top: 12px; break-inside: avoid; page-break-inside: avoid; }
  .msheet h4 { margin: 0; font-size: 16px; }
  .msheet .mtables { columns: 2; column-gap: 20px; margin-top: 6px; }
  .msheet .measure { font-size: 13px; break-inside: avoid; margin-bottom: 8px; }
  .msheet .measure th, .msheet .measure td { padding: 3px 2px; border-bottom: 1px solid #999; font-size: 13px; }
  .msheet .measure caption { font-size: 14px; }
  .msheet .en { color: #000; }
  .msheet .mnotes { white-space: pre-line; border: 1px solid #999; padding: 6px; margin-top: 8px; }
  .msheet .mdate { font-size: 11px; margin-bottom: 8px; }
  .msheet .mpair { break-inside: avoid; }
}

@media (min-width: 560px) {
  .ocard { grid-template-columns: 72px 80px minmax(0, 1fr); }
  .tag { width: 72px; height: 80px; }
  .thumb { width: 80px; height: 80px; }
  .mgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
