/* Neonatal Klinik Assistent — uslub */
:root {
  --accent: #0e7490;
  --accent-dark: #0c5f77;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --red: #b91c1c;
  --red-bg: #fef2f2;
  --orange: #c2410c;
  --orange-bg: #fff7ed;
  --yellow: #a16207;
  --yellow-bg: #fefce8;
  --green: #15803d;
  --green-bg: #f0fdf4;
  --blue-bg: #eff6ff;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
}

/* ---------- Header ---------- */
.app-header {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  color: #fff;
  padding: 18px 16px 14px;
}
.header-inner { max-width: 860px; margin: 0 auto; }
.app-header h1 { margin: 0; font-size: 1.45rem; }
.tagline { margin: 4px 0 0; opacity: .85; font-size: .85rem; }

/* ---------- Patient bar ---------- */
.patient-bar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
}
.patient-inner {
  max-width: 860px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: end;
}
.patient-bar label {
  display: flex; flex-direction: column; gap: 2px;
  font-size: .75rem; font-weight: 600; color: var(--muted);
}
.patient-hint {
  max-width: 860px; margin: 6px auto 0;
  font-size: .72rem; color: var(--muted);
}
.pt-summary { font-size: .8rem; color: var(--accent-dark); font-weight: 600; padding-bottom: 8px; }

/* ---------- Tabs (8 ta — grid) ---------- */
.tabs {
  max-width: 860px; margin: 14px auto 0;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
  padding: 0 16px;
}
.tab {
  padding: 10px 6px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: .85rem; font-weight: 600; color: var(--muted);
  text-align: center;
}
.tab.active {
  color: var(--accent-dark);
  box-shadow: inset 0 -3px 0 var(--accent);
}

/* ---------- Main ---------- */
main { max-width: 860px; margin: 0 auto; padding: 0 16px 30px; }
.tabpanel { display: none; padding-top: 12px; }
.tabpanel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card.hidden { display: none; }
.card h2 { margin: 0 0 12px; font-size: 1.05rem; }
.card h2 .sub { font-size: .75rem; color: var(--muted); font-weight: 400; }

