:root{
  --bg:#f5f7fb;
  --card:#ffffff;
  --muted:#6b7280;
  --text:#111827;
  --line:#e8edf5;
  --blue:#2f6df6;
  --blue2:#1f5be0;
  --blueSoft:#e8f0ff;
  --green:#22c55e;
  --teal:#19d3c5;
  --orange:#ff6b6b;
  --shadow:0 10px 30px rgba(17,24,39,.06);
  --radius:14px;
  --radius2:18px;
  --sidebar:#ffffff;
  --sidebarLine:#eef2f7;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Helvetica Neue", "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background:var(--bg);
}

.i{ width:18px; height:18px; display:inline-block; }
.i.big{ width:42px; height:42px; }
a{ color:inherit; text-decoration:none; }

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

/* Sidebar */
.sidebar{
  width:260px;
  background:var(--sidebar);
  border-right:1px solid var(--sidebarLine);
  padding:16px 12px;
  position:sticky;
  top:0;
  height:100vh;
  display:flex;
  flex-direction:column;
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 10px 14px 10px;
}
.brand-icon{
  width:34px;height:34px;border-radius:12px;
  background:var(--blueSoft);
  display:grid;place-items:center;
  color:var(--blue);
}
.brand-icon.lg{ width:48px;height:48px;border-radius:16px; }
.brand-name{ font-weight:700; font-size:22px; letter-spacing:.2px; color:#1b2b50; }
.sidebar-close{ margin-left:auto; display:none; }

.nav{ display:flex; flex-direction:column; gap:6px; padding:8px 6px; }
.nav-item{
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 10px;
  border-radius:14px;
  color:#344054;
  font-weight:600;
}
.nav-item:hover{ background:#f3f6fb; }
.nav-item.active{ background:var(--blueSoft); color:#1b2b50; }

.nav-ico{
  width:38px;height:38px;border-radius:12px;
  background:#f3f6fb;
  display:grid; place-items:center;
  color:#4b5563;
}
.nav-item.active .nav-ico{ background:#dbe8ff; color:var(--blue); }
.nav-ico.danger{ background:#e9f0ff; color:var(--blue); position:relative; }
.nav-ico.danger::after{
  content:"";
  position:absolute;
  width:8px;height:8px;border-radius:50%;
  background:#ff3b30;
  top:6px; left:6px;
}

.sidebar-footer{ margin-top:auto; padding:10px 10px 12px; border-top:1px solid var(--sidebarLine); }

.footer-row{ display:flex; align-items:center; gap:10px; }
.footer-row .nav-item{ flex:1; }

.footer-lang-row{ padding-top:8px; display:flex; }

.lang-switch{ display:flex; gap:8px; max-width:100%; flex-wrap:wrap; }
.lang-btn{
  width:38px;
  height:38px;
  border-radius:12px;
  border:1px solid var(--sidebarLine);
  background:#fff;
  cursor:pointer;
  display:grid;
  place-items:center;
  box-shadow:0 1px 0 rgba(17,24,39,.02);
}
.lang-btn:hover{ background:#f3f6fb; }
.lang-btn.active{ background:var(--blueSoft); border-color:#dbe8ff; }
.lang-btn .flag{ font-size:18px; line-height:1; }

/* Main */
.main{
  flex:1;
  display:flex;
  flex-direction:column;
  min-width:0;
}
.topbar{
  display:flex;
  align-items:center;
  gap:14px;
  padding:18px 22px;
}
.burger{ display:none; }
.search{
  flex:1;
  max-width:720px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:16px;
  padding:10px 14px;
  display:flex;
  align-items:center;
  gap:10px;
  box-shadow:0 1px 0 rgba(17,24,39,.02);
}
.search input{
  width:100%;
  border:0;
  outline:none;
  font-size:14px;
  background:transparent;
}
.search-ico{ color:#98a2b3; }

.topbar-right{ margin-left:auto; display:flex; align-items:center; gap:10px; }
.icon-btn{
  border:0;
  background:transparent;
  padding:8px;
  border-radius:12px;
  cursor:pointer;
  color:#667085;
}
.icon-btn:hover{ background:#f0f4ff; color:#1b2b50; }

/* Tooltip simples */
.tip{ position:relative; }
.tip:hover::after{
  content: attr(data-tip);
  position:absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17,24,39,.92);
  color:#fff;
  font-size:12px;
  padding:6px 8px;
  border-radius:10px;
  white-space:nowrap;
  pointer-events:none;
  z-index:50;
}
.tip:hover::before{
  content: '';
  position:absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border:6px solid transparent;
  border-top-color: rgba(17,24,39,.92);
  pointer-events:none;
  z-index:50;
}

.dot{
  position:absolute;
  width:8px;height:8px;border-radius:50%;
  background:#ffb020;
  transform:translate(10px,-16px);
}

.userchip{
  display:flex;
  align-items:center;
  gap:10px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:18px;
  padding:8px 10px;
}
.avatar{
  width:34px;height:34px;border-radius:50%;
  background:#e8f0ff;
  color:var(--blue);
  display:grid;place-items:center;
  font-weight:800;
}
.avatar.lg{ width:44px;height:44px; }
.userchip-meta{ line-height:1.1; }
.userchip-name{ font-weight:700; font-size:13px; }
.userchip-role{ font-size:11px; color:var(--muted); margin-top:2px; }

/* Content */
.content{ padding:0 22px 28px 22px; }
.page-head{
  display:flex;
  align-items:center;
  gap:16px;
  margin:6px 0 14px 0;
}
.page-head h1{ margin:0; font-size:28px; letter-spacing:.2px; }
.toolbar{
  margin-left:auto;
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  color:#667085;
}
.tool{
  border:0;
  background:transparent;
  padding:8px 10px;
  border-radius:12px;
  cursor:pointer;
  display:flex;
  gap:8px;
  align-items:center;
  font-weight:600;
  color:#667085;
}
.tool:hover{ background:#eef4ff; color:#1b2b50; }
.slider{
  width:150px;
  height:8px;
  background:#e7eefb;
  border-radius:999px;
  position:relative;
}
.slider span{
  position:absolute;
  left:55%;
  top:-6px;
  width:18px;height:18px;border-radius:50%;
  background:#1f2937;
}

/* Grid / Cards */
.grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap:18px;
}
.card{
  grid-column: span 4;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius2);
  padding:16px 16px;
  box-shadow:var(--shadow);
}
.card.tall{ grid-column: span 4; grid-row: span 3; }
.card.wide{ grid-column: span 8; }
.card-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:10px;
}
.card-head h3{ margin:0; font-size:16px; }
.card-actions{ display:flex; gap:6px; }
.row{
  display:flex; align-items:center; gap:12px;
}
.grow{ flex:1; min-width:0; }
.muted{ color:var(--muted); font-size:13px; }
.title{ font-weight:800; margin-top:2px; }
.linkish{ color:var(--blue); font-weight:700; cursor:pointer; }
.divider{ height:1px; background:var(--line); margin:12px 0; }
.divider.dotted{ background:transparent; border-top:2px dotted #d9e1ef; height:0; margin:12px 0; }

.meta-row{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.meta{ display:flex; align-items:center; gap:8px; color:#475467; font-weight:700; font-size:13px; }

.pills{ display:flex; gap:10px; margin-top:10px; align-items:center; }
.pill{
  border:1px solid var(--line);
  background:#f7f9fe;
  padding:6px 10px;
  border-radius:999px;
  font-weight:800;
  font-size:12px;
  cursor:pointer;
  color:#344054;
}
.pill:hover{ background:#eef4ff; border-color:#dbe8ff; }
.pill.right{ margin-left:auto; }
.icon-pill{
  width:40px;height:40px;border-radius:50%;
  border:1px solid var(--line);
  background:#f7f9fe;
  display:grid;place-items:center;
  cursor:pointer;
}
.icon-pill:hover{ background:#eef4ff; border-color:#dbe8ff; }

.empty{ padding:18px; text-align:center; color:var(--muted); }

.list{ display:flex; flex-direction:column; gap:0; }
.appt{ display:flex; gap:12px; align-items:flex-start; padding:8px 0; }
.appt .title{ font-size:14px; }
.appt .meta-row{ justify-content:flex-start; gap:16px; margin-top:6px; }

.bars{ display:flex; gap:14px; align-items:flex-end; padding-top:8px; }
.bar{ width:42px; text-align:center; }
.bar-col{
  width:10px;
  height:90px;
  margin:0 auto 6px auto;
  background:#e8edf5;
  border-radius:999px;
  display:flex;
  align-items:flex-end;
  overflow:hidden;
}
.bar-fill{
  width:100%;
  background:var(--blue);
  border-radius:999px;
}
.bar-lab{ font-size:11px; color:#667085; }

.spark{ width:100%; height:160px; margin-top:8px; }
.spark .line{ fill:none; stroke-width:4; stroke-linecap:round; }
.spark .line.a{ stroke:var(--green); }
.spark .line.b{ stroke:var(--teal); }
.spark .dot{ fill:#fff; stroke-width:4; }
.spark .dot.a{ stroke:var(--green); }
.spark .dot.b{ stroke:var(--teal); }

.legend{ display:flex; gap:18px; font-size:11px; font-weight:900; color:#667085; }
.legend .sw{ display:inline-block; width:10px; height:10px; border-radius:999px; margin-right:8px; }
.legend .sw.a{ background:var(--green); }
.legend .sw.b{ background:var(--teal); }

.tabs{ display:flex; gap:12px; margin:8px 0 12px 0; }
.tab{
  border:0;
  background:transparent;
  font-weight:900;
  color:#98a2b3;
  cursor:pointer;
}
.tab.active{ color:var(--blue); }

.seg{ display:flex; gap:0; background:#f7f9fe; border:1px solid var(--line); border-radius:12px; overflow:hidden; }
.seg.small .seg-btn{ padding:7px 10px; font-size:12px; }
.seg-btn{
  border:0; background:transparent; padding:8px 14px;
  font-weight:900; cursor:pointer; color:#98a2b3;
}
.seg-btn.active{ background:#fff; color:var(--blue); }

.prog{ margin-top:12px; }
.prog-row{ display:flex; justify-content:space-between; align-items:center; gap:10px; font-size:13px; }
.prog-lab{ color:#475467; font-weight:800; }
.prog-bar{
  height:8px; background:#ffe5e5; border-radius:999px; overflow:hidden; margin-top:8px;
}
.prog-bar span{ display:block; height:100%; background:#ff5b5b; }
.prog-bar.green{ background:#eaf9f0; }
.prog-bar.green span{ background:var(--green); }
.prog-bar.blue{ background:#e8f0ff; }
.prog-bar.blue span{ background:var(--blue); }

/* Buttons, Forms, Modal */
.btn{
  border:1px solid var(--line);
  background:#fff;
  padding:10px 14px;
  border-radius:14px;
  cursor:pointer;
  font-weight:900;
  display:inline-flex;
  gap:8px;
  align-items:center;
}
.btn:hover{ background:#f7f9fe; }
.btn.primary{ background:var(--blue); border-color:var(--blue); color:#fff; }
.btn.primary:hover{ background:var(--blue2); border-color:var(--blue2); }

.form{ display:flex; flex-direction:column; gap:10px; }
.field{ display:flex; flex-direction:column; gap:6px; }
.field span{ font-size:12px; color:#667085; font-weight:800; }
.field input, .field textarea{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px 12px;
  outline:none;
  font-size:14px;
  background:#fff;
}
.field input:focus, .field textarea:focus{ border-color:#c7d8ff; box-shadow:0 0 0 4px rgba(47,109,246,.08); }

.inline-search{
  display:flex; align-items:center; gap:10px;
  border:1px solid var(--line);
  background:#fff;
  padding:10px 12px;
  border-radius:14px;
}
.inline-search input{ border:0; outline:none; width:240px; background:transparent; }

.table-wrap{ overflow:auto; }
.table{
  width:100%;
  border-collapse:collapse;
  min-width:720px;
}
.table th, .table td{
  padding:12px 10px;
  border-bottom:1px solid var(--line);
  text-align:left;
  font-size:13px;
}
.table th{ color:#475467; font-weight:900; background:#fbfcff; position:sticky; top:0; }
.table td .mini{ font-size:12px; color:var(--muted); }

.modal{
  position:fixed;
  inset:0;
  background:rgba(17,24,39,.35);
  display:none;
  padding:16px;
  z-index:50;
}
.modal.show{ display:flex; align-items:center; justify-content:center; }
.modal-card{
  width:min(720px, 100%);
  background:#fff;
  border-radius:18px;
  border:1px solid var(--line);
  box-shadow:0 30px 80px rgba(17,24,39,.2);
  padding:14px;
}
.modal-head{ display:flex; align-items:center; justify-content:space-between; padding:6px 6px 10px 6px; }
.modal-actions{ display:flex; gap:10px; justify-content:flex-end; margin-top:6px; }
.grid2{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }

/* Patient page */
.patient-grid{ grid-template-columns: repeat(12, 1fr); }
.patient-grid .card{ grid-column: span 4; }
.patient-grid .card.wide{ grid-column: span 8; }

.kv{ display:flex; flex-direction:column; gap:10px; }
.kv > div{ display:flex; justify-content:space-between; gap:10px; }
.kv span{ color:#667085; font-weight:800; font-size:12px; }
.kv b{ font-size:13px; }
.text{ white-space:pre-wrap; color:#344054; }

.mini-list{ display:flex; flex-direction:column; gap:10px; margin-top:8px; }
.mini-item{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:10px; border:1px solid var(--line); border-radius:14px; background:#fbfcff; }
.mini-item .mini-title{ font-weight:900; font-size:13px; }
.badge{ padding:4px 10px; border-radius:999px; font-size:12px; font-weight:900; border:1px solid var(--line); background:#fff; color:#344054; }
.badge.blue{ border-color:#dbe8ff; background:#eef4ff; color:var(--blue); }
.badge.red{ border-color:#ffe5e5; background:#fff3f3; color:#ff3b30; }
.badge.gray{ border-color:#e5e7eb; background:#f3f4f6; color:#374151; }

.notes{ display:flex; flex-direction:column; gap:12px; margin-top:10px; }
.note{
  border:1px solid var(--line);
  background:#fbfcff;
  border-radius:16px;
  padding:12px;
}
.note-head{ display:flex; justify-content:space-between; align-items:center; gap:10px; }
.note-time{ font-size:12px; color:#667085; font-weight:900; }
.note-text{ margin-top:8px; white-space:pre-wrap; color:#344054; }
.note-actions{ display:flex; gap:6px; }

/* Auth */
.auth-body{ background:linear-gradient(180deg,#f5f7fb 0%, #eef4ff 100%); }
.auth{ min-height:100vh; display:grid; place-items:center; padding:20px; }
.auth-card{
  width:min(420px, 100%);
  background:#fff;
  border:1px solid var(--line);
  border-radius:22px;
  box-shadow:0 30px 80px rgba(17,24,39,.12);
  padding:18px;
}
.auth-brand{ display:flex; align-items:center; gap:12px; margin-bottom:10px; }
.auth-title{ font-weight:900; font-size:18px; }
.auth-sub{ color:var(--muted); font-weight:800; font-size:12px; margin-top:2px; }
.alert{
  background:#fff3f3;
  border:1px solid #ffd6d6;
  color:#b42318;
  border-radius:14px;
  padding:10px 12px;
  margin:10px 0;
  font-weight:900;
  font-size:13px;
}
.hint{ color:var(--muted); font-size:12px; font-weight:800; margin:10px 0 0 0; }

/* Responsive */
@media (max-width: 1100px){
  .grid{ grid-template-columns: repeat(6, 1fr); }
  .card{ grid-column: span 3; }
  .card.tall{ grid-column: span 6; }
  .card.wide{ grid-column: span 6; }
  .patient-grid .card{ grid-column: span 6; }
  .patient-grid .card.wide{ grid-column: span 6; }
}
@media (max-width: 820px){
  .sidebar{
    position:fixed;
    left:-280px;
    top:0;
    height:100vh;
    z-index:60;
    transition:left .18s ease;
  }
  .sidebar.open{ left:0; }
  .sidebar-close{ display:inline-flex; }
  .burger{ display:inline-flex; }
  .topbar{ padding:14px 14px; }
  .content{ padding:0 14px 18px 14px; }
  .search{ max-width:none; }
  .grid{ grid-template-columns: repeat(1, 1fr); }
  .card, .card.tall, .card.wide{ grid-column: span 1; }
  .table{ min-width:640px; }
  .grid2{ grid-template-columns:1fr; }
  .inline-search input{ width:160px; }
}

.icon-btn.danger{ color:#ef4444; }
.icon-btn.danger:hover{ background:rgba(239,68,68,.12); }

.grid-2{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
@media (max-width:900px){ .grid-2{ grid-template-columns:1fr; } }
