/*
 * Design tokens + shared components.
 *
 * Sizes on the public pages are deliberately large: the buyer of a blood-pressure
 * monitor is usually 50+, often registering on a budget Android in a shop. Base
 * text is 18px, inputs 20px, and every tap target is at least 48px.
 *
 * Status colour is never decorative — green/amber/red mean in-warranty /
 * expiring / expired-or-void everywhere in the product.
 */

:root {
  --c-primary: #0e7c86;
  --c-primary-dark: #0a5d65;
  --c-primary-soft: #e6f4f5;
  --c-ok: #15803d;      --c-ok-bg: #ecfdf3;   --c-ok-line: #bbe7c9;
  --c-warn: #b45309;    --c-warn-bg: #fffbeb; --c-warn-line: #f3dfae;
  --c-bad: #b91c1c;     --c-bad-bg: #fef2f2;  --c-bad-line: #f3c1c1;
  --c-ink: #1f2937;
  --c-muted: #6b7280;
  --c-line: #e5e7eb;
  --c-bg: #f4f7f7;
  --c-card: #ffffff;

  --radius-card: 14px;
  --radius-input: 10px;
  --pad-card: 16px;
  --shadow-card: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 14px rgba(16, 24, 40, .06);

  --font: "Segoe UI", system-ui, -apple-system, "Noto Sans Myanmar", "Padauk",
          "Myanmar Text", sans-serif;
}

* { box-sizing: border-box; margin: 0; }

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-ink);
  font-size: 18px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------------- app bar */

.appbar {
  background: var(--c-primary);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.appbar .logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: #fff; color: var(--c-primary);
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px; flex-shrink: 0;
}
.appbar .titles { min-width: 0; }
.appbar .t { font-size: 15px; font-weight: 700; line-height: 1.25; }
.appbar .s { font-size: 12px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar .spacer { margin-left: auto; }

.langtoggle {
  background: none; color: #fff; font: inherit; font-size: 13px;
  border: 1px solid rgba(255, 255, 255, .6); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; min-height: 36px;
}
.langtoggle:hover { background: rgba(255, 255, 255, .12); }

/* ---------------------------------------------------------------- layout */

.wrap { max-width: 520px; margin: 0 auto; padding: 16px 14px 48px; }
.wrap.wide { max-width: 1180px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--c-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--pad-card);
}
.card.center { text-align: center; }

.muted { color: var(--c-muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.hidden { display: none !important; }
.mt { margin-top: 12px; }

/* ---------------------------------------------------------------- forms */

label { display: block; font-size: 15px; font-weight: 600; margin: 14px 0 6px; }
label .sub { color: var(--c-muted); font-weight: 500; }
label:first-child { margin-top: 0; }

input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 20px;
  color: var(--c-ink);
  background: #fff;
  border: 1.5px solid var(--c-line);
  border-radius: var(--radius-input);
  padding: 12px;
  min-height: 52px;
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--c-primary-soft);
  border-color: var(--c-primary);
}
input[aria-invalid="true"] { border-color: var(--c-bad); }

.fielderror { color: var(--c-bad); font-size: 14px; margin-top: 5px; }

.btn {
  display: block; width: 100%;
  background: var(--c-primary); color: #fff;
  font: inherit; font-size: 19px; font-weight: 700;
  border: 0; border-radius: 12px; padding: 15px;
  margin-top: 18px; cursor: pointer; min-height: 54px;
}
.btn:hover { background: var(--c-primary-dark); }
.btn[disabled] { opacity: .6; cursor: default; }
.btn.secondary { background: #fff; color: var(--c-primary); border: 1.5px solid var(--c-primary); }
.btn.secondary:hover { background: var(--c-primary-soft); }
.btn.inline { display: inline-block; width: auto; padding: 10px 18px; font-size: 16px; margin-top: 0; min-height: 44px; }

/* ---------------------------------------------------------------- status */

.shield {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--c-primary-soft);
  display: grid; place-items: center; margin: 0 auto 10px;
}
.bigicon {
  width: 68px; height: 68px; border-radius: 50%;
  display: grid; place-items: center; margin: 4px auto 12px;
}
.bigicon.ok { background: var(--c-ok-bg); }
.bigicon.bad { background: var(--c-bad-bg); }
.bigicon.warn { background: var(--c-warn-bg); }

.planpill {
  display: inline-block; background: var(--c-primary-soft); color: var(--c-primary-dark);
  font-size: 13px; font-weight: 700; border-radius: 999px; padding: 5px 14px; margin-top: 8px;
}

.hero-label { font-size: 13px; color: var(--c-muted); }
.hero-date { font-size: 34px; font-weight: 800; letter-spacing: -.5px; line-height: 1.15; }
.hero-date.ok { color: var(--c-ok); }
.hero-date.bad { color: var(--c-bad); }
.hero-date.warn { color: var(--c-warn); }

.kv { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 15px; text-align: left; }
.kv td { padding: 9px 0; border-top: 1px solid var(--c-line); }
.kv td:first-child { color: var(--c-muted); width: 42%; }
.kv td:last-child { font-weight: 600; text-align: right; word-break: break-word; }