.row {
  display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px;
}
label { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.grow { flex: 1; min-width: 180px; }

input, select {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .95rem;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
input[type="number"] { font-variant-numeric: tabular-nums; }

.quick { display: inline-flex; gap: 4px; margin-top: 4px; }
.quick button {
  padding: 3px 10px; font-size: .75rem; border: 1px solid var(--line);
  background: var(--blue-bg); border-radius: 6px; cursor: pointer; color: var(--accent-dark);
}

.btn {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 18px; border-radius: 8px; font-size: .95rem; font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn-ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; color: var(--muted); font-size: .8rem;
}

/* ---------- Warning banner ---------- */
.warning-banner {
  background: var(--red-bg);
  border: 1px solid #fecaca;
  color: var(--red);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: .82rem;
  margin-bottom: 14px;
}

/* ---------- Result boxes ---------- */
.result-main {
  border-radius: 10px; padding: 14px; margin-top: 10px;
  border: 1px solid var(--line);
  font-size: .95rem;
}
.result-main .big { font-size: 1.3rem; font-weight: 700; }
.st-green  { background: var(--green-bg);  border-color: #bbf7d0; color: var(--green); }
.st-yellow { background: var(--yellow-bg); border-color: #fde68a; color: var(--yellow); }
.st-orange { background: var(--orange-bg); border-color: #fed7aa; color: var(--orange); }
.st-red    { background: var(--red-bg);    border-color: #fecaca; color: var(--red); }
.st-blue   { background: var(--blue-bg);   border-color: #bfdbfe; color: #1d4ed8; }

.result-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-top: 10px;
}
.result-cell {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.result-cell .k { font-size: .72rem; color: var(--muted); font-weight: 600; }
.result-cell .v { font-size: 1.05rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

.notes { margin-top: 10px; font-size: .82rem; color: var(--muted); }
.notes ul { margin: 4px 0 0; padding-left: 18px; }
.warnbox {
  background: var(--red-bg); border: 1px solid #fecaca; color: var(--red);
  border-radius: 8px; padding: 8px 12px; font-size: .82rem; margin-top: 10px;
}
.src-line { font-size: .7rem; color: var(--muted); margin-top: 10px; }

/* ---------- Drug panel ---------- */
.drug-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.drug-head h3 { margin: 0; font-size: 1.1rem; }
.badge {
  font-size: .7rem; font-weight: 700; padding: 3px 8px; border-radius: 20px;
  background: var(--blue-bg); color: var(--accent-dark); border: 1px solid #bfdbfe;
}
.drug-route { font-size: .78rem; color: var(--muted); }

/* ---------- Fluids / others ---------- */
.hint-inline { font-size: .7rem; color: var(--muted); font-weight: 400; }
.small { font-size: .8rem; color: var(--muted); }

fieldset.risks {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin: 0 0 12px;
}
fieldset.risks legend { font-size: .78rem; font-weight: 700; color: var(--muted); padding: 0 6px; }
fieldset.risks label {
  flex-direction: row; align-items: center; gap: 8px; font-size: .85rem; color: var(--ink); font-weight: 400;
}
fieldset.risks input[type="checkbox"] { width: auto; }

/* ---------- Ballard / APGAR ---------- */
.ballard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.ballard-grid label { font-size: .75rem; }

.saved-list { font-size: .85rem; }
.saved-list .entry {
  display: inline-block; background: var(--blue-bg); border: 1px solid #bfdbfe;
  border-radius: 8px; padding: 4px 10px; margin: 3px 6px 3px 0; color: #1d4ed8;
}

.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 2px 16px; }
.check-grid label { font-weight: 400; }
label.indent { padding-left: 20px; font-style: italic; }

/* ---------- Lug'at ---------- */
.g-cat { margin-top: 16px; }
.g-cat h3 {
  margin: 0 0 4px; font-size: .78rem; color: var(--accent-dark);
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 2px solid var(--accent); padding-bottom: 4px;
}
.g-entry {
  display: grid; grid-template-columns: minmax(130px, 210px) 1fr; gap: 12px;
  padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: .85rem;
  break-inside: avoid;
}
.g-entry:last-child { border-bottom: none; }
.g-term { font-weight: 700; color: var(--ink); }
.g-def { color: #334155; line-height: 1.45; }

/* ---------- Footer ---------- */
.app-footer {
  max-width: 860px; margin: 0 auto; padding: 16px;
  font-size: .75rem; color: var(--muted);
  border-top: 1px solid var(--line);
}
.app-footer p { margin: 4px 0; }

/* ---------- Global qidiruv ---------- */
.global-search { position: relative; margin-top: 12px; }
.global-search input {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: none;
  font-size: .95rem; background: #fff; color: var(--ink);
}
.search-overlay {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .18);
  max-height: 62vh; overflow-y: auto; z-index: 60;
}
.search-overlay.hidden { display: none; }
.sr-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.sr-item:hover { background: var(--blue-bg); }
.sr-item:last-child { border-bottom: none; }
.sr-group {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  color: var(--accent-dark); background: var(--blue-bg);
  padding: 2px 8px; border-radius: 12px; white-space: nowrap;
}
.sr-label { font-size: .88rem; font-weight: 600; color: var(--ink); }
.sr-sub { font-size: .72rem; color: var(--muted); margin-left: auto; }
.sr-empty { padding: 12px 14px; font-size: .85rem; color: var(--muted); }

/* ---------- Chiplar ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.chip {
  padding: 6px 13px; border-radius: 20px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: .78rem; font-weight: 600; color: var(--muted);
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Kasallik akkordeoni ---------- */
.dis-card { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: #fff; overflow: hidden; }
.dis-head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 13px 14px; background: none; border: none; cursor: pointer; text-align: left;
  font-size: .95rem; color: var(--ink);
}
.dis-name { font-weight: 700; flex: 1; }
.dis-arrow { font-size: .7rem; color: var(--muted); }
.dis-body { padding: 0 14px 14px; }
.dis-body[hidden] { display: none; }
.dis-about { margin: 0 0 6px; font-size: .85rem; color: #334155; font-style: italic; }
.dis-sec h4 { margin: 12px 0 4px; font-size: .78rem; color: var(--accent-dark); text-transform: uppercase; letter-spacing: .03em; }
.dis-sec ul { margin: 0; padding-left: 18px; font-size: .85rem; }
.dis-sec li { margin-bottom: 3px; }
.dis-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.small-btn { padding: 8px 12px; font-size: .8rem; }

/* ---------- Toast + flash ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: .85rem; z-index: 100; box-shadow: 0 8px 20px rgba(0,0,0,.25);
}
.flash { animation: flashfade 1.6s ease-out; }
@keyframes flashfade { 0% { background: #fef08a; } 100% { background: transparent; } }

/* ---------- Qo'llanma ---------- */
.man-sec { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.man-sec h3 { margin: 0 0 8px; font-size: .95rem; color: var(--accent-dark); }
.man-sec ul { margin: 4px 0; padding-left: 20px; font-size: .85rem; }
.man-sec li { margin-bottom: 4px; }
.man-sec code { background: var(--blue-bg); padding: 1px 6px; border-radius: 6px; font-size: .8rem; }

/* ---------- Lab tahlil ---------- */
.lab-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: 10px; }
.lab-table th, .lab-table td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
.lab-table th { background: var(--blue-bg); font-size: .75rem; }
.lab-val { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lab-flag { font-size: .7rem; font-weight: 700; padding: 3px 9px; border-radius: 14px; white-space: nowrap; }
.lab-der td { background: #fffbeb; }
.lab-ref { color: var(--muted); max-width: 170px; }
.lab-raw summary { cursor: pointer; font-size: .8rem; color: var(--accent-dark); font-weight: 600; }
.lab-raw pre { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: .72rem; max-height: 220px; overflow: auto; white-space: pre-wrap; }

/* ---------- Hujjatlar (jurnal / retsept / xulosa) ---------- */
.jr-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: .85rem; }
.jr-dt { white-space: nowrap; font-weight: 700; color: var(--accent-dark); font-size: .78rem; padding-top: 2px; }
.jr-main { flex: 1; }
.jr-note { font-style: italic; color: #475569; margin-top: 2px; }
.rx-row { display: flex; gap: 8px; align-items: center; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: .85rem; flex-wrap: wrap; }
.rx-name { flex: 0 0 200px; font-weight: 700; }
.rx-dose { flex: 1; min-width: 140px; }
.rx-days { width: 70px; }
.rx-freq { color: var(--muted); font-size: .78rem; max-width: 240px; }
textarea { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: .95rem; background: #fff; color: var(--ink); width: 100%; font-family: inherit; resize: vertical; }
textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* ---------- Chop etish (PDF) ---------- */
#printArea { display: none; }
.pr-doc { max-width: 700px; margin: 0 auto; font-family: Georgia, "Times New Roman", serif; color: #111; font-size: 12.5px; line-height: 1.5; }
.pr-head { text-align: center; border-bottom: 3px double #111; padding-bottom: 8px; margin-bottom: 12px; }
.pr-title { font-size: 20px; font-weight: bold; letter-spacing: 4px; }
.pr-sub { font-size: 11px; color: #444; margin-top: 2px; }
.pr-row { display: flex; justify-content: space-between; gap: 14px; font-size: 12px; margin: 4px 0 10px; flex-wrap: wrap; }
.pr-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px; }
.pr-table th, .pr-table td { border: 1px solid #555; padding: 5px 8px; text-align: left; vertical-align: top; }
.pr-table th { background: #eee; }
.pr-sign { display: flex; gap: 40px; margin-top: 34px; font-size: 12px; }
.pr-sign > div { flex: 1; border-top: 1px solid #333; padding-top: 4px; }
.pr-note { font-size: 10px; color: #555; margin-top: 18px; font-style: italic; }

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
  .row { gap: 10px; }
  .row > label { min-width: 100%; }
  .tabs { grid-template-columns: repeat(2, 1fr); }
  .sr-sub { display: none; }
}

/* ---------- Print ---------- */
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  body { background: #fff; }
}

/* ---------- v1.7: emlash, o'sish, yorliqlar ---------- */
.vax-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.vax-row:last-child { border-bottom: none; }
.vax-row input[type="checkbox"] { width: auto; margin-top: 4px; }
.vax-row.ok .vax-label { text-decoration: line-through; color: var(--green); }
.vax-row.late { background: var(--red-bg); border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.vax-row.up .badge { background: var(--blue-bg); }
.vax-main { flex: 1; }
.vax-label { font-size: .9rem; font-weight: 600; }
.vax-when { color: var(--muted); }
.growth-canvas { width: 100%; max-width: 760px; height: 400px; background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-top: 8px; }
.pr-label { border: 2px dashed #666; border-radius: 8px; padding: 10px 12px; margin: 8px 0; break-inside: avoid; page-break-inside: avoid; }
.lb-name { font-size: 15px; font-weight: 700; }
.lb-dose { font-size: 13px; font-weight: 600; margin-top: 2px; }
.lb-freq { font-size: 12px; color: #333; margin-top: 2px; }
.lb-meta { font-size: 10px; color: #555; margin-top: 6px; border-top: 1px solid #999; padding-top: 3px; }
@media print { .pr-label { border-color: #000; } }

/* ---------- Referanslar (v1.9) ---------- */
.ref-item { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #fff; overflow: hidden; }
.ref-item summary { display: flex; align-items: baseline; gap: 8px; padding: 10px 12px; cursor: pointer; font-size: .88rem; flex-wrap: wrap; }
.ref-item summary:hover { background: var(--blue-bg); }
.ref-title { font-weight: 700; flex: 1; min-width: 120px; }
.ref-sub { font-size: .75rem; color: var(--muted); }
.ref-body { padding: 0 12px 10px; }
.ref-text { font-size: .82rem; white-space: pre-wrap; line-height: 1.5; margin: 4px 0; font-family: inherit; }

.brand-line {
  display: flex;
  align-items: center;
  gap: 7px;
  opacity: .85;
}
