/* Rally web — the printed surfaces and the counters behind them.

   Three things live here, and they share a look on purpose: a prescription
   pad, a pharmacy bill, and the back office that produces them. All three end
   up on paper, so all three are laid out as a sheet with a letterhead rather
   than as app chrome.

   Everything is themed off app.css's variables, plus a small ink palette of
   its own: --ink is the navy a clinic letterhead is printed in, and it stays
   navy in dark mode because the sheet itself stays white. */

:root {
  --ink: #16265c;
  --ink-2: #2f4b9b;
  --ink-soft: #eef2fb;
  --ink-line: #d7deef;
  --rupee: #0f7a4d;
  --warn-bg: #fff4e5;
  --warn-fg: #a35a00;
  --shop: #6d4aff;
  --shop-soft: #f1edff;
}

[data-theme="dark"] {
  --ink-soft: #141a2e;
  --ink-line: #26304d;
  --warn-bg: #2a1f0d;
  --warn-fg: #e0a24a;
  --shop-soft: #1a1630;
}

/* ---------------------------------------------------------------- the sheet */

/* A pad and a bill are both "a sheet of paper with a heading on it", so they
   share the shell and differ only in what goes inside. */
.sheet {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 3px solid var(--ink);
}

.sheet-head h1 {
  margin: 0;
  font-size: 21px;
  color: var(--ink);
  letter-spacing: -.4px;
}

.sheet-head .years { color: var(--ink-2); font-weight: 600; font-size: 12px; }
.sheet-head .disc { font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; }
.sheet-head .where { color: var(--muted); font-size: 12px; margin: 2px 0 0; }
.sheet-head .phone {
  display: inline-block; margin-top: 6px; padding: 2px 8px;
  border: 1px solid var(--ink-line); border-radius: 6px;
  font-size: 12px; color: var(--ink);
}

.sheet-head .brand { margin-left: auto; text-align: right; }
.sheet-head .brand b { color: var(--ink-2); font-size: 13px; }
.sheet-head .brand small { display: block; color: var(--muted); font-size: 11px; }

.sheet-mark {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--ink-soft); color: var(--ink);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700;
  flex: none;
}
.sheet-mark img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* The facts strip: patient, sex, blood group, complaint, time. A definition
   list rather than a table, because it is genuinely label-and-value pairs and
   it has to wrap on a phone. */
.sheet-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  padding: 12px 22px;
  background: var(--ink-soft);
  border-bottom: 1px solid var(--ink-line);
}
.sheet-facts div { min-width: 0; }
.sheet-facts dt {
  font-size: 10px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--ink-2); font-weight: 600; margin: 0;
}
.sheet-facts dd { margin: 1px 0 0; font-weight: 600; font-size: 14px; }

.sheet-body { padding: 18px 22px 22px; }

/* A titled block inside the sheet, with the rule running off to the right. */
.pad-section { margin-top: 22px; }
.pad-section:first-child { margin-top: 0; }
.pad-section > h2 {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 12px;
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--ink); font-weight: 700;
}
.pad-section > h2::after {
  content: ""; flex: 1; height: 1px; background: var(--ink-line);
}
.pad-section > h2 .sub {
  font-size: 11px; letter-spacing: 0; text-transform: none;
  color: var(--muted); font-weight: 500;
}

.pad-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) { .pad-grid { grid-template-columns: 1fr; } }

.pad-field label {
  display: block; margin-bottom: 5px;
  font-size: 12.5px; font-weight: 600;
}
.pad-field input, .pad-field textarea, .pad-field select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--divider); border-radius: 9px;
  background: var(--surface); color: var(--fg); font: inherit;
}
.pad-field textarea { resize: vertical; min-height: 78px; }
/* The diagnosis: the one field on the sheet everything else hangs off, so it
   reads a size up from the rest of them. */
.pad-field input.pad-lead { font-size: 16px; font-weight: 600; padding: 12px 14px; }
.pad-field input:focus, .pad-field textarea:focus, .pad-field select:focus {
  outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--ink-soft);
}

/* ------------------------------------------------------------- medicine rows */

/* One prescribed line. Numbered down the left because a doctor reads a pad as
   an ordered list, and because "drop line 3" is unambiguous. */
