:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #059669;
  --primary-dark: #047857;
  --primary-soft: #d1fae5;
  --danger-soft: #fee2e2;
  --danger: #b91c1c;
  --warning-soft: #ffedd5;
  --warning: #c2410c;
  --blue-soft: #dbeafe;
  --blue: #1d4ed8;
  --shadow: 0 18px 45px rgba(15, 23, 42, .08);
  --radius: 26px;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  padding: 10px;
}

.brand-logo {
  width: 50px;
  height: 50px;
  border-radius: 18px;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-size: 25px;
}

.brand strong {
  display: block;
  font-size: 20px;
  letter-spacing: -.04em;
}

.brand small {
  color: var(--muted);
  font-weight: 800;
}

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

.nav a {
  text-decoration: none;
  padding: 13px 14px;
  border-radius: 18px;
  color: #475569;
  font-weight: 850;
}

.nav a.active,
.nav a:hover {
  background: var(--primary);
  color: white;
}

.user-card {
  margin-top: auto;
  background: #020617;
  color: white;
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 6px;
}

.user-card span {
  color: #cbd5e1;
  font-size: 13px;
}

.user-card a {
  color: white;
  font-weight: 800;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.topbar p {
  margin: 0 0 3px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -.04em;
}

.topbar-badge {
  border-radius: 999px;
  padding: 9px 14px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 900;
}

.content {
  padding: 28px;
}

.alert {
  border-radius: 18px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-weight: 800;
}

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

.alert.error {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.stat-card,
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(15, 23, 42, .04);
}

.stat-card {
  padding: 20px;
}

.stat-card span {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--primary-soft);
  border-radius: 16px;
  margin-bottom: 12px;
}

.stat-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.stat-card strong {
  display: block;
  font-size: 34px;
  margin-top: 6px;
  letter-spacing: -.05em;
}

.card {
  padding: 20px;
}

.narrow {
  max-width: 860px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.section-head,
.detail-head,
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.section-head h2,
.card h2,
.detail-head h2 {
  margin: 0;
  letter-spacing: -.03em;
}

.section-head p,
.detail-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 0;
  border-radius: 16px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  font-weight: 900;
  padding: 11px 14px;
  cursor: pointer;
}

.btn.secondary {
  background: #e2e8f0;
  color: #0f172a;
}

.btn.small {
  padding: 8px 11px;
  font-size: 13px;
}

.link {
  color: var(--primary-dark);
  font-weight: 900;
}

.list {
  display: grid;
  gap: 10px;
}

.child-row,
.soft-card {
  border-radius: 22px;
  background: #f8fafc;
  padding: 15px;
  text-decoration: none;
}

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

.child-row strong {
  font-size: 17px;
}

.child-row p,
.soft-card p {
  color: var(--muted);
  margin: 5px 0 0;
  font-size: 13px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 74px);
  gap: 8px;
  text-align: center;
}

.metrics span {
  background: white;
  border-radius: 16px;
  padding: 8px;
  font-size: 12px;
  color: var(--muted);
}

.metrics b {
  color: var(--text);
}

.pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 950;
}

.pill.green {
  background: #dcfce7;
  color: #15803d;
}

.pill.yellow {
  background: #fef3c7;
  color: #b45309;
}

.pill.red {
  background: #fee2e2;
  color: #b91c1c;
}

.pill.orange {
  background: #ffedd5;
  color: #c2410c;
}

.pill.blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.pill.gray {
  background: #e2e8f0;
  color: #475569;
}

.form,
.grid-form {
  display: grid;
  gap: 14px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px;
  outline: 0;
  background: white;
}

textarea {
  min-height: 95px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
}

.span-2 {
  grid-column: span 2;
}

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

.check input {
  width: auto;
}

.form-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.search-form {
  display: flex;
  gap: 10px;
  margin: 14px 0 18px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .04em;
}

.detail-head {
  margin-bottom: 18px;
}

.profile-grid {
  display: grid;
  gap: 10px;
}

.profile-grid span {
  display: grid;
  gap: 4px;
  border-radius: 16px;
  background: #f8fafc;
  padding: 12px;
}

.immunization-grid,
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.soft-card.done {
  background: #ecfdf5;
}

.inline-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 40px;
  gap: 10px;
  align-items: center;
  font-weight: 850;
}

.bar {
  height: 14px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--primary);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at top left, rgba(5,150,105,.25), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(37,99,235,.18), transparent 32rem),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 60px;
  height: 60px;
  border-radius: 22px;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-size: 30px;
}

.login-card h1 {
  margin: 18px 0 5px;
  letter-spacing: -.05em;
}

.login-card p {
  margin-top: 0;
  color: var(--muted);
}

.demo-box {
  margin-top: 16px;
  display: grid;
  gap: 5px;
  background: #f8fafc;
  border-radius: 18px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .stats-grid,
  .grid-2,
  .immunization-grid,
  .inventory-grid {
    grid-template-columns: 1fr;
  }

  .child-row,
  .section-head,
  .detail-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .content,
  .topbar {
    padding: 16px;
  }

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

  .span-2 {
    grid-column: span 1;
  }

  .metrics {
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .search-form {
    flex-direction: column;
  }
}


article.soft-card h3 {
  margin-bottom: 4px;
}

.nav a[href*="api.backup"] {
  background: #f8fafc;
  color: #0f172a;
}


.sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

.muted {
  color: var(--muted);
}


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

.topbar-badge.offline {
  background: #ffedd5;
  color: #c2410c;
}

.install-btn {
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  background: #020617;
  color: white;
  font-weight: 900;
  cursor: pointer;
}

.pwa-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  max-width: min(360px, calc(100vw - 36px));
  border-radius: 18px;
  background: #020617;
  color: white;
  padding: 13px 16px;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  transition: .25s ease;
  font-weight: 800;
}

.pwa-toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 640px) {
  .topbar-actions {
    align-items: flex-end;
    flex-direction: column;
  }

  .install-btn,
  .topbar-badge {
    font-size: 12px;
    padding: 8px 10px;
  }
}
