:root {
  --bg: #f3efe6;
  --surface: #fffcf6;
  --ink: #1b2422;
  --muted: #5e6b67;
  --line: #e3dacb;
  --teal: #0f6b62;
  --teal-dark: #123e3b;
  --teal-soft: #e5f2ef;
  --sand: #efe4d2;
  --coral: #a84832;
  --coral-soft: #f8e6df;
  --gold: #8d6b32;
  --shadow: 0 18px 50px rgba(28, 40, 36, 0.08);
  --sidebar: 248px;
  --radius: 18px;
  --font: "Figtree", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1.05fr) minmax(320px, 0.95fr);
}
.login-brand {
  background:
    radial-gradient(900px 420px at -10% -10%, rgba(255, 236, 196, 0.18), transparent 55%),
    linear-gradient(165deg, #184743 0%, #102c2a 70%);
  color: #f6f1e6;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
}
.mark {
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
}
.mark-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f3efe4;
  color: var(--teal-dark);
  display: grid;
  place-items: center;
}
.login-brand h1 {
  font-family: var(--display);
  font-size: clamp(42px, 5vw, 68px);
  font-weight: 520;
  letter-spacing: -0.03em;
  line-height: 0.95;
  max-width: 12ch;
}
.login-brand .lede {
  margin-top: 18px;
  max-width: 36ch;
  color: rgba(246, 241, 230, 0.78);
  font-size: 17px;
  line-height: 1.45;
}
.points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; }
.points li {
  display: flex;
  gap: 10px;
  align-items: center;
  color: rgba(246, 241, 230, 0.9);
}
.points i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e7c98a;
  display: block;
  flex: none;
}
.fine {
  font-size: 13px;
  color: rgba(246, 241, 230, 0.62);
}
.login-panel {
  display: grid;
  place-items: center;
  padding: 32px 24px;
}
.card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.card h2 {
  font-family: var(--display);
  font-size: 36px;
  font-weight: 520;
  margin: 8px 0 8px;
}
.card .sub { color: var(--muted); line-height: 1.45; margin-bottom: 22px; }
label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
input, select, textarea {
  width: 100%;
  background: #fff;
  border: 1px solid #ddd4c4;
  border-radius: 12px;
  padding: 12px 13px;
  outline: none;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 107, 98, 0.12);
}
.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--teal);
  color: white;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover { background: #0c5c54; }
.btn.block { width: 100%; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost:hover { background: #fff; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.note {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }
.sidebar {
  background: var(--teal-dark);
  color: #f4efe6;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-brand { padding: 6px 10px 18px; }
.side-brand strong {
  display: block;
  font-family: var(--display);
  font-size: 26px;
  font-weight: 520;
}
.side-brand span { color: rgba(244, 239, 230, 0.62); font-size: 13px; }
.nav { display: grid; gap: 4px; }
.nav button {
  text-align: left;
  background: transparent;
  color: rgba(244, 239, 230, 0.84);
  border: 0;
  border-radius: 12px;
  padding: 11px 12px;
  font-weight: 650;
}
.nav button.active, .nav button:hover { background: rgba(255, 255, 255, 0.08); color: white; }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding: 12px 8px 0; }
.side-foot p { font-size: 12px; color: rgba(244, 239, 230, 0.55); line-height: 1.4; }
.linkish {
  background: transparent;
  border: 0;
  color: #e7c98a;
  padding: 0;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
}
.main { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 0;
}
.topbar h1 {
  font-family: var(--display);
  font-size: 34px;
  font-weight: 520;
}
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--sand); color: var(--teal-dark);
  display: grid; place-items: center; font-weight: 800;
}
.menu-btn { display: none; }

.content { padding: 22px 28px 40px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
}
.stat span { color: var(--muted); font-size: 13px; font-weight: 650; }
.stat strong {
  display: block;
  margin-top: 8px;
  font-family: var(--display);
  font-size: 36px;
  font-weight: 520;
  letter-spacing: -0.03em;
}
.grid-2 { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 14px; margin-top: 14px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.panel-head, .toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.panel h2, .toolbar h2 { font-size: 18px; font-weight: 750; }
.row-item, .patient-row {
  display: grid;
  gap: 8px 12px;
  align-items: center;
  padding: 12px 4px;
  border-top: 1px solid var(--line);
}
.row-item { grid-template-columns: 72px 1fr auto; }
.time { font-variant-numeric: tabular-nums; font-weight: 750; color: var(--teal-dark); }
.muted { color: var(--muted); font-size: 13px; }
.name-btn {
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  font-weight: 750;
}
.name-btn:hover { color: var(--teal); }
.pill {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 750;
  border: 0;
  background: var(--sand);
  color: var(--ink);
}
.pill.en-sala { background: var(--teal-soft); color: var(--teal-dark); }
.pill.atendida { background: #e7f5df; color: #2d5a1e; }
.pill.cancelada { background: #eeeae4; color: #6d675f; }
.quick { display: grid; gap: 8px; }
.quick button { justify-content: flex-start; }

.toolbar .search { width: min(320px, 100%); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px 10px;
}
td { padding: 12px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #faf6ee; }
.person { display: flex; gap: 10px; align-items: center; }
.initials {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--teal-soft); color: var(--teal-dark);
  display: grid; place-items: center; font-weight: 800; flex: none;
}
.back {
  background: transparent; border: 0; color: var(--muted);
  padding: 0 0 8px; font-weight: 700;
}
.profile-head {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
  margin-bottom: 14px;
}
.profile-id { display: flex; gap: 14px; align-items: center; }
.profile-id .initials { width: 64px; height: 64px; border-radius: 18px; font-size: 22px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  background: var(--sand);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 650;
}
.alert {
  background: var(--coral-soft);
  color: var(--coral);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  margin-bottom: 14px;
}
.split { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 14px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 15px; }
.kv span { color: var(--muted); }
.timeline { display: grid; gap: 0; }
.visit {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.visit strong { display: block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.modal-back {
  position: fixed; inset: 0;
  background: rgba(20, 30, 28, 0.46);
  display: grid; place-items: center;
  padding: 20px;
  z-index: 20;
}
.modal {
  width: min(560px, 100%);
  max-height: min(90vh, 760px);
  overflow: auto;
  background: var(--surface);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--teal-dark);
  color: white;
  padding: 12px 14px;
  border-radius: 12px;
  z-index: 30;
  box-shadow: var(--shadow);
}
.empty { color: var(--muted); padding: 16px 0; }
.select-status {
  border-radius: 999px;
  padding: 6px 10px;
  border: 0;
  font-weight: 750;
  font-size: 12px;
  width: auto;
}

@media (max-width: 980px) {
  .login { grid-template-columns: 1fr; }
  .today-label { display: none; }
  .row-item { grid-template-columns: 64px 1fr; }
  .row-item .pill, .row-item .select-status { grid-column: 2; justify-self: start; }
  .toolbar { flex-wrap: wrap; align-items: flex-start; }
  .login-brand { min-height: auto; padding: 28px 22px; }
  .login-brand h1 { font-size: 42px; }
  .stats, .grid-2, .split, .form-grid { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 15;
    transform: translateX(-105%);
    width: min(84vw, 300px);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .scrim {
    position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 14;
  }
}
