:root {
  --rcf-red: #CC0000;
  --rcf-red-light: #FF2222;
  --rcf-black: #0A0A0A;
  --rcf-dark: #141414;
  --rcf-gray: #1E1E1E;
  --rcf-gray-mid: #2A2A2A;
  --rcf-gray-light: #3A3A3A;
  --rcf-white: #F0F0F0;
  --rcf-muted: #777;
  --green: #3CB371;
  --yellow: #E6AC00;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: 'Barlow', sans-serif;
  background: var(--rcf-black);
  color: var(--rcf-white);
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ===== ONBOARDING ===== */
#onboarding {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.onboarding-inner {
  padding: 48px 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 100%;
}

.ob-logo { width: 72px; height: 72px; margin-bottom: 16px; }

.ob-brand {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.ob-sub {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rcf-red);
  margin-top: 4px;
  margin-bottom: 32px;
}

.ob-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 26px;
  margin-bottom: 10px;
}

.ob-desc {
  font-size: 14px;
  color: var(--rcf-muted);
  line-height: 1.6;
  max-width: 280px;
  margin-bottom: 28px;
}

.ob-form { width: 100%; text-align: left; }

.ob-formula {
  font-size: 12px;
  color: var(--rcf-muted);
  text-align: center;
  margin-bottom: 16px;
  margin-top: -4px;
}

/* ===== APP SHELL ===== */
#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ===== HEADER ===== */
.app-header {
  background: var(--rcf-dark);
  border-bottom: 2px solid var(--rcf-red);
  padding: 11px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}

.logo-mark { width: 36px; height: 36px; flex-shrink: 0; }
.brand-text { flex: 1; }

.brand-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
}

.brand-sub {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rcf-red);
  margin-top: 2px;
}

.header-meta {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--rcf-muted);
  text-align: right;
  line-height: 1.3;
}

/* ===== TABS ===== */
.nav-tabs {
  display: flex;
  background: var(--rcf-dark);
  border-bottom: 1px solid var(--rcf-gray);
  flex-shrink: 0;
}

.nav-tab {
  flex: 1;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rcf-muted);
  padding: 10px 4px;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.nav-tab.active { color: var(--rcf-white); border-bottom: 2px solid var(--rcf-red); }

/* ===== PAGES ===== */
.page {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  padding-bottom: 24px;
  -webkit-overflow-scrolling: touch;
}

.page.active { display: block; }

/* ===== CARDS ===== */
.card {
  background: var(--rcf-dark);
  border: 1px solid var(--rcf-gray-light);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rcf-red);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: '';
  display: inline-block;
  width: 3px; height: 14px;
  background: var(--rcf-red);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ===== FORMS ===== */
label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rcf-muted);
  margin-bottom: 5px;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  background: var(--rcf-gray);
  border: 1px solid var(--rcf-gray-light);
  border-radius: 7px;
  color: var(--rcf-white);
  font-family: 'Barlow', sans-serif;
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus { border-color: var(--rcf-red); }

.meta-preview {
  background: rgba(204,0,0,0.08);
  border: 1px solid rgba(204,0,0,0.25);
  border-radius: 7px;
  padding: 10px 14px;
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.meta-preview.show { display: flex; }
.meta-preview-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--rcf-muted); }
.meta-preview-val { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 20px; color: var(--rcf-red); }

/* ===== BUTTONS ===== */
.btn-primary {
  width: 100%;
  background: var(--rcf-red);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 13px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

.btn-primary:hover { background: var(--rcf-red-light); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  width: 100%;
  background: transparent;
  color: var(--rcf-muted);
  border: 1px solid var(--rcf-gray-light);
  border-radius: 8px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
  touch-action: manipulation;
}

.btn-secondary:hover { color: var(--rcf-white); border-color: var(--rcf-gray-mid); }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn-primary,
.btn-row .btn-secondary { flex: 1; }

/* ===== TODAY ===== */
.date-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.date-text {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--rcf-muted);
}

.day-streak {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--rcf-red);
  background: rgba(204,0,0,0.1);
  border: 1px solid rgba(204,0,0,0.25);
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

/* PROGRESS RING */
.progress-card {
  background: var(--rcf-dark);
  border: 1px solid var(--rcf-gray-light);
  border-radius: 12px;
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 12px;
}

.ring-wrap { position: relative; width: 96px; height: 96px; flex-shrink: 0; }
.ring-svg { transform: rotate(-90deg); display: block; }

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-pct {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 21px;
  line-height: 1;
}

.ring-sub { font-size: 10px; color: var(--rcf-muted); margin-top: 1px; }
.progress-info { flex: 1; min-width: 0; }

.progress-big {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 30px;
  line-height: 1;
}

.progress-big .unit { font-size: 15px; font-weight: 400; color: var(--rcf-muted); }
.progress-row { font-size: 12px; color: var(--rcf-muted); margin-top: 5px; }
.progress-row strong { color: var(--rcf-white); }

/* ALERTS */
.alert {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.4;
}

.alert.red    { background: rgba(204,0,0,0.1);    border: 1px solid rgba(204,0,0,0.3);    color: #FF6666; }
.alert.green  { background: rgba(60,179,113,0.1); border: 1px solid rgba(60,179,113,0.3); color: var(--green); }
.alert.yellow { background: rgba(230,172,0,0.1);  border: 1px solid rgba(230,172,0,0.3);  color: var(--yellow); }

/* TURNOS */
.turno-card {
  background: var(--rcf-dark);
  border: 1px solid var(--rcf-gray-light);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  transition: border-color 0.25s;
}

.turno-card.active-t { border-color: var(--rcf-red); }
.turno-card.done-t   { border-color: #2d5a2d; opacity: 0.8; }

.turno-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

.turno-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex: 1;
}

.turno-time { font-size: 11px; color: var(--rcf-muted); }

.badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
}

