/* ===== Hermes Health — design system ===== */
:root {
  --bg: #f4f7f6;
  --bg-soft: #eef2f1;
  --surface: #ffffff;
  --surface-2: #f8fafa;
  --border: #e3e9e8;
  --text: #0f1f1c;
  --text-soft: #5b6b68;
  --muted: #8a9794;
  --primary: #0f766e;
  --primary-600: #0d6760;
  --primary-soft: #d7efec;
  --accent: #10b981;
  --danger: #e2483d;
  --warn: #d97706;
  --ok: #16a34a;
  --shadow: 0 1px 2px rgba(16,40,37,.05), 0 8px 24px rgba(16,40,37,.06);
  --shadow-lg: 0 10px 40px rgba(16,40,37,.14);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
[data-theme="dark"] {
  --bg: #0b1413;
  --bg-soft: #0f1c1a;
  --surface: #13211f;
  --surface-2: #182d2a;
  --border: #24403b;
  --text: #e8f1ef;
  --text-soft: #9fb3af;
  --muted: #6f827e;
  --primary: #2dd4bf;
  --primary-600: #14b8a6;
  --primary-soft: #143a36;
  --accent: #34d399;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 70% -10%, var(--primary-soft), transparent 60%), var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 40px 32px; box-shadow: var(--shadow-lg); text-align: center;
}
.login-logo { font-size: 46px; margin-bottom: 8px; }
.login-card h1 { font-size: 24px; }
.login-card p { color: var(--text-soft); margin: 6px 0 26px; }

/* ===== Layout ===== */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 280px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 22px; font-weight: 800; font-size: 18px; }
.brand .logo { font-size: 24px; }
.side-section { padding: 8px 14px; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 12px 10px 6px; font-weight: 700; }
.person-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  transition: background .15s; margin-bottom: 2px;
}
.person-item:hover { background: var(--surface-2); }
.person-item.active { background: var(--primary-soft); }
.avatar {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.person-meta { min-width: 0; }
.person-meta .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-meta .sub { font-size: 12px; color: var(--muted); }
.side-foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 28px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.topbar .title-area h2 { font-size: 20px; }
.topbar .title-area .sub { color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--surface); overflow-x: auto; }
.tab {
  padding: 13px 16px; cursor: pointer; color: var(--text-soft); font-weight: 600; font-size: 14px;
  border-bottom: 2.5px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.content { padding: 26px 28px 60px; flex: 1; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; transition: all .15s; font-size: 14px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-600); }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger:hover { background: rgba(226,72,61,.1); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; justify-content: center; }

/* ===== Cards ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 20px; }
.grid-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.section-head h3 { font-size: 17px; }

/* ===== Stats ===== */
.stat-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .lbl { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .val { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat .val small { font-size: 14px; color: var(--text-soft); font-weight: 600; }
.stat .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.green { background: rgba(22,163,74,.12); color: var(--ok); }
.badge.gray { background: var(--surface-2); color: var(--text-soft); }
.badge.amber { background: rgba(217,119,6,.13); color: var(--warn); }
.badge.teal { background: var(--primary-soft); color: var(--primary); }
.badge.red { background: rgba(226,72,61,.12); color: var(--danger); }

/* ===== Forms ===== */
.field { margin-bottom: 14px; text-align: left; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.input, .select, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2);
  outline: none; transition: border .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: var(--surface); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ===== Tables ===== */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 700; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ===== Modal ===== */
.modal-bg { position: fixed; inset: 0; background: rgba(8,20,18,.5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); width: 100%; max-width: 540px; max-height: 90vh; overflow: auto; }
.modal.lg { max-width: 820px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }

/* ===== Toast ===== */
#toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; animation: slideup .25s; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--primary); color: #fff; }
@keyframes slideup { from { transform: translateY(10px); opacity: 0; } }

/* ===== Empty ===== */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .ico { font-size: 40px; margin-bottom: 10px; }

/* ===== Dashboard grid ===== */
.dash-toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.grid-stack { background: transparent; }
.widget {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  height: 100%; display: flex; flex-direction: column; overflow: hidden;
}
.widget-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: move; }
.widget-head .wt { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.widget-body { flex: 1; padding: 10px 12px; position: relative; min-height: 0; }
.widget-body canvas { max-height: 100%; }
.widget-stat { padding: 16px; display: flex; flex-direction: column; justify-content: center; height: 100%; }
.widget-stat .v { font-size: 34px; font-weight: 800; }
.grid-stack-item-content { inset: 6px !important; }

/* ===== misc ===== */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.spacer { flex: 1; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.chip-toggle { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 500; background: var(--surface-2); }
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.muted { color: var(--muted); }
.flex { display: flex; align-items: center; gap: 10px; }
.mt { margin-top: 18px; }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; padding: 80px; }
.ref-pill { font-size: 11px; color: var(--muted); }
.val-out { color: var(--danger); font-weight: 700; }
.val-in { color: var(--ok); font-weight: 600; }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -300px; z-index: 50; transition: left .25s; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 60px; }
  .topbar { padding: 14px 16px; }
}
/* ===== Autocomplete (registrar dado) ===== */
.autocomplete-drop { position: absolute; left: 0; right: 0; top: 100%; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow-lg); max-height: 240px; overflow: auto; margin-top: 4px; }
.ac-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 13px; cursor: pointer; font-size: 14px; }
.ac-item:hover, .ac-item.active { background: var(--primary-soft); }
.ac-item .muted { font-size: 12px; }
.ac-add { color: var(--primary); border-top: 1px solid var(--border); }

.menu-btn { display: none; }
@media (max-width: 860px) { .menu-btn { display: inline-flex; } }
