/* ============================================================
   styles.css — Παρακολούθηση Υγείας
   Mobile: bottom-nav + FAB.  Desktop: sidebar + wide content.
   Χρώμα = σημασία (εντός/οριακό/εκτός στόχου). Tabular αριθμοί.
   ============================================================ */

:root {
  --bg: #F6F8F9; --surface: #FFFFFF; --surface-2: #EDF1F3;
  --ink: #16202A; --muted: #5C6B78; --line: #E1E7EA;
  --accent: #0D7D74; --accent-ink: #FFFFFF;
  --ok: #1E8E5A; --ok-bg: #E4F2EA;
  --warn: #B7791F; --warn-bg: #FBF0DD;
  --bad: #C6413A; --bad-bg: #FBE7E5;
  --grid: #E7ECEE;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20,32,42,.06), 0 6px 18px rgba(20,32,42,.05);
  --tap: 46px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0F1519; --surface: #161E24; --surface-2: #1E272E;
  --ink: #E7EDF1; --muted: #93A2AE; --line: #263039;
  --accent: #33B3A6; --accent-ink: #06231F;
  --ok: #4BC98A; --ok-bg: #122A20; --warn: #E0A94A; --warn-bg: #2E2413;
  --bad: #E4776F; --bad-bg: #331A18; --grid: #223039;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 22px rgba(0,0,0,.28);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1519; --surface: #161E24; --surface-2: #1E272E;
    --ink: #E7EDF1; --muted: #93A2AE; --line: #263039;
    --accent: #33B3A6; --accent-ink: #06231F;
    --ok: #4BC98A; --ok-bg: #122A20; --warn: #E0A94A; --warn-bg: #2E2413;
    --bad: #E4776F; --bad-bg: #331A18; --grid: #223039;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 22px rgba(0,0,0,.28);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .mt { margin-top: 10px; }

/* ============================================================
   SHELL — mobile-first
   ============================================================ */
.layout { min-height: 100vh; min-height: 100dvh; }
.content { max-width: 560px; margin: 0 auto; padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
.sidebar { display: none; }
.only-mobile { display: revert; }

.appbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: max(env(safe-area-inset-top), 8px) 16px 8px;
}
.appbar__row { display: flex; align-items: center; gap: 10px; }
.appbar__title { font-size: 1.05rem; font-weight: 650; letter-spacing: -.01em; margin: 0; }
.appbar__title small { display: block; font-size: .72rem; font-weight: 500; color: var(--muted); }
.appbar__spacer { flex: 1; }

.iconbtn { width: var(--tap); height: var(--tap); display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; color: var(--ink); }
.iconbtn svg { width: 20px; height: 20px; }

main { padding: 14px 16px 8px; display: grid; gap: 14px; }
.section-label { font-size: .82rem; color: var(--muted); margin: 5px 2px 5px; }

/* Profile chips */
.profiles { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 2px; scrollbar-width: none; }
.profiles::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px 7px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: .9rem; white-space: nowrap; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.chip__avatar { width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: .78rem; font-weight: 700; }
.chip--add { padding: 7px 14px; color: var(--muted); }

/* Bottom nav (mobile) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-top: 1px solid var(--line); display: flex; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.tab { flex: 1; background: none; border: 0; color: var(--muted); display: grid; justify-items: center; gap: 3px; padding: 6px 0; font-size: .72rem; border-radius: 10px; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-selected="true"] { color: var(--accent); }

.fab { position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 31; width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); display: grid; place-items: center; }
.fab svg { width: 26px; height: 26px; }

/* ============================================================
   DESKTOP — sidebar layout
   ============================================================ */
@media (min-width: 900px) {
  .only-mobile { display: none !important; }
  .layout { display: grid; grid-template-columns: 264px minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column; gap: 14px;
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    padding: 20px 16px; border-right: 1px solid var(--line);
    background: var(--surface);
  }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; padding: 2px 6px 6px; }
  .brand__mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
  .brand__mark svg { width: 20px; height: 20px; }
  .sidebar__profiles { display: flex; flex-direction: column; gap: 6px; }
  .sidebar__profiles .chip { width: 100%; justify-content: flex-start; }
  .sidebar__profiles .chip--add { justify-content: center; }
  .sidebar__nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
  .navitem { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; padding: 11px 12px; border-radius: 11px; border: 0; background: transparent; color: var(--ink); font-size: .96rem; }
  .navitem svg { width: 20px; height: 20px; color: var(--muted); }
  .navitem:hover { background: var(--surface-2); }
  .navitem[aria-current="true"] { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--accent); font-weight: 600; }
  .navitem[aria-current="true"] svg { color: var(--accent); }
  .sidebar .js-add { margin-top: 2px; }
  .sidebar__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }

  .content { max-width: 1080px; margin: 0; padding: 0 0 40px; }
  main { padding: 26px 34px; gap: 18px; grid-template-columns: 1fr; }
  .view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  .view-head h2 { margin: 0; font-size: 1.4rem; letter-spacing: -.02em; }
}
@media (min-width: 1280px) {
  .content { max-width: 1240px; }
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dash-head h2 { margin: 0; font-size: 1.15rem; }

.range { display: inline-flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.range button { border: 0; background: transparent; color: var(--muted); font-size: .84rem; padding: 6px 12px; border-radius: 999px; }
.range button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.dash-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .dash-grid { grid-template-columns: repeat(auto-fit, minmax(380px, 560px)); justify-content: start; gap: 18px; } }

/* κάρτα κατηγορίας: header (τιμή+status) + stats + chart */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; position: relative; overflow: hidden; }
.card[data-band]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.card[data-band="ok"]::before { background: var(--ok); }
.card[data-band="warn"]::before { background: var(--warn); }
.card[data-band="bad"]::before { background: var(--bad); }

