:root {
  --green: #079b7a;
  --green2: #12b995;
  --mint: #e9fbf4;
  --navy: #153b62;
  --ink: #18324b;
  --muted: #71839a;
  --line: #e5edf3;
  --bg: #f5f9fc;
  --white: #fff;
  --red: #f45c70;
  --shadow: 0 12px 35px rgba(22, 65, 95, 0.08);
  --radius: 17px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

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

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 245px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 26px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 9px 28px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(145deg, #0da7c4, #06a77b);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 23px;
  box-shadow: 0 7px 16px #0ba68b35;
  flex-shrink: 0;
}

.brand strong {
  font-size: 20px;
  color: var(--navy);
  letter-spacing: -0.7px;
}

.brand strong span { color: var(--green); }

.brand small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 2px;
}

.nav-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: #9aa9b7;
  padding: 12px 12px 8px;
}

.nav { display: grid; gap: 5px; }

.nav button {
  border: 0;
  background: transparent;
  color: #6c7f92;
  text-align: left;
  padding: 12px 13px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 650;
  font-size: 13px;
  transition: background 0.2s, color 0.2s;
}

.nav button .ico {
  font-size: 18px;
  width: 22px;
  text-align: center;
}

.nav button:hover,
.nav button.active {
  background: var(--mint);
  color: var(--green);
}

.nav button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.sidebar-bottom { margin-top: auto; }

.privacy-card {
  background: linear-gradient(145deg, #eafbf4, #eff8ff);
  border: 1px solid #dcefe9;
  padding: 14px;
  border-radius: 15px;
  font-size: 12px;
  line-height: 1.5;
  color: #527267;
}

.privacy-card b {
  display: block;
  color: #176e5c;
  margin-bottom: 4px;
}

.profile-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 7px 0;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #d9f3ed;
  display: grid;
  place-items: center;
  font-size: 21px;
  flex-shrink: 0;
}

.profile-mini b { display: block; font-size: 12px; }
.profile-mini small { font-size: 10px; color: var(--muted); }

/* Main */
.main {
  margin-left: 245px;
  width: calc(100% - 245px);
  padding: 28px 34px 50px;
  max-width: 1600px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
}