.pad-med {
  position: relative;
  border: 1px solid var(--ink-line);
  border-radius: 12px;
  background: var(--ink-soft);
  padding: 14px 46px 14px 52px;
  margin-bottom: 10px;
}
.pad-med .n {
  position: absolute; left: 14px; top: 14px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.pad-med .drop {
  position: absolute; right: 10px; top: 12px;
  width: 28px; height: 28px; border-radius: 8px;
  border: 0; background: transparent; color: var(--like);
  cursor: pointer; font-size: 17px; line-height: 1;
}
.pad-med .drop:hover { background: rgba(237, 73, 86, .12); }
.pad-med .row { display: grid; grid-template-columns: 2fr 90px 1fr; gap: 10px; }
.pad-med .row + .full { margin-top: 10px; }
@media (max-width: 620px) { .pad-med .row { grid-template-columns: 1fr; } }

.pad-add {
  display: block; width: 100%;
  padding: 12px; border: 1px dashed var(--ink-line); border-radius: 12px;
  background: transparent; color: var(--ink-2);
  font-weight: 600; cursor: pointer;
}
.pad-add:hover { background: var(--ink-soft); }

/* The lab-test chips under the medicines. */
.pad-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pad-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 8px 6px 12px; border-radius: 999px;
  background: var(--ink-soft); border: 1px solid var(--ink-line);
  color: var(--ink); font-size: 13px; font-weight: 600;
}
.pad-chip button {
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px;
}
.pad-chip.own { background: #eafaf1; border-color: #bfe6cf; color: var(--rupee); }
[data-theme="dark"] .pad-chip.own { background: #0f2418; border-color: #1f4a31; }

.pad-save {
  display: block; width: 100%; margin-top: 22px;
  padding: 14px; border: 0; border-radius: 11px;
  background: var(--blue); color: #fff;
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.pad-save:hover { background: var(--blue-press); }
.pad-save[disabled] { opacity: .55; cursor: not-allowed; }

/* -------------------------------------------------------------------- a bill */

.bill-head {
  background: var(--ink); color: #fff;
  padding: 20px 22px;
  display: flex; align-items: flex-start; gap: 16px;
}
.bill-head h1 { color: #fff; font-size: 20px; margin: 0; }
.bill-head small { color: rgba(255, 255, 255, .72); }
.bill-head .no { margin-left: auto; text-align: right; }
.bill-head .no b { display: block; font-size: 16px; }
.bill-tag {
  display: inline-block; margin-top: 8px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase; font-weight: 700;
}

.bill-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.bill-table th {
  text-align: left; padding: 10px 8px;
  font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--divider); font-weight: 600;
}
.bill-table td { padding: 12px 8px; border-bottom: 1px solid var(--divider); }
.bill-table th.num, .bill-table td.num { text-align: right; }
.bill-table tfoot td { border-bottom: 0; padding-top: 14px; }
.bill-table .total td { font-size: 19px; font-weight: 700; color: var(--ink); }
.bill-table .total td:first-child { font-size: 14px; }

.bill-verify {
  display: flex; align-items: center; gap: 16px;
  margin-top: 18px; padding: 14px;
  border: 1px dashed var(--ink-line); border-radius: 12px;
}
.bill-verify img, .bill-verify svg { width: 104px; height: 104px; flex: none; }
.bill-verify b { display: block; font-size: 13px; }
.bill-verify small { color: var(--muted); }
.bill-sign { margin-top: 26px; }
.bill-sign span {
  display: inline-block; min-width: 190px;
  border-top: 1px solid var(--divider); padding-top: 6px;
  font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted);
}

/* ------------------------------------------------------- the shop back office */

.shop-hero {
  background: linear-gradient(135deg, var(--shop), #9b6bff);
  color: #fff; border-radius: 14px; padding: 20px 22px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.shop-hero h2 { color: #fff; margin: 0 0 2px; font-size: 17px; }
.shop-hero p { margin: 0; color: rgba(255, 255, 255, .8); font-size: 13px; max-width: 52ch; }
.shop-hero .btn { margin-left: auto; background: #fff; color: var(--shop); border: 0; font-weight: 700; }

.tile-row {
  display: grid; gap: 12px; margin: 16px 0;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.tile {
  background: var(--surface); border: 1px solid var(--divider);
  border-radius: 12px; padding: 14px;
}
.tile .ic {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--ink-soft); color: var(--ink);
  display: grid; place-items: center; margin-bottom: 8px;
}
.tile b { display: block; font-size: 21px; letter-spacing: -.5px; }
.tile small { color: var(--muted); }
.tile.money b { color: var(--rupee); }
.tile.alert .ic { background: var(--warn-bg); color: var(--warn-fg); }

/* A low-stock line: the bar is how much of the alert threshold is left, so a
   nearly-empty shelf reads as nearly-empty at a glance. */
.stock-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--divider);
}
.stock-row:last-child { border-bottom: 0; }
.stock-row .name { flex: 1; min-width: 0; }
.stock-row .name b { display: block; }
.stock-row .bar {
  width: 120px; height: 6px; border-radius: 3px;
  background: var(--divider); overflow: hidden; flex: none;
}
.stock-row .bar i { display: block; height: 100%; background: var(--warn-fg); }
.stock-row .bar i.out { background: var(--like); }

/* The counter's line editor. Denser than the prescription pad: a chemist bills
   ten lines where a doctor writes three. */
.counter-line {
  display: grid;
  grid-template-columns: 1fr 78px 96px 96px 104px 34px;
  gap: 8px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--divider);
}
.counter-line:last-of-type { border-bottom: 0; }
.counter-line .cell-name b { display: block; }
.counter-line .cell-name small { color: var(--muted); }
.counter-line input { width: 100%; }
.counter-line .money { text-align: right; font-weight: 600; }
.counter-line .drop {
  border: 0; background: transparent; color: var(--like);
  font-size: 17px; cursor: pointer;
}
@media (max-width: 780px) {
  .counter-line { grid-template-columns: 1fr 1fr; }
  .counter-line .money { text-align: left; }
}

.counter-totals {
  margin-top: 14px; padding: 14px;
  border: 1px solid var(--divider); border-radius: 12px;
  background: var(--surface-2);
}
.counter-totals .line { display: flex; justify-content: space-between; padding: 5px 0; }
.counter-totals .line.grand {
  border-top: 1px solid var(--divider); margin-top: 6px; padding-top: 10px;
  font-size: 18px; font-weight: 700; color: var(--ink);
}

/* Search results while billing: a dropdown of shelf lines under the box. */
.shelf-hits {
  border: 1px solid var(--divider); border-radius: 10px;
  margin-top: 6px; max-height: 260px; overflow: auto;
  background: var(--surface);
}
.shelf-hits button {
  display: flex; width: 100%; gap: 10px; align-items: center;
  padding: 9px 12px; border: 0; border-bottom: 1px solid var(--divider);
  background: transparent; text-align: left; cursor: pointer;
}
.shelf-hits button:last-child { border-bottom: 0; }
.shelf-hits button:hover, .shelf-hits button.on { background: var(--ink-soft); }
.shelf-hits .price { margin-left: auto; font-weight: 600; }
.shelf-hits .none { padding: 10px 12px; color: var(--muted); }

/* --------------------------------------------------------------- homecare */

.staff-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
}
.staff-card {
  display: flex; gap: 12px; padding: 14px;
  border: 1px solid var(--divider); border-radius: 12px; background: var(--surface);
}
.staff-card.retired { opacity: .55; }
.staff-card .av { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; }
.staff-card .ph {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  background: var(--ink-soft); color: var(--ink);
  display: grid; place-items: center; font-weight: 700;
}
.staff-card .body { min-width: 0; flex: 1; }
.staff-card h3 { margin: 0; font-size: 15px; }
.staff-card .job { color: var(--ink-2); font-size: 12px; font-weight: 600; }
.staff-card ul { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12.5px; color: var(--muted); }
.staff-card ul li { display: flex; gap: 6px; padding: 1px 0; }

/* ------------------------------------------------------------------- print */

/* Paper has no sidebar, no tab bar and no buttons. The sheet is the page. */
@media print {
  .topbar, .sidebar, .tabbar, .toast, .no-print, .skip { display: none !important; }
  body { background: #fff; color: #000; }
  main { margin: 0 !important; padding: 0 !important; max-width: none !important; }
  .page, .narrow { max-width: none !important; margin: 0 !important; padding: 0 !important; }

  .sheet {
    border: 0; border-radius: 0; box-shadow: none;
    page-break-inside: avoid;
  }
  .sheet-head { border-bottom: 3px solid #16265c; }
  .sheet-facts { background: #f4f6fc !important; }
  .bill-head { background: #16265c !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pad-med { background: #f4f6fc !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  a[href]::after { content: ""; }
  @page { margin: 12mm; }
}
