/* LINH CLINIC – giao diện (ưu tiên điện thoại, đẹp cả trên máy tính) */
:root {
  --teal: #1f9e94; --teal-d: #0f766e; --teal-l: #e6f6f4;
  --rose: #e0607e; --rose-d: #b83d5c; --rose-l: #fdecf0;
  --ink: #1f2933; --mute: #6b7785; --line: #e4e9ee; --bg: #f5f8f9; --white: #fff;
  --ok: #2f9e5b; --warn: #c97a00; --err: #d64545; --err-l: #fdeeee; --warn-l: #fff6e0;
  --radius: 12px; --shadow: 0 1px 3px rgba(20, 40, 60, .08), 0 4px 14px rgba(20, 40, 60, .06);
  --hour-h: 56px; --nav-h: 58px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--teal-d); }
.muted { color: var(--mute); } .small { font-size: .85rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }

/* ---------- khung ứng dụng ---------- */
.shell { min-height: 100vh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--white); border-bottom: 1px solid var(--line); }
.logo { font-weight: 800; letter-spacing: .08em; color: var(--teal-d); font-size: 1.1rem; }
.logo b { color: var(--rose); font-weight: 800; }
.topbar .sp { flex: 1; }
.who { font-size: .85rem; color: var(--mute); text-align: right; line-height: 1.2; }
.main { padding: 14px; max-width: 1200px; margin: 0 auto; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; display: flex; background: var(--white); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 6px; font-size: .72rem; color: var(--mute); text-decoration: none; cursor: pointer; }
.nav a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.on { color: var(--teal-d); font-weight: 600; }
.nav a.more { display: flex; }
.nav a.side-only { display: none; }
@media (min-width: 900px) {
  .shell { padding-bottom: 0; padding-left: 210px; }
  .topbar { margin-left: -210px; padding-left: 224px; }
  .nav { top: 0; bottom: auto; right: auto; width: 210px; height: 100vh; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 62px 10px 10px; z-index: 35; }
  .nav a { flex: 0; flex-direction: row; gap: 10px; padding: 10px 12px; font-size: .95rem; border-radius: 10px; }
  .nav a.on { background: var(--teal-l); }
  .nav a.more { display: none; }
  .nav a.side-only { display: flex; }
  .topbar { z-index: 50; }
  .topbar .logo { position: absolute; left: 16px; }
}

/* ---------- thành phần ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--white); color: var(--ink); border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: var(--teal); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-d); }
.btn.rose { background: var(--rose); border-color: var(--rose); color: #fff; }
.btn.danger { color: var(--err); border-color: #f1c4c4; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--teal-d); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: .85rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
input, select, textarea { width: 100%; font: inherit; color: inherit; padding: 9px 11px; border: 1px solid #cfd8df; border-radius: 10px; background: #fff; min-height: 40px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal-l); border-color: var(--teal); }
input[type=checkbox] { width: auto; min-height: 0; }
.f { display: block; margin-bottom: 10px; }
.f > span { display: block; font-size: .82rem; color: var(--mute); margin-bottom: 3px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: 1fr 1fr 1fr; } }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.bar .grow { flex: 1; min-width: 160px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: #eef1f4; color: #435; white-space: nowrap; }
.badge.kham_benh { background: var(--teal-l); color: var(--teal-d); }
.badge.tham_my { background: var(--rose-l); color: var(--rose-d); }
.badge.debt { background: var(--err-l); color: var(--err); }
.badge.ok { background: #e6f6ec; color: var(--ok); }
.badge.warn { background: var(--warn-l); color: var(--warn); }
.s-dat { background: #e8eefc; color: #3558b6; } .s-den { background: #fff1d6; color: #a86500; } .s-dang_lam { background: #e0f4ff; color: #0a6aa1; }
.s-hoan_thanh { background: #e6f6ec; color: var(--ok); } .s-huy { background: #eee; color: #777; } .s-khong_den { background: var(--err-l); color: var(--err); }
.alert { padding: 10px 12px; border-radius: 10px; background: var(--warn-l); border: 1px solid #f3d99b; color: #7a4d00; margin-bottom: 12px; }
.alert.err { background: var(--err-l); border-color: #f1c4c4; color: #8c2b2b; }
.alert.ok { background: #e6f6ec; border-color: #bfe3cc; color: #1f6b3e; }
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item:hover { background: #fafcfc; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--teal-l); color: var(--teal-d); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { appearance: none; border: 0; background: none; padding: 10px 12px; font: inherit; font-weight: 600; color: var(--mute); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--teal-d); border-color: var(--teal); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.tbl th { text-align: left; font-size: .78rem; color: var(--mute); padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl td.num, table.tbl th.num { text-align: right; white-space: nowrap; }
.tblwrap { overflow-x: auto; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
@media (min-width: 800px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat .k { font-size: .78rem; color: var(--mute); font-weight: 600; }
.stat .v { font-size: 1.25rem; font-weight: 800; margin-top: 2px; word-break: break-word; }
.stat.debt .v { color: var(--err); } .stat.teal .v { color: var(--teal-d); } .stat.rose .v { color: var(--rose-d); }
.progress { height: 9px; background: #eef1f4; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--teal); }
.pkg { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.pkg.done { opacity: .65; }

/* ---------- hộp thoại ---------- */
.ov { position: fixed; inset: 0; z-index: 100; background: rgba(20, 30, 40, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--white); width: 100%; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 16px; }
.modal.wide { max-width: 760px; }
.modal h2 { margin-top: 0; }
.modal .foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
@media (min-width: 640px) { .ov { align-items: center; } .modal { max-width: 560px; border-radius: 16px; } .modal.wide { max-width: 800px; } }
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); z-index: 200; background: #20303c; color: #fff; padding: 10px 16px; border-radius: 10px; max-width: 90vw; box-shadow: var(--shadow); }
.toast.err { background: var(--err); }
.picker .results { border: 1px solid var(--line); border-radius: 10px; margin-top: 4px; max-height: 190px; overflow: auto; }
.picker .results .item { padding: 8px 10px; }
.chosen { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--teal); background: var(--teal-l); border-radius: 10px; }

