:root {
  --navy: #14213d;
  --navy-2: #1d2f57;
  --orange: #f28c28;
  --orange-d: #d9741a;
  --bg: #eef1f7;
  --card: #fff;
  --text: #1c2333;
  --muted: #6b7489;
  --line: #dde2ec;
  --green: #1f9d55;
  --red: #d64545;
  --blue: #2f6fd6;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }

/* ---------- layout ---------- */
.side {
  position: fixed; inset: 0 auto 0 0; width: 220px; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; font-weight: 700; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--orange); display: grid; place-items: center; font-size: 20px; flex: none; }
.side nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.side nav a { display: flex; align-items: center; gap: 10px; color: #c9d1e3; padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; }
.side nav a i { font-style: normal; width: 20px; text-align: center; }
.side nav a:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.side nav a.on { background: var(--orange); color: #fff; }
.me { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.me b, .me small { display: block; }
.me small { color: #9aa6c0; margin-bottom: 6px; }
.me a { color: var(--orange); }
.main { margin-left: 220px; min-height: 100vh; }
.main.solo { margin-left: 0; }
.top { display: flex; align-items: center; gap: 12px; background: #fff; padding: 12px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top h1 { font-size: 18px; margin: 0; flex: 1; }
.top-r { color: var(--muted); font-size: 13px; }
.burger { display: none; border: 0; background: none; font-size: 22px; cursor: pointer; padding: 0 4px; }
.wrap { padding: 20px 22px; max-width: 1700px; }
.shade { display: none; }

@media (max-width: 900px) {
  .side { transform: translateX(-100%); transition: transform .2s; }
  body.menu .side { transform: none; }
  body.menu .shade { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
  .main { margin-left: 0; }
  .burger { display: block; }
  .wrap { padding: 14px 16px; }
  .top { padding: 10px 16px; }
  .top-r { display: none; }
}

/* ---------- pieces ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 2px rgba(20,33,61,.06); margin-bottom: 18px; border: 1px solid var(--line); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-h h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } .span2 { grid-column: auto; } }

.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; gap: 14px; align-items: center; }
.stat .ic { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; background: #e8ecf6; color: var(--navy); flex: none; }
.stat.o .ic { background: #fdeedd; color: var(--orange-d); }
.stat .n { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 12px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; background: var(--navy); color: #fff; padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--navy-2); text-decoration: none; }
.btn.o { background: var(--orange); }
.btn.o:hover { background: var(--orange-d); }
.btn.g { background: #fff; color: var(--navy); border-color: var(--line); }
.btn.g:hover { background: #f4f6fb; }
.btn.r { background: var(--red); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(242,140,40,.35); border-color: var(--orange); }
textarea { min-height: 70px; resize: vertical; }
.f { margin-bottom: 12px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filters > div { min-width: 140px; }
.filters input[type=search] { min-width: 220px; }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #f7f8fb; }
tr:hover td { background: #fafbfd; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; background: #f7f8fb; }
.empty { color: var(--muted); text-align: center; padding: 24px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #e8ecf6; color: var(--navy); white-space: nowrap; }
.badge.waiting { background: #fff4e5; color: #b4610d; }
.badge.with_doctor { background: #e3edff; color: var(--blue); }
.badge.done, .badge.paid { background: #e2f5ea; color: var(--green); }
.badge.cancelled, .badge.void, .badge.due { background: #fde8e8; color: var(--red); }
.badge.low { background: #fde8e8; color: var(--red); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: #e2f5ea; color: #13663a; border: 1px solid #bfe6cf; }
.flash.err { background: #fde8e8; color: #9b2c2c; border-color: #f5c2c2; }
.muted { color: var(--muted); }
.right { text-align: right; }
.token { font-size: 18px; font-weight: 800; color: var(--orange-d); }

/* lists become cards on phones: <table class="resp"> */
@media (max-width: 700px) {
  table.resp thead { display: none; }
  table.resp, table.resp tbody, table.resp tr, table.resp td { display: block; width: 100%; }
  table.resp tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; position: relative; }
  table.resp td { border: 0; padding: 3px 0; text-align: left; }
  table.resp td.num { text-align: left; }
  table.resp td:empty { display: none; }
  table.resp td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 12px; }
  table.resp td.token { position: absolute; right: 12px; top: 8px; width: auto; font-size: 22px; }
  table.resp td.right .btns, table.resp td.right { justify-content: flex-start !important; text-align: left; }
  table.resp tr:hover td { background: none; }
  table.resp tfoot { display: block; }
  table.resp tfoot tr { display: flex; flex-wrap: wrap; gap: 8px; }
  table.resp tfoot td { width: auto; }
}

/* bars chart */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars .b span.v { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bars .b div { width: 100%; max-width: 46px; background: var(--navy); border-radius: 6px 6px 0 0; min-height: 2px; }
.bars .b:last-child div { background: var(--orange); }
.bars .b small { font-size: 11px; color: var(--muted); }

/* item rows (prescription / bill) */
.items td { padding: 5px 6px; }
.items input, .items select { padding: 6px 8px; }
.items .x { border: 0; background: none; color: var(--red); font-size: 18px; cursor: pointer; }
.totals { margin-left: auto; max-width: 340px; }
.totals .tr { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 5px 0; }
.totals .tr input, .totals .tr select { width: 140px; text-align: right; }
.totals .grand { font-size: 18px; font-weight: 800; border-top: 2px solid var(--navy); padding-top: 8px; }

/* search picker */
.pick { position: relative; }
.pick-list { display: none; position: absolute; left: 0; right: 0; top: 100%; margin-top: 2px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(20,33,61,.15); z-index: 40; max-height: 280px; overflow-y: auto; min-width: 260px; }
.pick-it { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #f0f2f7; }
.pick-it:hover { background: #fdf3e8; }
.pick-it small { color: var(--muted); }

/* login */
.login { max-width: 380px; margin: 9vh auto; }
.login .brand2 { text-align: center; margin-bottom: 18px; }
.login .brand2 .logo { width: 54px; height: 54px; font-size: 34px; border-radius: 14px; background: var(--orange); color: #fff; display: inline-grid; place-items: center; }
.login .brand2 h1 { font-size: 20px; margin: 10px 0 0; }

/* print pages */
.paper { background: #fff; max-width: 800px; margin: 20px auto; padding: 28px 34px; border: 1px solid var(--line); }
.paper .ph { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--navy); padding-bottom: 12px; }
.paper .ph h1 { margin: 0; font-size: 22px; color: var(--navy); }
.paper .ph .doc { text-align: right; }
.paper .pinfo { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.paper .rxbody { display: grid; grid-template-columns: 200px 1fr; gap: 20px; padding-top: 14px; min-height: 480px; }
.paper .rxbody .lft { border-right: 1px solid var(--line); padding-right: 14px; font-size: 13px; }
.paper .rxsym { font-size: 30px; font-weight: 700; color: var(--navy); font-family: Georgia, serif; }
.paper .pf { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 8px; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.receipt { max-width: 80mm; margin: 20px auto; background: #fff; padding: 12px; font-size: 12px; border: 1px solid var(--line); }
.receipt h1 { font-size: 16px; text-align: center; margin: 0; }
.receipt .c { text-align: center; }
.receipt table th, .receipt table td { padding: 3px 2px; font-size: 12px; }
.receipt hr { border: 0; border-top: 1px dashed #999; }
.noprint { text-align: center; margin: 14px; }
@media (max-width: 700px) { .paper { padding: 16px; } .paper .rxbody { grid-template-columns: 1fr; } .paper .rxbody .lft { border-right: 0; padding-right: 0; } }
@media print {
  body { background: #fff; }
  .noprint, .side, .top, .shade { display: none !important; }
  .main { margin: 0; }
  .paper, .receipt { border: 0; margin: 0; max-width: none; }
  .paper { padding: 0; }
}