.badge-red    { background: rgba(204,0,0,0.15);    color: var(--rcf-red); border: 1px solid rgba(204,0,0,0.25); }
.badge-green  { background: rgba(60,179,113,0.15); color: var(--green);   border: 1px solid rgba(60,179,113,0.25); }
.badge-yellow { background: rgba(230,172,0,0.15);  color: var(--yellow);  border: 1px solid rgba(230,172,0,0.25); }

.bar-track { height: 5px; background: var(--rcf-gray); border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.bar-fill  { height: 100%; border-radius: 3px; transition: width 0.5s ease; }

.turno-stat {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--rcf-muted);
  margin-bottom: 10px;
}

.turno-stat strong { color: var(--rcf-white); }

.dose-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.dose-btn {
  background: var(--rcf-gray);
  border: 1px solid var(--rcf-gray-light);
  border-radius: 7px;
  color: var(--rcf-muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 6px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  touch-action: manipulation;
}

.dose-btn:hover  { background: var(--rcf-gray-mid); color: var(--rcf-white); border-color: var(--rcf-red); }
.dose-btn:active { transform: scale(0.96); }

.dose-input-row { display: flex; gap: 8px; margin-bottom: 8px; }
.dose-input-row input { flex: 1; margin-bottom: 0; }
.dose-input-row button { flex-shrink: 0; padding: 10px 14px; width: auto; }

.btn-done {
  width: 100%;
  background: transparent;
  border: 1px solid #2d5a2d;
  border-radius: 7px;
  color: var(--green);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px;
  cursor: pointer;
  transition: all 0.15s;
  touch-action: manipulation;
}

.btn-done:hover { background: rgba(60,179,113,0.1); }

/* ===== UNDO / REMOVE ===== */
.undo-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.btn-undo {
  flex: 1;
  background: transparent;
  border: 1px solid var(--rcf-gray-light);
  border-radius: 7px;
  color: var(--rcf-muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 8px 6px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  touch-action: manipulation;
}

.btn-undo:hover:not(:disabled) {
  color: var(--yellow);
  border-color: rgba(230,172,0,0.4);
  background: rgba(230,172,0,0.06);
}

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

/* ===== HISTORICO ===== */
.hist-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-box {
  background: var(--rcf-dark);
  border: 1px solid var(--rcf-gray-light);
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
}

.stat-box-val {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 22px;
  color: var(--rcf-red);
  line-height: 1;
}

.stat-box-lbl {
  font-size: 10px;
  color: var(--rcf-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
  line-height: 1.3;
}

.hist-item {
  background: var(--rcf-dark);
  border: 1px solid var(--rcf-gray-light);
  border-radius: 10px;
  padding: 13px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.hist-item:hover { border-color: var(--rcf-gray-mid); }

.hist-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.hist-date {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hist-pct {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 20px;
  text-align: right;
  line-height: 1;
}

.hist-ml { font-size: 11px; color: var(--rcf-muted); text-align: right; margin-top: 1px; }
.hist-bar-track { height: 4px; background: var(--rcf-gray); border-radius: 2px; overflow: hidden; }
.hist-bar-fill  { height: 100%; border-radius: 2px; }

/* ===== PERFIL ===== */
.perfil-row { display: flex; align-items: center; gap: 14px; }

.perfil-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(204,0,0,0.12);
  border: 1px solid rgba(204,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--rcf-red);
  flex-shrink: 0;
}

.perfil-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.perfil-sub { font-size: 12px; color: var(--rcf-muted); margin-top: 3px; }

/* ===== INFO ROWS ===== */
.info-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rcf-gray);
  font-size: 13px;
  line-height: 1.5;
}

.info-row:last-child { border-bottom: none; }
.info-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.info-label { font-size: 11px; color: var(--rcf-muted); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 2px; }

/* ===== DANGER ===== */
.danger-card { border-color: rgba(204,0,0,0.25) !important; }

.btn-danger {
  width: 100%;
  background: transparent;
  color: #FF6666;
  border: 1px solid rgba(204,0,0,0.4);
  border-radius: 8px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 11px;
  cursor: pointer;
  transition: all 0.2s;
  touch-action: manipulation;
}

.btn-danger:hover { background: rgba(204,0,0,0.1); border-color: rgba(204,0,0,0.6); }

/* ===== MODAL ===== */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.overlay.open { display: flex; }

.sheet {
  background: var(--rcf-dark);
  border: 1px solid var(--rcf-gray-light);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--rcf-gray-light);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.sheet-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--rcf-gray);
  font-size: 13px;
}

.detail-row:last-child { border-bottom: none; }
.detail-row .val { font-weight: 600; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  max-width: 320px;
  width: calc(100% - 32px);
  background: var(--rcf-dark);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  z-index: 300;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.t-red    { border: 1px solid rgba(204,0,0,0.5);    color: #FF6666; }
.toast.t-green  { border: 1px solid rgba(60,179,113,0.5); color: var(--green); }
.toast.t-yellow { border: 1px solid rgba(230,172,0,0.5);  color: var(--yellow); }

/* ===== EMPTY ===== */
.empty { text-align: center; padding: 48px 20px; color: var(--rcf-muted); }
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty p { font-size: 13px; line-height: 1.6; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rcf-gray-light); border-radius: 2px; }