/* ---------- lịch hẹn ---------- */
.cal { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 230px); min-height: 360px; position: relative; }
.cal-head, .cal-body { display: grid; grid-template-columns: 44px repeat(var(--cols), minmax(var(--colw, 128px), 1fr)); min-width: min-content; }
.cal-head { position: sticky; top: 0; z-index: 12; background: var(--white); border-bottom: 1px solid var(--line); }
.cal-head > div { padding: 8px 6px; text-align: center; font-weight: 700; font-size: .85rem; border-left: 1px solid var(--line); }
.cal-head > div.dayhead { cursor: pointer; } .cal-head > div.today { color: var(--teal-d); background: var(--teal-l); }
.cal-head > div:first-child { border-left: 0; position: sticky; left: 0; background: var(--white); z-index: 13; }
.cal-head small { display: block; font-weight: 500; color: var(--mute); }
.cal-axis { position: sticky; left: 0; z-index: 11; background: var(--white); }
.cal-axis div { height: var(--hour-h); font-size: .7rem; color: var(--mute); text-align: right; padding: 0 5px; transform: translateY(-7px); }
.cal-col { position: relative; border-left: 1px solid var(--line); cursor: cell;
  background-image: repeating-linear-gradient(to bottom, var(--line) 0, var(--line) 1px, transparent 1px, transparent calc(var(--hour-h) / 2)); }
.cal-col.today { background-color: #fbfefe; }
.ap { position: absolute; border-radius: 8px; padding: 3px 6px; font-size: .75rem; overflow: hidden; cursor: pointer; border-left: 4px solid; line-height: 1.25; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.ap b { display: block; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap.kham_benh { background: #d9f1ee; border-color: var(--teal); color: #0a4d47; }
.ap.tham_my { background: #fbdde5; border-color: var(--rose); color: #7a1f38; }
.ap.st-huy, .ap.st-khong_den { opacity: .45; text-decoration: line-through; }
.ap.st-hoan_thanh { filter: saturate(.55); }
.ap.st-dang_lam { box-shadow: 0 0 0 2px #0a6aa1; }
.ap.st-den { box-shadow: 0 0 0 2px #e6a020; }
.ap .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 3px; background: currentColor; opacity: .7; }
.nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--err); z-index: 5; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .78rem; color: var(--mute); margin: 8px 0 0; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------- báo cáo ---------- */
.chart { overflow-x: auto; }
.chart svg { display: block; }
.chart text { font: 11px system-ui, sans-serif; fill: var(--mute); }
.leg { display: flex; gap: 14px; font-size: .8rem; color: var(--mute); margin-bottom: 4px; }
.leg i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------- đăng nhập ---------- */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, var(--teal-l), #fff 55%, var(--rose-l)); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 26px 22px; box-shadow: var(--shadow); }
.login-card .logo { font-size: 1.6rem; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--mute); margin-bottom: 18px; }

/* ---------- badge nhóm mới, ảnh da, nhắc lịch ---------- */
.badge.san_pham { background: #efe9fb; color: #5b3fb0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.photo { position: relative; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: #eef1f4; cursor: pointer; }
.photo.sel { border-color: var(--rose); }
.photo img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.photo .tag { position: absolute; top: 6px; left: 6px; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: #fff; color: var(--ink); }
.photo .tag.truoc { background: var(--err-l); color: var(--err); } .photo .tag.trong { background: var(--warn-l); color: var(--warn); } .photo .tag.sau { background: #e6f6ec; color: var(--ok); }
.photo .cap { font-size: .75rem; padding: 4px 6px; background: #fff; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-big { display: block; max-width: 100%; max-height: 62vh; margin: 0 auto 8px; border-radius: 10px; }
.photo-prev { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.photo-prev img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; }
.cmp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cmp-cols img { width: 100%; border-radius: 8px; display: block; }
.cmp-stack { position: relative; max-width: 560px; margin: 0 auto; line-height: 0; }
.cmp-stack img { width: 100%; border-radius: 8px; display: block; }
.cmp-stack .cmp-top { position: absolute; inset: 0; height: 100%; object-fit: cover; }
.cmp-range { position: absolute; left: 0; right: 0; bottom: -34px; width: 100%; }
.cmp-stack { margin-bottom: 44px; }
.remind .msg { margin-top: 6px; padding: 8px 10px; background: var(--bg); border-radius: 8px; font-size: .88rem; white-space: pre-wrap; }
.remind.done { opacity: .75; }