.eyebrow {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.8px;
  color: var(--navy);
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-btn {
  height: 42px;
  width: 42px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 13px;
  color: #526b80;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}

.icon-btn:hover { background: #f7fafc; border-color: #d0dde8; }

.dot {
  position: absolute;
  right: 9px;
  top: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  border: 1px solid white;
}

.primary, .secondary, .danger {
  border: 0;
  border-radius: 11px;
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 750;
  transition: transform 0.15s, filter 0.15s, background 0.2s;
}

.primary {
  background: linear-gradient(135deg, var(--green), var(--green2));
  color: white;
  box-shadow: 0 7px 14px #079b7a22;
}

.primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.primary:active { transform: translateY(0); }

.secondary {
  background: #f2f7fa;
  color: #456176;
  border: 1px solid var(--line);
}

.secondary:hover { background: #e8f0f5; }

.danger {
  background: #fff0f2;
  color: #d93d55;
  border: 1px solid #ffdde2;
}

.danger:hover { background: #ffe8ec; }

.page { display: none; animation: appear 0.24s ease; }
.page.active { display: block; }

@keyframes appear {
  from { opacity: 0.4; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.welcome {
  background: linear-gradient(110deg, #e5fbf2, #f2fbff);
  border: 1px solid #d7f0e8;
  border-radius: 22px;
  padding: 27px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  overflow: hidden;
  position: relative;
  margin-bottom: 22px;
}

.welcome:after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: #fff8;
  right: 12%;
  top: -130px;
  pointer-events: none;
}

.welcome h2 {
  font-size: 25px;
  margin: 0 0 8px;
  color: var(--navy);
  letter-spacing: -0.7px;
}

.welcome p {
  margin: 0 0 18px;
  color: #617d8e;
  font-size: 13px;
  max-width: 510px;
  line-height: 1.6;
}

.welcome-art {
  font-size: 80px;
  z-index: 1;
  filter: drop-shadow(0 8px 10px #2d997b1c);
  user-select: none;
}

.grid { display: grid; gap: 18px; }

.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
}

.stat, .panel, .feature {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 15px #173b5b05;
}

.stat { padding: 18px; }

.stat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.stat-icon {
  width: 37px;
  height: 37px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: #e9f8f2;
}

.stat strong {
  display: block;
  font-size: 26px;
  margin: 11px 0 4px;
  color: var(--navy);
}

.stat small {
  font-size: 11px;
  color: #8093a3;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 0 14px;
  gap: 12px;
}

.section-head h3 {
  margin: 0;
  font-size: 16px;
  color: var(--navy);
}

.text-link {
  border: 0;
  background: none;
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  padding: 0;
}

.text-link:hover { text-decoration: underline; }

.features { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.feature {
  padding: 19px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.feature:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: #c5eee1;
}

.feature:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #e8f8f2;
  display: grid;
  place-items: center;
  font-size: 22px;
  margin-bottom: 13px;
}

.feature h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.feature p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.two-col { grid-template-columns: 1.2fr 0.8fr; }

.panel { padding: 20px; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 17px;
}

.panel-head h3 {
  font-size: 15px;
  margin: 0;
  color: var(--navy);
}

.med-row, .report-row, .contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid #edf2f6;
}

.med-row:last-child,
.report-row:last-child,
.contact-row:last-child { border-bottom: 0; }

.pill-icon, .file-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #e7f8f1;
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}

.file-icon { background: #fff0f1; }

.row-main { flex: 1; min-width: 0; }
.row-main b { font-size: 12px; display: block; }
.row-main small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
}

.status {
  font-size: 10px;
  font-weight: 750;
  color: #078a69;
  background: #e9f9f2;
  padding: 5px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.status.low {
  background: #fff0f0;
  color: #dc4a5c;
}

.health-note {
  background: #f0f8ff;
  border: 1px solid #dcecf9;
  padding: 16px;
  border-radius: 14px;
  color: #496980;
  font-size: 12px;
  line-height: 1.6;
}

.health-note b { color: var(--navy); }

.page-title {
  margin: 0 0 7px;
  color: var(--navy);
  font-size: 24px;
  letter-spacing: -0.6px;
}

.page-subtitle {
  margin: 0 0 23px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.upload-layout { grid-template-columns: 1.05fr 0.95fr; }

.dropzone {
  border: 2px dashed #b9e5d8;
  background: #f6fffb;
  border-radius: 18px;
  padding: 34px 20px;
  text-align: center;
  min-height: 235px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone.drag-over {
  border-color: var(--green);
  background: #e8fbf4;
}

.dropzone:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.upload-icon { font-size: 39px; margin-bottom: 10px; }

.dropzone h3 {
  margin: 0 0 7px;
  color: var(--navy);
  font-size: 16px;
}

.dropzone p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 0 0 17px;
}

.file-input { display: none; }

.preview {
  display: none;
  margin-top: 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  align-items: center;
  gap: 12px;
}

.preview.show { display: flex; }

.preview img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 9px;
}

.action-row {
  display: flex;
  gap: 9px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 750;
  margin-bottom: 7px;
  color: #486176;
}

.field {
  width: 100%;
  border: 1px solid #dce6ee;
  border-radius: 10px;
  padding: 12px 13px;
  background: #fff;
  outline: none;
  color: var(--ink);
  font-size: 12px;
  margin-bottom: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field:focus {
  border-color: #54c8aa;
  box-shadow: 0 0 0 3px #12b99516;
}

.results { margin-top: 18px; display: none; }
.results.show { display: block; }

.result-banner {
  padding: 14px;
  border-radius: 12px;
  background: #eaf9f2;
  color: #176b56;
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.ocr-box {
  background: #f8fafc;
  border: 1px solid #e5edf3;
  border-radius: 12px;
  padding: 13px;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-bottom: 15px;
  max-height: 240px;
  overflow: auto;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.result-table th,
.result-table td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid #edf2f6;
}

.result-table th {
  color: var(--muted);
  font-weight: 650;
  font-size: 10px;
}

.result-table td:last-child { text-align: right; }

.disclaimer {
  font-size: 10px;
  color: #8798a6;
  line-height: 1.5;
  margin-top: 15px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 17px;
}

.search {
  flex: 1;
  min-width: 190px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
  background: #fff;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search:focus {
  border-color: #54c8aa;
  box-shadow: 0 0 0 3px #12b99516;
}

.reminder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.medicine-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.medicine-card:hover {
  border-color: #c5e8dc;
  box-shadow: 0 6px 18px #173b5b08;
}

.medicine-card .row-main b { font-size: 13px; }

.taken {
  border: 0;
  background: #e8f8f1;
  color: #078766;
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 750;
  flex-shrink: 0;
  transition: background 0.2s;
}

.taken:hover { background: #d4f3e8; }
.taken.done { background: #f0f3f5; color: #71839a; }
.taken.done:hover { background: #e4e9ed; }

.empty {
  padding: 35px 15px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.profile-grid { grid-template-columns: 1fr 1fr; }

.profile-card {
  display: flex;
  gap: 15px;
  align-items: center;
  padding: 20px;
  background: linear-gradient(120deg, #e8f8f2, #f4fbff);
  border: 1px solid #dcefe9;
  border-radius: var(--radius);
  margin-bottom: 18px;
}

.big-avatar {
  width: 66px;
  height: 66px;
  border-radius: 20px;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 35px;
  flex-shrink: 0;
}

.profile-card h3 { margin: 0 0 5px; }
.profile-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.notice {
  font-size: 11px;
  color: #7c8f9f;
  line-height: 1.55;
  margin-top: 15px;
}

.emergency-call-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.emergency-call-btn {
  font-size: 14px;
  padding: 13px 20px;
  box-shadow: 0 6px 16px #d93d5522;
}

.emergency-num-label {
  font-size: 12px;
  color: #a42d47;
  font-weight: 650;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.call-btn {
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 750;
  border-radius: 9px;
}

@media (max-width: 760px) {
  .contact-row {
    flex-wrap: wrap;
  }
  .contact-actions {
    width: 100%;
    margin-top: 8px;
    justify-content: flex-start;
  }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #102c4380;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 30;
  backdrop-filter: blur(4px);
}

.modal-backdrop.show { display: flex; }

.modal {
  width: min(430px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 70px #09253b35;
  animation: modalIn 0.22s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.modal-head h3 {
  margin: 0;
  color: var(--navy);
}

.close {
  border: 0;
  background: #f1f5f8;
  border-radius: 9px;
  width: 32px;
  height: 32px;
  font-size: 19px;
  color: #62798c;
  line-height: 1;
  transition: background 0.15s;
}

.close:hover { background: #e4ebf0; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #153b62;
  color: #fff;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 12px;
  box-shadow: var(--shadow);
  z-index: 50;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: min(340px, calc(100vw - 40px));
}

.toast.show {
  opacity: 1;
  transform: none;
}

.mobile-nav { display: none; }

/* Responsive */
@media (max-width: 1100px) {
  .main { padding: 24px 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .welcome-art { font-size: 65px; }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .main {
    margin-left: 0;
    width: 100%;
    padding: 20px 15px 100px;
  }
  .topbar { margin-bottom: 20px; }
  .topbar h1 { font-size: 22px; }
  .top-actions .desktop { display: none; }
  .welcome { padding: 22px 20px; }
  .welcome h2 { font-size: 21px; }
  .welcome-art { font-size: 47px; }
  .stats { gap: 10px; }
  .stat { padding: 13px; }
  .stat strong { font-size: 23px; }
  .features,
  .two-col,
  .upload-layout,
  .reminder-grid,
  .profile-grid { grid-template-columns: 1fr; }
  .features { gap: 10px; }
  .feature {
    display: flex;
    gap: 13px;
    align-items: flex-start;
    padding: 15px;
  }
  .feature-icon {
    flex-shrink: 0;
    margin: 0;
  }
  .section-head { margin-top: 22px; }
  .mobile-nav {
    display: flex;
    position: fixed;
    z-index: 20;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffffef;
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .mobile-nav button {
    border: 0;
    background: transparent;
    color: #8192a2;
    font-size: 9px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    transition: color 0.15s;
  }
  .mobile-nav button span { font-size: 19px; }
  .mobile-nav button.active {
    color: var(--green);
    font-weight: 800;
  }
  .page-title { font-size: 22px; }
  .topbar .primary { padding: 10px 11px; }
  .dropzone { min-height: 210px; }
  .toast { right: 12px; bottom: 80px; }
}
