/* MED CLOUD CIPHER™ — Reference Prototype Styles
   Mobile-first. High contrast. Large touch targets.
   Architecture rules preserved. Synthetic data only. */

:root {
  --ink: #0f1c28;
  --muted: #5a6b78;
  --line: #d0dbe3;
  --bg: #eef2f5;
  --card: #ffffff;
  --accent: #176b87;
  --accent2: #0d4e67;
  --ok: #1e6b3f;
  --warn: #9a5a00;
  --bad: #9c2b2b;
  --hist: #e4eef4;
  --hist-bg: #153f53;
  --radius: 12px;
  --touch: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }

/* ── Top bar ─────────────────────────────────────── */
.topbar {
  background: #0e2939;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.eyebrow {
  font-size: 9px;
  letter-spacing: 0.12em;
  opacity: 0.65;
  text-transform: uppercase;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}

.prototype-badge {
  font-size: 9px;
  border: 1px solid #5a7a8a;
  padding: 5px 8px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0.9;
  align-self: center;
}

/* ── Mode switcher ───────────────────────────────── */
.modebar {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 56px;
  z-index: 30;
}

.mode {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 14px 8px;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  min-height: var(--touch);
}

.mode.active {
  color: var(--accent2);
  border-bottom-color: var(--accent);
}

/* ── Main content ────────────────────────────────── */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 12px calc(24px + var(--safe-bottom));
}

/* ── Tabs (horizontal scroll on mobile) ──────────── */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 10px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  white-space: nowrap;
}

.tab.active {
  background: var(--accent2);
  color: #fff;
  border-color: var(--accent2);
}

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero h2 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  background: #e8eef1;
  color: var(--ink);
  margin: 2px 2px 2px 0;
}

.badge.ok   { background: #d8f0e2; color: var(--ok); }
.badge.warn { background: #fff0d0; color: var(--warn); }
.badge.bad  { background: #fde4e4; color: var(--bad); }
.badge.hist { background: var(--hist); color: var(--accent2); }

.badge-row { display: flex; flex-wrap: wrap; gap: 4px; }

/* ── Historical banner (Responder) ───────────────── */
.historical-banner {
  background: var(--hist-bg);
  color: #fff;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-align: center;
  line-height: 1.35;
}

/* ── Status grid ─────────────────────────────────── */
.status-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

/* ── Data rows ───────────────────────────────────── */
.rows { display: grid; gap: 0; }

.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 12px 0;
  border-top: 1px solid #e8eef2;
}

.row:first-child { border-top: 0; }

.row .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.row .value {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
}

.row .meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.row.critical {
  border-left: 5px solid var(--bad);
  padding-left: 12px;
  background: #fff8f8;
  margin: 0 -4px;
  padding-right: 8px;
  border-radius: 0 8px 8px 0;
}

.row.warning {
  border-left: 5px solid var(--warn);
  padding-left: 12px;
  background: #fffbf0;
}

/* ── Actions / buttons ───────────────────────────── */
.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  border: 0;
  border-radius: 10px;
  background: var(--accent2);
  color: #fff;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  min-height: var(--touch);
  width: 100%;
  text-align: center;
}

.btn:active { opacity: 0.9; }

.btn.secondary {
  background: #e4ebf0;
  color: var(--ink);
}

.btn.danger { background: #8b2e2e; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Notices ─────────────────────────────────────── */
.notice {
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff8e6;
  border: 1px solid #e8d090;
  font-size: 13px;
  margin-top: 12px;
  line-height: 1.4;
}

.notice.info {
  background: #e8f3f8;
  border-color: #a8c8d8;
}

.notice.bad {
  background: #fdeaea;
  border-color: #e0a0a0;
}

/* ── Conflict block ──────────────────────────────── */
.conflict {
  background: #fff6e8;
  border: 1px solid #e0c080;
  border-radius: 10px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.45;
}

.conflict hr {
  border: 0;
  border-top: 1px solid #e0c080;
  margin: 12px 0;
}

.source-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #3a5568;
  background: #e8eef2;
  padding: 3px 8px;
  border-radius: 999px;
  margin-top: 4px;
}

/* ── Form ────────────────────────────────────────── */
.formgrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 5px;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid #b8c6d0;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  font-size: 16px; /* prevents iOS zoom */
}

.field textarea { min-height: 72px; resize: vertical; }

/* ── Retrieval simulation ────────────────────────── */
.retrieval-steps {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f0f4f7;
  font-size: 14px;
  color: var(--muted);
}

.step.active {
  background: #e0eef6;
  color: var(--ink);
  font-weight: 600;
}

.step.done {
  background: #d8f0e2;
  color: var(--ok);
}

.step .n {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #c8d4dc;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex: none;
}

.step.active .n { background: var(--accent); }
.step.done .n { background: var(--ok); }

/* ── Footer note ─────────────────────────────────── */
.footer-note {
  font-size: 11px;
  color: var(--muted);
  padding: 12px 4px 8px;
  line-height: 1.4;
}

/* ── Toast ───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 12px;
  right: 12px;
  background: #0e2939;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.toast[hidden] { display: none; }

/* ── Install hint ────────────────────────────────── */
.install-hint {
  background: #e8f3f8;
  border: 1px solid #a8c8d8;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 12px;
  line-height: 1.4;
}

/* ── Desktop / tablet ────────────────────────────── */
@media (min-width: 600px) {
  .status-grid { grid-template-columns: repeat(3, 1fr); }
  .hero { flex-direction: row; justify-content: space-between; align-items: flex-start; }
  .actions { flex-direction: row; }
  .btn { width: auto; min-width: 160px; }
  .formgrid { grid-template-columns: 1fr 1fr; }
  main { padding: 20px 20px calc(32px + var(--safe-bottom)); }
  .topbar h1 { font-size: 20px; }
}

@media (min-width: 900px) {
  main { max-width: 860px; }
}

/* Unified prototype additions */
.offline-bar{background:#7a1f1f;color:#fff;text-align:center;font-size:12px;font-weight:700;padding:6px 10px}
.return-link{display:inline-block;color:#8ec8ff;font-size:12px;font-weight:600;margin-top:6px}
.topbar-actions{display:flex;flex-direction:column;align-items:flex-end;gap:4px}
.topbar .sub{font-size:11px;color:#8b9bb0;margin-top:2px;max-width:280px}
.modebar{flex-wrap:wrap}
.mode{font-size:12px;padding:10px 12px}

.banner-warn{background:#3a1515;color:#f0c0c0;border-color:#c43c3c;}
