/* ============================================================
   Diabetes Care — theme
   Deep petrol green + soft mint, designed as a phone app first.
   ============================================================ */

:root {
  --ink:        #11302E;
  --teal:       #0E5E58;
  --teal-dark:  #0A4540;
  --mint:       #EFF6F4;
  --card:       #FFFFFF;
  --line:       #DCE9E6;
  --ok:         #16803C;
  --ok-bg:      #E3F4E8;
  --warn:       #B45309;
  --warn-bg:    #FDF0DC;
  --bad:        #B91C1C;
  --bad-bg:     #FBE4E4;
  --low:        #4338CA;
  --low-bg:     #E7E7FB;
  --muted:      #5E7672;
  --radius:     16px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--mint);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
}

h1, h2, h3, .stat-value { font-family: 'Fraunces', Georgia, serif; }
h1 { font-size: 1.45rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 600; }

.container-app { max-width: 760px; margin: 0 auto; padding: 0 14px; }
.pb-nav { padding-bottom: 92px; padding-top: 8px; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--teal);
  color: #fff;
  padding: 12px 0;
  position: sticky; top: 0; z-index: 1020;
}
.topbar .brand {
  color: #fff; text-decoration: none;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700; font-size: 1.1rem; letter-spacing: .2px;
}
.brand-drop { color: #7FD8C7; }
.topdate { font-size: .78rem; opacity: .85; }

/* ---------- Cards ---------- */
.card-x {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 14px;
}
.card-x .card-title-x {
  font-size: .78rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}

/* ---------- Dashboard stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.stat .label { font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.stat .stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.15; margin-top: 2px; }
.stat .unit { font-size: .8rem; font-family: 'Inter', sans-serif; font-weight: 500; color: var(--muted); }
.stat .when { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.stat.tone-ok   { border-left: 5px solid var(--ok); }
.stat.tone-warn { border-left: 5px solid var(--warn); }
.stat.tone-bad  { border-left: 5px solid var(--bad); }
.stat.tone-low  { border-left: 5px solid var(--low); }
.stat.tone-none { border-left: 5px solid var(--line); }

/* ---------- Badges ---------- */
.badge-x { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .72rem; font-weight: 600; }
.badge-ok   { background: var(--ok-bg);   color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad  { background: var(--bad-bg);  color: var(--bad); }
.badge-low  { background: var(--low-bg);  color: var(--low); }
.badge-type { background: #E4EFED; color: var(--teal-dark); }

.delta { font-size: .78rem; font-weight: 600; }
.delta.good { color: var(--ok); }
.delta.poor { color: var(--bad); }
.delta.neutral { color: var(--muted); }

/* ---------- Forms & buttons ---------- */
.btn-teal { background: var(--teal); color: #fff; border: none; }
.btn-teal:hover, .btn-teal:focus { background: var(--teal-dark); color: #fff; }
.btn-outline-teal { border: 1.5px solid var(--teal); color: var(--teal); background: #fff; }
.btn-outline-teal:hover { background: var(--teal); color: #fff; }
.form-control, .form-select { border-radius: 12px; border-color: var(--line); padding: .55rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--teal); box-shadow: 0 0 0 .2rem rgba(14,94,88,.12); }
label.form-label { font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }

.seg { display: flex; gap: 6px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  flex: 1; text-align: center; padding: 9px 4px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; font-weight: 600;
  font-size: .85rem; cursor: pointer; color: var(--muted);
}
.seg input:checked + label { background: var(--teal); border-color: var(--teal); color: #fff; }

.bignum { font-size: 1.6rem; font-weight: 700; text-align: center; }

/* ---------- Lists ---------- */
.row-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line);
}
.row-item:last-child { border-bottom: none; }
.row-item .main { min-width: 0; }
.row-item .val { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.row-item .sub { font-size: .75rem; color: var(--muted); }
.icon-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 4px 8px; font-size: .95rem; text-decoration: none;
}
.icon-btn:hover { color: var(--bad); }
a.icon-btn:hover { color: var(--teal); }

/* ---------- Tables ---------- */
.table-x { width: 100%; font-size: .85rem; }
.table-x th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table-x td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-x tr:last-child td { border-bottom: none; }

/* ---------- Bottom navigation ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav a {
  flex: 1; text-align: center; text-decoration: none;
  color: var(--muted); font-size: .68rem; font-weight: 600;
  padding: 4px 0; border-radius: 12px;
}
.bottomnav a svg { display: block; margin: 0 auto 2px; width: 22px; height: 22px; }
.bottomnav a.active { color: var(--teal); background: var(--mint); }

/* ---------- Misc ---------- */
.alert-due {
  background: var(--warn-bg); border: 1px solid #F2D6AC; color: var(--warn);
  border-radius: var(--radius); padding: 12px 14px; margin-top: 14px; font-size: .88rem;
}
.med-chip {
  display: inline-block; background: #E4EFED; color: var(--teal-dark);
  border-radius: 10px; padding: 6px 10px; font-size: .78rem; font-weight: 600;
  margin: 3px 4px 3px 0;
}
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.quick-actions a {
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius);
  text-align: center; padding: 12px 6px; text-decoration: none;
  color: var(--teal-dark); font-weight: 600; font-size: .8rem;
}
.quick-actions a:active { background: var(--mint); }
.quick-actions .qa-icon { font-size: 1.2rem; display: block; }

.chart-wrap { position: relative; height: 260px; }
.muted { color: var(--muted); }
.small-note { font-size: .76rem; color: var(--muted); }

/* ---------- Login ---------- */
.login-wrap { min-height: 88vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; }
.login-logo { width: 72px; height: 72px; border-radius: 20px; display: block; margin: 0 auto 14px; }

/* ---------- Print (doctor report) ---------- */
@media print {
  .topbar, .bottomnav, .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .card-x { border: 1px solid #999; break-inside: avoid; }
  .pb-nav { padding-bottom: 0; }
}

@media (min-width: 600px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .chart-wrap { height: 320px; }
}

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

/* Report table status cells */
.cell-ok   { color: var(--ok,  #1a7f4e); font-weight: 600; }
.cell-warn { color: var(--warn,#b07a00); font-weight: 600; }
.cell-bad  { color: var(--bad, #c0392b); font-weight: 700; }
.cell-low  { color: var(--low, #7048b5); font-weight: 600; }

/* PDF auto-filled inputs */
input.autofilled {
  border-color: var(--brand, #0E5E58);
  background: #F0FAF7;
  box-shadow: 0 0 0 3px rgba(14, 94, 88, .12);
}
