:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-muted: #eef3ee;
  --ink: #17201d;
  --muted: #637069;
  --faint: #87928c;
  --line: #d9e0dc;
  --blue: #1769aa;
  --blue-soft: #e6f1fa;
  --green: #24745a;
  --green-soft: #e5f3ed;
  --amber: #a56414;
  --amber-soft: #fff1da;
  --coral: #b74b3f;
  --coral-soft: #fbe9e6;
  --red: #a33b35;
  --red-soft: #f9e7e5;
  --shadow: 0 14px 32px rgba(25, 36, 32, 0.08);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

h1,
h2,
h3,
p,
span,
strong,
em,
li,
td,
th,
button {
  overflow-wrap: break-word;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
  background:
    linear-gradient(135deg, rgba(23, 105, 170, 0.1), transparent 36%),
    var(--bg);
}

.login-panel {
  width: min(100%, 520px);
  display: grid;
  gap: 24px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand strong,
.login-brand span {
  display: block;
}

.login-brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.login-copy h1 {
  margin: 6px 0 10px;
  font-size: 34px;
  line-height: 1.05;
}

.login-form {
  display: grid;
  gap: 8px;
}

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

.login-input-row {
  display: flex;
  gap: 10px;
}

.login-input-row input {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
}

.login-status {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
}

.login-status.success {
  color: var(--green);
}

.login-status.warning {
  color: var(--amber);
}

.login-status.error {
  color: var(--red);
}

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 10px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand span,
.sidebar-status strong,
.sidebar-status span {
  display: block;
}

.brand span,
.sidebar-status span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.nav-item svg,
.icon-button svg,
.primary-button svg,
.secondary-button svg,
.search-box svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.sidebar-status {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface-muted);
  border-radius: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 24px;
  background: rgba(246, 247, 244, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.search-box {
  flex: 1;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 680px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sudo-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sudo-switcher[hidden] {
  display: none !important;
}

.sudo-switcher span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.icon-button {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.count-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--coral);
  color: white;
  font-size: 11px;
  font-weight: 700;
}

.session-button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.session-button svg {
  width: 16px;
  height: 16px;
}

select {
  height: 40px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.content {
  padding: 24px;
  min-width: 0;
  overflow-x: hidden;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

h1 {
  max-width: 880px;
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  font-size: 52px;
  line-height: 1;
  letter-spacing: 0;
}

h3 {
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.eyebrow,
.card-label {
  margin-bottom: 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  line-height: 1.5;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.2fr) minmax(320px, 1fr) minmax(260px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.score-layout,
.team-grid,
.reports-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 16px;
}

.review-layout,
.messages-layout {
  display: grid;
  grid-template-columns: minmax(640px, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.portal-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.portal-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.35fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.card {
  min-width: 0;
  overflow-wrap: break-word;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.hero-card {
  background: #fbfdfb;
}

.side-panel {
  display: grid;
  gap: 16px;
}

.card-header,
.table-header,
.conversation-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.success {
  color: var(--green);
  background: var(--green-soft);
}

.pill.warning {
  color: var(--amber);
  background: var(--amber-soft);
}

.pill.danger {
  color: var(--red);
  background: var(--red-soft);
}

.score-strip,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

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

.score-strip div,
.metric-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.score-strip span,
.metric-box span,
.metric-box em,
.day-card span,
.day-card em,
.task-row em,
.inbox-item span,
.inbox-item em,
.thread-item span,
.table-header span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.score-strip strong,
.metric-box strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.task-list,
.inbox-list,
.thread-list,
.message-stack {
  display: grid;
  gap: 10px;
}

.task-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.inbox-item,
.thread-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
}

.inbox-item:hover,
.thread-item:hover,
.thread-item.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(94px, 1fr));
  gap: 10px;
}

.day-card {
  min-height: 104px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.today-marker {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.primary-button,
.secondary-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 800;
  white-space: nowrap;
  text-align: center;
}

.primary-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: white;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--blue);
}

.full-width {
  width: 100%;
}

.segmented-control {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented-control button {
  min-width: 78px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segmented-control button.active {
  color: white;
  background: var(--blue);
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.selected-row {
  background: var(--blue-soft);
}

.up {
  color: var(--green);
  font-weight: 800;
}

.warn {
  color: var(--amber);
  font-weight: 800;
}

.risk-row {
  background: var(--red-soft);
}

.table-action {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.flush-row {
  margin-top: 0;
}

.metric-card {
  display: grid;
  gap: 4px;
}

.metric-card strong {
  font-size: 32px;
  line-height: 1;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card.attention {
  border-color: #efc2ba;
  background: #fffafa;
}

.coach-ai-card,
.client-snapshot,
.portal-messages {
  align-self: stretch;
}

.suggested-message {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.suggested-message p {
  color: var(--muted);
  line-height: 1.45;
}

.filter-row,
.template-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-row button,
.template-row button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.filter-row button.active,
.template-row button:hover {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: var(--blue);
}

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}

.snapshot-grid div {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.snapshot-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.snapshot-grid strong {
  font-size: 14px;
}

.portal-feed,
.mini-inbox {
  display: grid;
  gap: 10px;
}

.feed-event {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.feed-event.high {
  border-color: #efc2ba;
  background: var(--red-soft);
}

.feed-event span {
  color: var(--muted);
  font-size: 13px;
}

.detail-drawer dl {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.detail-drawer div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
}

.form-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea,
.message-composer input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 10px;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.conversation {
  min-height: 560px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.conversation-header p {
  color: var(--muted);
  font-size: 13px;
}

.message-stack {
  flex: 1;
  align-content: start;
  padding: 12px;
  background: var(--surface-muted);
  border-radius: 8px;
  overflow: auto;
  min-width: 0;
}

.bubble {
  max-width: 68%;
  padding: 11px 12px;
  border-radius: 8px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.coach-bubble {
  justify-self: start;
  background: white;
  border: 1px solid var(--line);
}

.user-bubble {
  justify-self: end;
  background: var(--blue);
  color: white;
}

.message-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

.message-composer input {
  min-height: 40px;
  padding: 0 12px;
}

.check-list {
  display: grid;
  gap: 8px;
  padding-left: 18px;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 84px 1fr;
  }

  .brand div:not(.brand-mark),
  .nav-item span,
  .sidebar-status div {
    display: none;
  }

  .nav-item {
    justify-content: center;
  }

  .dashboard-grid,
  .portal-metrics,
  .portal-grid,
  .score-layout,
  .team-grid,
  .reports-grid,
  .settings-grid,
  .review-layout,
  .messages-layout {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }

  .side-panel,
  .wide-card {
    grid-column: span 2;
  }
}

@media (max-width: 820px) {
  .login-panel {
    padding: 24px;
  }

  .login-copy h1 {
    font-size: 28px;
  }

  .login-input-row {
    display: grid;
  }

  .app-shell {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .sidebar {
    padding: 12px 8px;
  }

  .brand {
    justify-content: center;
    padding-inline: 0;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .topbar {
    height: auto;
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }

  .search-box {
    max-width: none;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .session-button,
  .primary-button,
  .secondary-button,
  .table-action {
    white-space: normal;
  }

  .content {
    padding: 16px 12px;
  }

  .page-heading {
    display: grid;
  }

  h1 {
    font-size: 24px;
  }

  .dashboard-grid,
  .portal-metrics,
  .portal-grid,
  .score-layout,
  .team-grid,
  .reports-grid,
  .settings-grid,
  .review-layout,
  .messages-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-panel,
  .wide-card {
    grid-column: auto;
  }

  .week-grid,
  .metric-grid,
  .score-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-header {
    display: grid;
  }

  table {
    min-width: 620px;
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }

  .wide-card,
  .card {
    overflow-x: auto;
  }

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

  .message-composer {
    grid-template-columns: minmax(0, 1fr);
  }

  .task-row {
    grid-template-columns: 18px minmax(0, 1fr);
  }

  .task-row em {
    grid-column: 2;
  }

  .bubble {
    max-width: 92%;
  }
}
