:root {
  --ink: #0e1f40;
  --ink-2: #17345f;
  --paper: #f6f8f4;
  --panel: #ffffff;
  --panel-2: #eef7f1;
  --line: #d9e1dc;
  --muted: #64706f;
  --text: #17202b;
  --green: #2f9f72;
  --green-2: #dff4e9;
  --teal: #1e9aae;
  --teal-2: #def3f6;
  --amber: #d99628;
  --amber-2: #fff2d8;
  --coral: #d75b4c;
  --coral-2: #ffe6e2;
  --violet: #6156a8;
  --violet-2: #ece9ff;
  --shadow: 0 14px 42px rgba(14, 31, 64, 0.08);
  --radius: 8px;
  --sidebar: 264px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--text);
  font-family: Inter, Figtree, "Noto Sans", Arial, sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

body {
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a,
select,
summary,
[role="button"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(30, 154, 174, 0.35);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 18px;
  z-index: 10;
}

.brand {
  padding: 8px 10px 14px;
  border-bottom: 1px solid var(--line);
}

.brand img {
  display: block;
  width: 178px;
  height: auto;
}

.brand small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  padding-right: 2px;
}

.nav button {
  border: 0;
  background: transparent;
  color: #263648;
  padding: 10px 10px;
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  text-align: left;
  min-height: 44px;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav button:hover {
  background: #edf4f3;
}

.nav button.active {
  background: var(--ink);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(14, 31, 64, 0.16);
}

.nav .nav-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(14, 31, 64, 0.08);
  color: inherit;
  font-size: 12px;
  font-weight: 800;
}

.nav button.active .nav-icon {
  background: rgba(255, 255, 255, 0.18);
}

.sidebar-footer {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfa;
  color: var(--muted);
  line-height: 1.4;
}

.sidebar-footer strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.content {
  min-width: 0;
  padding: 22px 28px 40px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  margin: 0 0 4px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 30px;
  line-height: 1.12;
}

h2 {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
  margin-bottom: 12px;
}

h3 {
  color: var(--ink);
  font-size: 15px;
  margin-bottom: 8px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 900px;
  line-height: 1.45;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button,
button.button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border .18s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(14, 31, 64, 0.16);
}

.button.secondary {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.button.green {
  background: var(--green);
}

.button.teal {
  background: var(--teal);
}

.button.amber {
  background: var(--amber);
}

.button.danger {
  background: var(--coral);
}

.button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: transparent;
}