.status {
  border-radius: var(--radius-card); padding: 15px 16px;
  font-weight: 700; font-size: 17px; border: 1px solid transparent;
}
.status .dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 9px; }
.status .sm { display: block; font-size: 14.5px; font-weight: 500; color: var(--c-ink); margin-top: 5px; }
.status.ok   { background: var(--c-ok-bg);   color: var(--c-ok);   border-color: var(--c-ok-line); }
.status.ok .dot { background: var(--c-ok); }
.status.warn { background: var(--c-warn-bg); color: var(--c-warn); border-color: var(--c-warn-line); }
.status.warn .dot { background: var(--c-warn); }
.status.bad  { background: var(--c-bad-bg);  color: var(--c-bad);  border-color: var(--c-bad-line); }
.status.bad .dot { background: var(--c-bad); }
.status.gray { background: #f3f4f6; color: var(--c-muted); border-color: var(--c-line); }
.status.gray .dot { background: #9ca3af; }

.chip { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 700; }
.chip.g { background: var(--c-ok-bg); color: var(--c-ok); }
.chip.a { background: var(--c-warn-bg); color: var(--c-warn); }
.chip.r { background: var(--c-bad-bg); color: var(--c-bad); }
.chip.n { background: #f3f4f6; color: var(--c-muted); }

/* ---------------------------------------------------------------- admin */

.admin { display: flex; min-height: 100vh; align-items: stretch; }
.nav {
  width: 190px; flex-shrink: 0;
  background: var(--c-primary-dark); color: #cfe9eb;
  padding: 16px 0; font-size: 15px;
}
.nav .brand { color: #fff; font-weight: 800; padding: 0 18px 16px; font-size: 16px; }
.nav button {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; color: inherit; font: inherit;
  padding: 11px 18px; cursor: pointer; border-left: 3px solid transparent;
}
.nav button:hover { background: rgba(255, 255, 255, .08); }
.nav button.on { background: var(--c-primary); color: #fff; font-weight: 700; border-left-color: #fff; }
.nav .who { padding: 14px 18px 0; font-size: 12.5px; opacity: .8; }

.main { flex: 1; padding: 20px; min-width: 0; background: var(--c-bg); }
.main h1 { font-size: 22px; margin-bottom: 4px; }
.main .lede { color: var(--c-muted); font-size: 14px; margin-bottom: 18px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: #fff; border-radius: 12px; box-shadow: var(--shadow-card); padding: 14px; }
.tile .n { font-size: 28px; font-weight: 800; line-height: 1.1; }
.tile .l { font-size: 12.5px; color: var(--c-muted); margin-top: 3px; }
.tile.ok .n { color: var(--c-ok); }
.tile.warn .n { color: var(--c-warn); }
.tile.bad .n { color: var(--c-bad); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; font-size: 15px; min-height: 44px; padding: 9px 11px; }

.fchip {
  display: inline-block; border: 1.5px solid var(--c-line); background: #fff;
  border-radius: 999px; padding: 8px 16px; font-size: 14.5px; color: var(--c-muted);
  cursor: pointer; font: inherit; min-height: 42px;
}
.fchip.on { background: var(--c-primary); border-color: var(--c-primary); color: #fff; font-weight: 700; }

.tablewrap { overflow-x: auto; background: #fff; border-radius: 12px; box-shadow: var(--shadow-card); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
  background: #fafafa; text-align: left; padding: 10px 12px;
  color: var(--c-muted); font-weight: 600; border-bottom: 1px solid var(--c-line); white-space: nowrap;
}
table.tbl td { padding: 10px 12px; border-bottom: 1px solid #f1f5f5; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tr.clickable:hover { background: #fafcfc; cursor: pointer; }
.empty { padding: 28px; text-align: center; color: var(--c-muted); }

.modalback {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: grid; place-items: center; padding: 16px; z-index: 50;
}
.modal { background: #fff; border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 20px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 19px; margin-bottom: 12px; }
.modal .row { display: flex; gap: 10px; margin-top: 18px; }
.modal .row .btn { margin-top: 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--c-ink); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 15px; box-shadow: var(--shadow-card); z-index: 100; max-width: 90vw;
}
.toast.bad { background: var(--c-bad); }
.toast.ok { background: var(--c-ok); }

/* ---------------------------------------------------------------- labels */

.labelsheet { background: #fff; padding: 8mm; }
.labelgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; }
.labelgrid.cols2 { grid-template-columns: repeat(2, 1fr); }
.labelgrid.cols4 { grid-template-columns: repeat(4, 1fr); }
.lbl {
  border: 1px dashed #9ca3af; border-radius: 4px; padding: 3mm;
  display: flex; gap: 3mm; align-items: center; break-inside: avoid;
}
.lbl .qr { flex-shrink: 0; }
.lbl .qr img, .lbl .qr canvas { display: block; width: 22mm; height: 22mm; }
.lbl .txt { font-size: 8pt; line-height: 1.45; min-width: 0; color: #000; }
.lbl .txt .model { font-weight: 700; font-size: 9pt; }
.lbl .txt .sn { font-weight: 700; font-family: "Consolas", monospace; }
.lbl .txt .code { color: #555; }

@media print {
  body { background: #fff; font-size: 12px; }
  .noprint, .appbar, .nav, .toolbar { display: none !important; }
  .main { padding: 0; background: #fff; }
  .labelsheet { padding: 0; }
  .card { box-shadow: none; border: 1px solid var(--c-line); }
  @page { margin: 8mm; }
}

@media (max-width: 760px) {
  .admin { flex-direction: column; }
  .nav { width: 100%; display: flex; flex-wrap: wrap; padding: 8px; gap: 4px; }
  .nav .brand { width: 100%; padding: 6px 10px 10px; }
  .nav button { width: auto; border-left: 0; border-bottom: 3px solid transparent; padding: 9px 13px; border-radius: 8px; }
  .nav button.on { border-left: 0; border-bottom-color: #fff; }
  .nav .who { width: 100%; }
}