.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card__hleft { min-width: 0; }
.card__hright { margin-left: auto; text-align: right; flex-shrink: 0; }
.card__hright .card__time { margin-top: 4px; }
.card__name { font-weight: 600; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.card__ic { width: 18px; height: 18px; color: var(--muted); flex: 0 0 auto; }
.card__time { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.card__value { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.card__value b { font-size: 2.2rem; font-weight: 720; letter-spacing: -.02em; line-height: 1; }
.card__unit { font-size: .95rem; color: var(--muted); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: currentColor; }
.status--ok { color: var(--ok); background: var(--ok-bg); }
.status--warn { color: var(--warn); background: var(--warn-bg); }
.status--bad { color: var(--bad); background: var(--bad-bg); }
.status--na { color: var(--muted); background: var(--surface-2); }

.card__stats { display: flex; flex-wrap: wrap; gap: 18px; padding: 12px 0; margin-top: 8px; border-top: 1px dashed var(--line); }
.stat { font-size: .78rem; color: var(--muted); }
.stat b { display: block; color: var(--ink); font-size: 1.05rem; font-weight: 650; margin-top: 1px; }

/* ============================================================
   CHART
   ============================================================ */
.chartbox { margin-top: 4px; }
.chart-wrap { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart-grid { stroke: var(--grid); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-empty { color: var(--muted); font-size: .86rem; padding: 26px 6px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.chart-legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.chart-legend i, .chart-tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart-tip { position: absolute; top: 4px; transform: translateX(-50%); background: var(--ink); color: var(--bg); border-radius: 10px; padding: 7px 10px; font-size: .76rem; line-height: 1.5; pointer-events: none; white-space: nowrap; box-shadow: var(--shadow); z-index: 5; }
.chart-tip b { display: block; margin-bottom: 2px; font-size: .74rem; opacity: .85; }
.chart-tip span { display: block; }

/* ============================================================
   Panels / empty / buttons / list / forms / sheet / toast
   ============================================================ */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.panel h3 { margin: 0 0 8px; font-size: .95rem; }

.empty { text-align: center; color: var(--muted); padding: 40px 18px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.empty h2 { color: var(--ink); font-size: 1.05rem; margin: 0 0 6px; }
.empty p { margin: 0 0 14px; font-size: .9rem; }

.btn { min-height: var(--tap); padding: 0 16px; border-radius: 12px; font-size: .95rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: transparent; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.list { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.row__main { flex: 1; min-width: 0; }
.row__title { font-weight: 600; font-size: .95rem; }
.row__meta { font-size: .8rem; color: var(--muted); }
.row__val { font-weight: 700; font-size: 1.05rem; text-align: right; }
.dot { width: 9px; height: 9px; border-radius: 999px; flex: 0 0 auto; }
.dot--ok{background:var(--ok);} .dot--warn{background:var(--warn);} .dot--bad{background:var(--bad);} .dot--na{background:var(--muted);}

.field { margin-bottom: 12px; min-width: 0; }
.field > label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 5px; }
.input, select.input, textarea.input { width: 100%; min-width: 0; max-width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font-size: 1rem; font-family: inherit; }
textarea.input { min-height: 72px; resize: vertical; }
.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1 1 0; min-width: 0; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: .88rem; }
.seg button[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg)); font-weight: 600; }

.settings-group { display: grid; gap: 10px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row small { color: var(--muted); display: block; font-size: .8rem; }
.switch { position: relative; width: 46px; height: 28px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; transition: .18s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 999px; background: #fff; transition: .18s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--accent); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(18px); }

.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(10,16,20,.45); display: none; }
.scrim.open { display: block; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 520px; margin: 0 auto; background: var(--surface); border-radius: 20px 20px 0 0; border: 1px solid var(--line); border-bottom: 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); opacity: 0; visibility: hidden; transition: transform .24s ease, opacity .2s ease; max-height: 92vh; overflow-y: auto; overflow-x: hidden; }
.sheet.open { transform: translateY(0); opacity: 1; visibility: visible; }
.sheet__grab { width: 40px; height: 4px; border-radius: 999px; background: var(--line); margin: 8px auto 6px; }
.sheet h2 { font-size: 1.1rem; margin: 4px 2px 12px; }
@media (min-width: 900px) {
  .sheet { top: 50%; bottom: auto; left: 50%; right: auto; transform: translate(-50%, -46%); border-radius: 18px; border-bottom: 1px solid var(--line); width: 460px; max-height: 88vh; }
  .sheet.open { transform: translate(-50%, -50%); }
  .sheet__grab { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .9rem; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90%; }
@media (min-width: 900px) { .toast { bottom: 28px; } }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.disclaimer { font-size: .76rem; color: var(--muted); line-height: 1.45; padding: 2px 2px 0; }

/* helpers added for responsive views */
.only-desktop { display: none; }
.narrow { width: 100%; }
@media (min-width: 900px) {
  .only-desktop { display: revert; }
  .narrow { max-width: 760px; }
}


/* history pagination */
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 14px; }
.pager button { min-width: 38px; height: 38px; padding: 0 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; font-size: .92rem; }
.pager button[aria-current="true"] { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.pager button:disabled { opacity: .4; }
.pager .gap { align-self: center; color: var(--muted); padding: 0 2px; }

/* BP limit lines */
.limit-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin: 2px 0 6px; }
.chart-limit { font-size: 11px; font-family: var(--font); font-weight: 600; }

.row__btn { width: 38px; height: 38px; flex: 0 0 auto; }
.row__btn svg { width: 18px; height: 18px; }
.row { gap: 8px; }
.sync-box { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: grid; gap: 4px; }
.js-engine.is-offline { color: var(--warn); }