.button.small {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.cols-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

.panel.tight {
  padding: 12px;
}

.metric {
  min-height: 116px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-value {
  color: var(--ink);
  font-size: 27px;
  font-weight: 900;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.metric-foot {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2f0;
  color: #405057;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.green {
  background: var(--green-2);
  color: #146145;
}

.pill.teal {
  background: var(--teal-2);
  color: #0c6371;
}

.pill.amber {
  background: var(--amber-2);
  color: #7a4e0d;
}

.pill.coral {
  background: var(--coral-2);
  color: #873326;
}

.pill.violet {
  background: var(--violet-2);
  color: #39307f;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.panel-head p {
  margin: 3px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.chart {
  width: 100%;
  min-height: 260px;
}

.chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.funnel {
  display: grid;
  gap: 8px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 122px minmax(120px, 1fr) 46px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.bar {
  height: 12px;
  border-radius: 99px;
  overflow: hidden;
  background: #edf1ed;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.bar.green span {
  background: var(--green);
}

.bar.amber span {
  background: var(--amber);
}

.bar.coral span {
  background: var(--coral);
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.field,
.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: #ffffff;
  color: var(--text);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .wide {
  grid-column: span 2;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 860px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--ink);
  font-size: 12px;
  text-transform: uppercase;
  background: #f7faf7;
}

td {
  color: #2f3d48;
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-col {
  background: #f8faf7;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 360px;
  padding: 10px;
}

.kanban-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-weight: 900;
  margin-bottom: 10px;
}

.lead-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 10px;
  margin-bottom: 8px;
  box-shadow: 0 7px 18px rgba(14, 31, 64, 0.06);
}

.lead-card[draggable="true"] {
  cursor: grab;
}

.lead-card strong {
  color: var(--ink);
  display: block;
  margin-bottom: 4px;
}

.lead-card p {
  color: var(--muted);
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.35;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  padding: 4px;
}

.day {
  min-height: 108px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.day.muted {
  opacity: 0.45;
}

.day-number {
  color: var(--ink);
  font-weight: 900;
  font-size: 12px;
}

.event {
  border-radius: 6px;
  padding: 4px 6px;
  color: #183044;
  font-size: 11px;
  line-height: 1.25;
  background: var(--teal-2);
  border-left: 3px solid var(--teal);
}

.event.reconsulta {
  background: var(--green-2);
  border-color: var(--green);
}

.event.atrasado {
  background: var(--coral-2);
  border-color: var(--coral);
}

.event.proximo {
  background: var(--amber-2);
  border-color: var(--amber);
}

.insight-list {
  display: grid;
  gap: 10px;
}

.insight {
  border: 1px solid var(--line);
  border-left: 5px solid var(--amber);
  border-radius: var(--radius);
  padding: 12px;
  background: #ffffff;
}

.insight.high {
  border-left-color: var(--coral);
}

.insight.medium {
  border-left-color: var(--amber);
}

.insight.low {
  border-left-color: var(--teal);
}

.insight h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.insight p {
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 10px;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
}

.patient-summary {
  display: grid;
  gap: 10px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #ffffff;
  font-weight: 900;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 3px solid var(--teal);
  padding-left: 10px;
}

.timeline-item strong {
  display: block;
  color: var(--ink);
}

.timeline-item small,
.empty,
.hint {
  color: var(--muted);
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px;
}

.audit-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.audit-main .pill {
  justify-self: start;
}

.audit-main strong {
  color: var(--ink);
  line-height: 1.25;
}

.audit-main small {
  color: var(--muted);
  line-height: 1.35;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.team-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.team-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.team-top h2 {
  margin: 0 0 3px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.team-top p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.team-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scope-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scope-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  background: #fbfcfa;
  font-size: 12px;
  font-weight: 800;
}

.diff-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
}

.diff-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 31, 64, 0.42);
}

.diff-dialog {
  position: relative;
  width: min(920px, 100%);
  max-height: min(720px, 92vh);
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 22px 70px rgba(14, 31, 64, 0.28);
  padding: 16px;
}

.diff-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.diff-grid > div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  padding: 12px;
  min-width: 0;
}

.diff-grid strong {
  display: block;
  color: var(--ink);
  margin-bottom: 8px;
}

.diff-grid pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
  color: #2f3d48;
  line-height: 1.45;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #ffffff;
  text-align: center;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.integration {
  min-height: 168px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.integration h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.integration p {
  color: var(--muted);
  line-height: 1.42;
  margin-bottom: auto;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 14px;
}

.notice {
  border: 1px solid rgba(217, 150, 40, 0.45);
  background: #fff8e9;
  color: #6c450a;
  padding: 12px;
  border-radius: var(--radius);
  line-height: 1.4;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  max-width: 420px;
  background: var(--ink);
  color: #ffffff;
  padding: 12px 14px;
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(14, 31, 64, 0.22);
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card img {
  width: 210px;
  display: block;
  margin-bottom: 20px;
}

.login-card p {
  color: var(--muted);
  line-height: 1.45;
}

.mobile-head {
  display: none;
}

@media (max-width: 1180px) {
  .grid.cols-5,
  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.cols-3,
  .integration-grid,
  .team-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split,
  .profile-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .mobile-head img {
    width: 136px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    width: min(310px, 88vw);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content {
    padding: 16px 14px 32px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: flex-start;
  }

  h1 {
    font-size: 25px;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .grid.cols-5,
  .integration-grid,
  .team-grid,
  .diff-grid {
    grid-template-columns: 1fr;
  }

  .audit-item {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .wide {
    grid-column: auto;
  }

  .calendar {
    grid-template-columns: 1fr;
  }

  .calendar-head {
    display: none;
  }

  .day {
    min-height: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
