:root {
  --navy: #1B2A4A;
  --navy-light: #2C3F66;
  --gold: #C9A227;
  --gold-soft: #F5EED9;
  --bg: #F7F8FA;
  --card: #FFFFFF;
  --border: #E4E7EC;
  --text: #1F2430;
  --text-soft: #6B7280;
  --green: #2E9E6B;
  --green-soft: #E3F5EC;
  --red: #C0392B;
  --red-soft: #FBE9E6;
  --blue-soft: #E8EEF7;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(27, 42, 74, 0.08);
  --nav-h: 64px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

#app { height: 100%; }

.view {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.view.no-nav { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 20px;
  color: var(--navy);
  letter-spacing: 0.3px;
}

.brand img { width: 30px; height: 30px; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }

h1.page-title { font-size: 22px; color: var(--navy); }
h2.section-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-soft);
  font-weight: 700;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card p.muted { color: var(--text-soft); font-size: 14px; }

.occ-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.occ-time {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
}

.occ-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge-pending { background: var(--gold-soft); color: #8a6d1a; }
.badge-concluded { background: var(--green-soft); color: var(--green); }
.badge-future { background: var(--blue-soft); color: var(--navy-light); }

.med-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.med-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.med-name { font-weight: 600; font-size: 15px; }
.med-detail { font-size: 12.5px; color: var(--text-soft); }

.status-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-pending { background: var(--gold-soft); color: #8a6d1a; }
.status-confirmed { background: var(--green-soft); color: var(--green); }

.btn {
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter 0.15s, transform 0.05s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--navy); color: #fff; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--navy);
  color: var(--navy);
}
.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  font-size: 13.5px;
  padding: 8px 12px;
}
.btn-danger-soft { background: var(--red-soft); color: var(--red); }
.btn-success { background: var(--green); color: #fff; }
.btn-block { width: 100%; }

.btn-sm { padding: 8px 14px; font-size: 13.5px; }

.field { display: flex; flex-direction: column; gap: 5px; }

.field label { font-size: 13px; font-weight: 600; color: var(--text-soft); }

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field input[type="time"],
.field select,
.field textarea {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  width: 100%;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--navy-light);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 9px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
}

.segmented button.active { background: var(--card); color: var(--navy); box-shadow: var(--shadow); }

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

.list-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.list-item .li-title { font-weight: 600; font-size: 15px; }
.list-item .li-sub { font-size: 12.5px; color: var(--text-soft); margin-top: 2px; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}

.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.switch { position: relative; width: 48px; height: 27px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.2s;
  cursor: pointer;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 21px;
  height: 21px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(21px); }

.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  z-index: 50;
}

.nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
}

.nav a .ico { font-size: 20px; line-height: 1; }
.nav a.active { color: var(--navy); }
.nav a.active .ico { filter: drop-shadow(0 0 6px rgba(201, 162, 39, 0.55)); }

.banner {
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 13.5px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.45;
}

.banner.warn { background: var(--gold-soft); color: #7a5f12; }
.banner.ok { background: var(--green-soft); color: var(--green); }
.banner.info { background: var(--blue-soft); color: var(--navy-light); }
.banner.err { background: var(--red-soft); color: var(--red); }

.alert {
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 13.5px;
  background: var(--red-soft);
  color: var(--red);
}

.alert.success { background: var(--green-soft); color: var(--green); }

.auth-wrap {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.auth-logo img { width: 72px; height: 72px; }
.auth-logo h1 { font-size: 26px; color: var(--navy); }
.auth-logo p { color: var(--text-soft); font-size: 14px; text-align: center; }

.auth-form { display: flex; flex-direction: column; gap: 12px; }

.empty-state {
  text-align: center;
  color: var(--text-soft);
  padding: 28px 16px;
  font-size: 14px;
  line-height: 1.6;
}

.empty-state .big { font-size: 40px; display: block; margin-bottom: 8px; }

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

.hist-item { display: flex; flex-direction: column; gap: 6px; }
.hist-item .occ-head { flex-wrap: wrap; }

.note { font-size: 12.5px; color: var(--text-soft); line-height: 1.5; }

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 26px;
  border: none;
  box-shadow: 0 4px 14px rgba(27, 42, 74, 0.35);
  cursor: pointer;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spacer { flex: 1; }

.hidden { display: none !important; }