/* Red and white, the colours of the SHAHI logo. All colours are set here. */
:root {
  --red: #c8141f;
  --red-dark: #9c0f18;
  --red-deep: #6e0a11;
  --red-soft: #fdecec;
  --red-line: #f2c1c3;
  --gold: #f4b400;
  --green: #17803d;
  --green-soft: #e5f4ea;
  --ink: #1d1a1a;
  --muted: #6a6262;
  --line: #ece4e4;
  --field: #d6cccc;
  --bg: #faf6f5;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(60, 10, 10, .05), 0 8px 20px -12px rgba(60, 10, 10, .25);
  --nav-h: 64px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--red-dark); text-decoration: none; }
h2 { font-size: 21px; margin: 4px 0 2px; letter-spacing: -.01em; }
h3 { font-size: 13px; margin: 22px 0 8px; text-transform: uppercase; letter-spacing: .08em; color: var(--red-dark); }
p { margin: 4px 0; }
.ic { flex: none; vertical-align: -0.18em; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.red { color: var(--red); }
.green { color: var(--green); }
.right { text-align: right; }
.pre { white-space: pre-line; }
:focus-visible { outline: 3px solid rgba(200, 20, 31, .45); outline-offset: 2px; }

/* layout */
header.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 12px;
  background: linear-gradient(120deg, var(--red-deep), var(--red) 85%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(110, 10, 17, .3);
}
header.top .title { flex: 1; font-weight: 700; font-size: 18px; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top .icon-btn { color: #fff; background: none; border: 0; padding: 8px; cursor: pointer; position: relative; line-height: 0; display: inline-flex; }
header.top .logo-sm { width: 34px; height: 34px; border-radius: 8px; background: #fff; object-fit: contain; }
main { max-width: 860px; margin: 0 auto; padding: 14px 14px calc(var(--nav-h) + 26px); }
nav.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px -10px rgba(60, 10, 10, .3);
}
nav.bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 12px; position: relative; }
nav.bottom a .ico { line-height: 0; }
nav.bottom a.on { color: var(--red); font-weight: 700; }
nav.bottom a.on::before { content: ""; position: absolute; top: 0; left: 50%; width: 40px; margin-left: -20px; height: 3px; border-radius: 0 0 3px 3px; background: var(--red); }
/* The middle "New bill" tab stands out: it is the main job of the app. */
nav.bottom a.main .ico { background: var(--red); color: #fff; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; margin-top: -22px; box-shadow: 0 6px 14px -4px rgba(200, 20, 31, .6); border: 3px solid #fff; }
nav.bottom a.main.on::before { display: none; }

/* cards, tiles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px; margin: 10px 0; box-shadow: var(--shadow); }
a.card { display: block; color: inherit; text-decoration: none; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row > .grow { flex: 1; min-width: 0; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 13px; color: inherit; display: block; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 24px; line-height: 1.2; color: var(--red-dark); letter-spacing: -.01em; }
.tile span { color: var(--muted); font-size: 14px; }
@media (min-width: 620px) { .tiles { grid-template-columns: repeat(4, 1fr); } }

.banner { border-radius: 14px; padding: 12px 13px; margin: 10px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.banner.ok { background: var(--green-soft); color: var(--green); font-weight: 600; }
.banner.warn { background: #fff6dc; color: #6b4d00; border: 1px solid #f1d98a; }
.banner.bad { background: var(--red-soft); color: var(--red); font-weight: 600; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 700; background: #f0eaea; color: #5b5252; white-space: nowrap; }
.tag.own { background: #fff3cc; color: #7a5600; }
.tag.cancelled, .tag.archived { background: var(--red-soft); color: var(--red); }
.tag.active { background: var(--green-soft); color: var(--green); }
.items { margin: 8px 0; padding: 0; list-style: none; }
.items li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.items li:last-child { border-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.loading { text-align: center; color: var(--muted); padding: 40px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 8px 16px; border-radius: 12px; border: 1px solid var(--red-dark);
  background: linear-gradient(180deg, #df2430, var(--red)); color: #fff;
  font: 600 15px system-ui; cursor: pointer; text-align: center; text-decoration: none;
  box-shadow: 0 1px 2px rgba(110, 10, 17, .3);
}
.btn:active, .chip:active, .qty button:active, .tile:active, .menu a:active, .menu button:active, nav.bottom a:active, .icon-btn:active, a.card:active { transform: scale(.96); filter: brightness(.9); }
/* A tap answers at once: no waiting for a double tap, no grey flash, and the tapped button shows that it is working. */
a, button, label, input, select, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button, .btn, .chip, .tile, nav.bottom a { -webkit-user-select: none; user-select: none; }
.busy { pointer-events: none; opacity: .75; }
.busy::after { content: ""; flex: none; display: inline-block; width: 14px; height: 14px; margin-left: 6px; vertical-align: -2px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn:disabled { opacity: .55; }
.btn.light { background: var(--card); color: var(--red-dark); border-color: var(--field); box-shadow: none; }
.btn.danger { background: var(--card); color: var(--red); border-color: var(--red-line); box-shadow: none; }
.btn.wa { background: linear-gradient(180deg, #2bd469, #1ea952); border-color: #168a42; }
.btn.big { width: 100%; min-height: 54px; font-size: 17px; }
.btn.sm { min-height: 44px; padding: 6px 14px; font-size: 14px; border-radius: 10px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btns .btn { flex: 1 1 auto; }

/* forms */
label.f { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--field); border-radius: 12px;
  font: 16px system-ui; background: #fff; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(200, 20, 31, .2); border-color: var(--red); }
input.pin { text-align: center; font-size: 24px; font-weight: 700; letter-spacing: .5em; padding-left: calc(12px + .5em); }
input.pin::placeholder { color: #cdbfbf; letter-spacing: .35em; font-weight: 400; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 16px; }
.check input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { padding: 8px 14px; border-radius: 22px; border: 1px solid var(--field); background: var(--card); color: var(--ink); font: 15px system-ui; cursor: pointer; min-height: 44px; }
.chip.on { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.tabs { display: flex; gap: 6px; margin: 4px 0 10px; background: #f1e8e8; padding: 4px; border-radius: 14px; }
.tabs a { flex: 1; text-align: center; padding: 9px 4px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 15px; }
.tabs a.on { background: var(--card); color: var(--red-dark); box-shadow: 0 1px 3px rgba(60, 10, 10, .15); }
.filters { display: flex; gap: 8px; margin: 8px 0; }
.filters > * { flex: 1; min-width: 0; }

/* quantity stepper */
.qty { display: flex; align-items: center; gap: 4px; flex: none; }
.qty button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--field); background: var(--card); font-size: 22px; color: var(--red-dark); cursor: pointer; }
.qty input { width: 58px; min-height: 44px; padding: 4px; text-align: center; font-weight: 700; }
.qty.has input { border-color: var(--red); background: var(--red-soft); }
.sticky-foot { position: sticky; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom)); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; box-shadow: 0 -2px 14px rgba(60, 10, 10, .14); margin-top: 12px; z-index: 3; }
.sticky-foot .total { font-size: 24px; font-weight: 800; color: var(--red-dark); }

/* product pictures */
.pic { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--red-soft); flex: none; border: 1px solid var(--line); }
.pic.big { width: 96px; height: 96px; }
.pic.none { display: grid; place-items: center; color: var(--red); }
.pic-slot { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pic-slot:last-child { border-bottom: 0; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }

/* product card: picture, name, packs with rates */
.product { display: flex; gap: 12px; align-items: flex-start; }
.product .grow { flex: 1; min-width: 0; }
.product .name { font-weight: 700; font-size: 17px; line-height: 1.25; }
.packs { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin-top: 6px; font-size: 15px; }
.packs .rate { font-weight: 700; }

/* new order: one row per pack */
.pick { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--line); }
.pick .grow { flex: 1; min-width: 0; }
.pick .pack { font-weight: 700; }
.pick .pic { width: 44px; height: 44px; border-radius: 10px; }
.chosen { display: flex; align-items: center; gap: 10px; background: var(--red-soft); border: 1px solid var(--red-line); border-radius: 14px; padding: 10px 12px; }
.chosen .grow { flex: 1; min-width: 0; }
.results { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--card); margin-top: 6px; box-shadow: var(--shadow); }
.results button { display: block; width: 100%; text-align: left; padding: 12px; background: none; border: 0; border-bottom: 1px solid var(--line); font: 16px system-ui; color: var(--ink); cursor: pointer; min-height: 48px; }
.results button:last-child { border-bottom: 0; }
.results button.add { color: var(--red-dark); font-weight: 600; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin: 10px 0; box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 9px 7px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { padding-left: 12px; }
th:last-child, td:last-child { padding-right: 12px; }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: #fbf5f5; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; }
td input { min-height: 42px; padding: 6px 10px; }

/* menu */
.menu { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin: 10px 0; box-shadow: var(--shadow); }
.menu a, .menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 13px; background: var(--card); border: 0; border-bottom: 1px solid var(--line); font: 16px system-ui; color: var(--ink); cursor: pointer; text-align: left; }
.menu > :last-child { border-bottom: 0; }
.menu .ico { width: 28px; line-height: 0; text-align: center; color: var(--red); }

/* sheet, toast */
.sheet { position: fixed; inset: 0; z-index: 20; display: none; }
.sheet.open { display: block; }
.sheet-back { position: absolute; inset: 0; background: rgba(40, 6, 8, .55); }
.sheet-box { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 20px 20px 0 0; border-top: 4px solid var(--red); padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); max-width: 620px; margin: 0 auto; }
.sheet-box h3 { margin-top: 0; padding-right: 40px; font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.sheet-x { position: absolute; top: 4px; right: 4px; border: 0; background: none; font-size: 30px; color: var(--muted); cursor: pointer; padding: 6px 16px; min-width: 48px; min-height: 48px; }
.toast { position: fixed; left: 50%; top: 66px; transform: translateX(-50%); z-index: 40; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 22px; font-size: 15px; max-width: 90vw; display: none; text-align: center; }
.toast.show { display: block; }
.toast.err { background: var(--red); }

/* login */
body.login-page { min-height: 100vh; background: radial-gradient(120% 80% at 50% 0%, #e2323d 0%, var(--red-dark) 50%, var(--red-deep) 100%); }
.login { max-width: 400px; margin: 0 auto; padding: 44px 18px; }
body.login-page .login { margin-top: 6vh; padding: 28px 22px; background: var(--card); border-radius: 22px; box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .6); }
@media (max-width: 440px) { body.login-page .login { margin-left: 14px; margin-right: 14px; } }
.login .logo { width: 170px; display: block; margin: 0 auto 10px; }
.login h1 { text-align: center; font-size: 22px; margin: 0 0 4px; color: var(--red-dark); }
.login p { text-align: center; }

/* the bill as it is shown and printed */
.bill { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); margin: 10px 0; }
.bill-head { background: var(--red); color: #fff; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.bill-head b { font-size: 20px; }
.bill-body { padding: 14px 16px; }
.bill-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.bill-to { margin: 12px 0; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.bill table td, .bill table th { padding: 7px 5px; white-space: normal; }
.bill .total-row td { font-size: 18px; font-weight: 800; color: var(--red-dark); border-top: 2px solid var(--ink); }
.bill-foot { text-align: center; font-weight: 700; color: var(--red); padding: 10px; border-top: 1px dashed var(--line); }
.stamp { border: 3px solid var(--red); color: var(--red); font-weight: 800; text-align: center; padding: 6px; border-radius: 10px; margin: 8px 0; letter-spacing: .1em; }

/* What the 2 inch thermal printer will print: 32 letters a line, like the paper. */
.receipt { font: 13px/1.35 ui-monospace, Consolas, "Courier New", monospace; width: 34ch; max-width: 100%; margin: 8px auto; padding: 12px 1ch; background: #fff; border: 1px dashed var(--field); border-radius: 6px; white-space: pre; overflow-x: auto; color: #000; }

/* Items hidden by a search or filter stay hidden, whatever their layout. */
[hidden] { display: none !important; }

@media (min-width: 900px) {
  .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Printing a bill: only the bill, no buttons, no header, no menu. */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; }
  header.top, nav.bottom, .no-print, .btns, .banner, .toast, .sheet { display: none !important; }
  main { padding: 0; max-width: none; }
  .bill { border: 0; box-shadow: none; border-radius: 0; }
  .bill-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
