
h1 {
  color: #2c3e50;
}

form {
  display: flex;
  flex-direction: column;
}

label {
  margin-bottom: 12px;
  font-weight: bold;
  font-size: 14px;
}

input, select, textarea {
  display: block;
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  font-size: 14px;
  box-sizing: border-box;
}

button {
  margin-top: 16px;
  padding: 10px;
  background-color: #2c3e50;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 16px;
}

button:hover {
  background-color: #34495e;
}

#resultMessage {
  margin-top: 16px;
  font-weight: bold;
}

/* ===== AfyaPlus Design Tokens ===== */
:root {
  --primary-900: #1C3A52;
  --primary-600: #2D6E7E;
  --success-600: #3F7D58;
  --warning-600: #B8862B;
  --critical-600: #B23A48;
  --info-600: #5B6EAE;
  --neutral-900: #20242B;
  --neutral-600: #5F6570;
  --neutral-300: #D8D9DC;
  --neutral-100: #F1F1EF;
  --surface-white: #FFFFFF;

  --font-sans: 'IBM Plex Sans', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --space-1: 4px; --space-2: 8px; --space-3: 12px;
  --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;

  --radius-sm: 4px;
  --radius-md: 8px;
}

body {
  font-family: var(--font-sans);
  color: var(--neutral-900);
  background-color: var(--neutral-100);
}

/* ===== Top Navigation ===== */
.mmc-nav {
  position: relative;
  display: flex;
  align-items: center;
  background-color: var(--primary-900);
  padding: var(--space-2) var(--space-5);
}
.mmc-nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding-right: 76px;
}
.mmc-nav-links a {
  color: var(--neutral-100);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}
.mmc-nav-links a:hover {
  background-color: rgba(255,255,255,0.08);
}
.mmc-nav-links a.active {
  background-color: var(--primary-600);
  color: var(--surface-white);
}
.mmc-nav-dropdown {
  position: relative;
}
.mmc-nav-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--neutral-100);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.mmc-nav-dropdown-btn:hover {
  background-color: rgba(255,255,255,0.08);
}
.mmc-nav-dropdown-btn.active {
  background-color: var(--primary-600);
  color: var(--surface-white);
}
.mmc-nav-caret {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.mmc-nav-dropdown.open .mmc-nav-caret {
  transform: rotate(180deg);
}
.mmc-nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background-color: var(--surface-white);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(20,25,30,.12);
  padding: var(--space-2);
  z-index: 50;
  flex-direction: column;
}
.mmc-nav-dropdown.open .mmc-nav-dropdown-menu {
  display: flex;
}
.mmc-nav-dropdown-menu a {
  color: var(--neutral-900);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.mmc-nav-dropdown-menu a:hover {
  background-color: var(--neutral-100);
}
.mmc-nav-dropdown-menu a.active {
  background-color: var(--primary-600);
  color: var(--surface-white);
}
.mmc-nav-user {
  position: absolute;
  top: 0;
  right: var(--space-5);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background-color: var(--surface-white);
  border: 2px solid var(--critical-600);
  color: var(--neutral-700);
  font-size: 9px;
  box-sizing: border-box;
  overflow: hidden;
  text-align: center;
}
.mmc-role-label {
  font-size: 7px;
  color: var(--neutral-700);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46px;
}
.mmc-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: var(--success-600);
  color: var(--surface-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 600;
  flex-shrink: 0;
}
.mmc-nav-user button {
  background: none;
  border: none;
  color: var(--critical-600);
  margin: 0;
  padding: 0;
  cursor: pointer;
  font-size: 7px;
  line-height: 1;
  display: block;
}
.mmc-nav-user button:hover {
  text-decoration: underline;
}
.mmc-nav-user button:hover {
  background-color: var(--critical-600);
  border-color: var(--critical-600);
  color: var(--surface-white);
}

/* ===== Scope legacy narrow form layout to auth/form pages only ===== */
body.auth-page {
  font-family: Arial, sans-serif;
  position: fixed;
  inset: 0;
  margin: auto;
  width: 90vw;
  max-width: 480px;
  height: fit-content;
  min-height: 0;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--neutral-300);
  background: var(--surface-white);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(28, 58, 82, 0.2);
  padding: var(--space-5, 24px);
}

body.auth-page h1 {
  margin-top: 0;
  font-size: 1.4rem;
  line-height: 1.25;
  text-align: center;
}

body.auth-page form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3, 12px);
}

body.auth-page form[hidden] {
  display: none;
}

body.auth-page label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 4px);
  font-size: 0.9rem;
}

body.auth-page input {
  padding: var(--space-2, 8px);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  font-size: 1rem;
}

.password-field-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field-wrapper input {
  width: 100%;
  padding-right: 40px;
}

.password-toggle-btn {
  position: absolute;
  right: 6px;
  margin-top: 0;
  padding: 4px;
  background: transparent;
  color: var(--neutral-700);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.password-toggle-btn:hover {
  color: var(--neutral-900);
}

@media (max-width: 480px) {
  body.auth-page {
    width: 94vw;
    padding: var(--space-4, 16px);
  }
}

/* ===== Dashboard shell ===== */
body.dashboard-page {
  margin: 0;
  padding: 0;
}
.dashboard-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-5);
}
.dashboard-shell h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--primary-900);
  margin-bottom: var(--space-4);
}

/* ===== Subnav tabs ===== */
.dashboard-tabs {
  display: flex;
  gap: var(--space-2);
  border-bottom: 1px solid var(--neutral-300);
  margin-bottom: var(--space-5);
}
.tab-btn {
  background: none;
  border: none;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--neutral-600);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover {
  color: var(--primary-900);
}
.tab-btn.active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-600);
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* ===== Stat cards ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.card {
  background: var(--surface-white);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.card h3 {
  font-size: 12px;
  font-weight: 500;
  color: var(--neutral-600);
  margin: 0 0 var(--space-2) 0;
  text-transform: none;
}
.card-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--neutral-900);
  margin: 0;
}

/* ===== Lists / tables ===== */
.lists-container h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-900);
  margin: var(--space-5) 0 var(--space-3) 0;
}
.dashboard-list-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-white);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: 13px;
}
.dashboard-list-table th {
  text-align: left;
  background: var(--neutral-100);
  color: var(--neutral-600);
  font-weight: 500;
  font-size: 12px;
  padding: var(--space-3);
  border-bottom: 1px solid var(--neutral-300);
}
.dashboard-list-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--neutral-300);
  color: var(--neutral-900);
}
.dashboard-list-table tr:last-child td {
  border-bottom: none;
}
.dashboard-list-table tr:hover td {
  background: var(--neutral-100);
}

/* ===== Charts ===== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}
.chart-box {
  background: var(--surface-white);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Dashboard shell  full width ===== */
.dashboard-shell {
  max-width: 100%;
  margin: 0;
  padding: var(--space-5) var(--space-6);
  box-sizing: border-box;
}

/* ===== Sub-nav tabs  spread across page, wrap onto new rows if needed ===== */
.dashboard-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  border-bottom: 1px solid var(--neutral-300);
  margin-bottom: var(--space-5);
  width: 100%;
}
.tab-btn {
  flex: 1 1 180px;
  text-align: center;
  background: var(--surface-white);
  border: 1px solid var(--neutral-300);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--neutral-600);
  cursor: pointer;
  margin-bottom: -1px;
  transition: background-color .15s ease, color .15s ease;
}
.tab-btn:hover {
  background: var(--neutral-100);
  color: var(--primary-900);
}
.tab-btn.active {
  background: var(--primary-900);
  color: var(--surface-white);
  border-color: var(--primary-900);
}

/* ===== Cards  color-coded left accent + clickable state ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.card {
  position: relative;
  border-left: 4px solid var(--neutral-300);
}
.card.card-primary   { border-left-color: var(--primary-600); }
.card.card-info      { border-left-color: var(--info-600); }
.card.card-success   { border-left-color: var(--success-600); }
.card.card-warning   { border-left-color: var(--warning-600); }
.card.card-critical  { border-left-color: var(--critical-600); }
.card.card-neutral   { border-left-color: var(--neutral-300); }

.card.card-clickable {
  cursor: pointer;
  transition: box-shadow .15s ease, transform .1s ease;
}
.card.card-clickable:hover {
  box-shadow: 0 4px 12px rgba(20,25,30,.12);
  transform: translateY(-1px);
}

/* ===== Charts  fit the viewport instead of stacking indefinitely ===== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, minmax(320px, 1fr));
  gap: var(--space-4);
  height: calc(100vh - 280px);
  min-height: 560px;
}
.chart-box {
  background: var(--surface-white);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  position: relative;
  min-height: 0;
  min-width: 0;
}
@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 320px);
    height: auto;
  }
}

/* ===== Full-viewport safeguard ===== */
html, body {
  width: 100%;
  min-height: 100%;
}
body.dashboard-page {
  width: 100%;
}
.dashboard-shell {
  width: 100%;
}


/* ===== App pages  same full-width shell as dashboard ===== */
body.app-page {
  margin: 0;
  padding: var(--space-5) var(--space-6);
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-sans);
  color: var(--neutral-900);
  background-color: var(--neutral-100);
}
body.app-page h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--primary-900);
  margin-bottom: var(--space-4);
}

/* ===== Form card  constrained, styled container for form pages ===== */
h1 + .form-card {
  margin-top: 4px;
}

h1:has(+ .form-card) {
  margin-bottom: 0 !important;
}

.form-card {
  max-width: 640px;
  margin: var(--space-2) auto var(--space-6);
  background-color: var(--surface-white);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  padding: 0;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.form-card form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.form-card-body {
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-6) var(--space-6) 0 var(--space-6);
  flex: 1 1 auto;
  min-height: 0;
}
.form-card-footer {
  flex: 0 0 auto;
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--neutral-300);
  background-color: var(--surface-white);
}
.form-card::-webkit-scrollbar {
  width: 8px;
}
.form-card::-webkit-scrollbar-thumb {
  background-color: var(--neutral-300);
  border-radius: var(--radius-sm);
}
.form-card label {
  display: block;
  margin-bottom: var(--space-4);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--neutral-600);
}
.form-card input,
.form-card select,
.form-card textarea {
  display: block;
  width: 100%;
  margin-top: var(--space-2);
  padding: var(--space-3);
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--neutral-900);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}
.form-card textarea {
  min-height: 70px;
  resize: vertical;
}
.form-card button[type="submit"] {
  background-color: var(--primary-900);
  color: var(--surface-white);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-5);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: var(--space-2);
}
.form-card button[type="submit"]:hover {
  background-color: var(--primary-600);
}









/* ===== Compact data table component (Phase 12) ===== */
.table-card {
  max-width: 900px;
  margin: var(--space-4) auto;
  background: var(--surface-white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(28, 58, 82, 0.08);
}

.table-card.table-card-wide {
  max-width: 1200px;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead th {
  background: var(--primary-600);
  color: #ffffff;
  font-weight: 600;
  text-align: left;
  height: 40px;
  padding: 0 var(--space-3);
}

.data-table tbody td {
  height: 44px;
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--neutral-300);
  color: var(--neutral-900);
  background: var(--surface-white);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: var(--neutral-100);
}

.data-table tbody tr.row-selected td {
  background: rgba(28, 58, 82, 0.08);
  border-left: 3px solid var(--primary-600);
}

.data-table tbody tr.row-flagged td:first-child {
  border-left: 3px solid var(--critical-600);
}

/* Column alignment helpers */
.data-table .col-text { text-align: left; }
.data-table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .col-status { text-align: center; }
.data-table .col-actions { text-align: right; width: 1%; white-space: nowrap; }

.data-table input,
.data-table select {
  width: 100%;
  box-sizing: border-box;
  padding: 4px 6px;
  font-size: 14px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-sm, 4px);
}


/* ===== Badge component (Phase 3, confirmed spec) ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.badge-neutral  { background: #EAEAE7; color: #5F6570; border-color: #D8D9DC; }
.badge-info     { background: #EEF0F8; color: #46568A; border-color: #C9CFE8; }
.badge-primary  { background: #EAF2F3; color: #1F4E59; border-color: #BEDBDF; }
.badge-warning  { background: #FBF1E0; color: #8C6620; border-color: #EBD4A2; }
.badge-success  { background: #EAF3EC; color: #2E5C41; border-color: #BFDCC9; }
.badge-critical { background: #FBEAEC; color: #8A2C37; border-color: #EDBEC3; }


/* ===== Center headings that sit directly above a form-card or table-card ===== */
h1:has(+ .form-card),
h2:has(+ .form-card),
h3:has(+ .form-card),
h1:has(+ .table-card),
h2:has(+ .table-card),
h3:has(+ .table-card) {
  text-align: center;
}

/* ===== Modal / Dialog component (Phase 2.7) ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 25, 30, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: modal-backdrop-in 150ms ease-out forwards;
}

.modal-backdrop.modal-closing {
  animation: modal-backdrop-out 150ms ease-out forwards;
}

@keyframes modal-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-backdrop-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.modal-panel {
  background: var(--surface-white);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(28, 58, 82, 0.2);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  width: 90vw;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  animation: modal-panel-in 200ms ease-out forwards;
}

.modal-panel.modal-closing {
  animation: modal-panel-out 150ms ease-out forwards;
}

@keyframes modal-panel-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modal-panel-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(8px) scale(0.96); }
}

@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal-panel {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

.modal-sm { max-width: 400px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 720px; }

/* Half-page side panel — used for the peep/manage view so the admin's
   own page stays visible behind it, rather than a centered dialog. */
.modal-backdrop-half {
  justify-content: flex-end;
  align-items: stretch;
  background: rgba(20, 25, 30, 0.35);
}

.modal-half {
  width: 50vw;
  max-width: 720px;
  min-width: 420px;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  transform: translateX(24px) scale(1);
  box-shadow: -8px 0 24px rgba(28, 58, 82, 0.2);
}

@keyframes modal-panel-in-half {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes modal-panel-out-half {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(24px); }
}

.modal-half.modal-panel-in-half { animation: modal-panel-in-half 200ms ease-out forwards; }
.modal-half.modal-closing { animation: modal-panel-out-half 150ms ease-out forwards; }

@media (max-width: 767px) {
  .modal-panel {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--neutral-300);
  flex: 0 0 auto;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--neutral-900);
}

.modal-title-icon-critical {
  color: var(--critical-600);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--neutral-600);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  background: var(--neutral-100);
  color: var(--neutral-900);
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--neutral-300);
  flex: 0 0 auto;
}

.modal-btn-cancel {
  background: var(--surface-white);
  color: var(--neutral-600);
  border: 1px solid var(--neutral-300);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
}

.modal-btn-cancel:hover {
  background: var(--neutral-100);
}

.modal-btn-primary {
  background: var(--primary-600);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
}

.modal-btn-primary:hover {
  opacity: 0.9;
}

.modal-btn-primary:disabled {
  background: var(--neutral-300);
  cursor: not-allowed;
  opacity: 1;
}

.modal-btn-destructive {
  background: var(--critical-600);
}

.modal-btn-destructive:hover {
  opacity: 0.9;
}

/* ===== Permissions matrix ===== */
.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
  margin: var(--space-4) auto;
  max-width: 1300px;
}

.perm-category-card {
  background: var(--surface-white);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px rgba(28, 58, 82, 0.08);
  overflow: hidden;
  border: 1px solid var(--neutral-300);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.perm-category-card h3 {
  margin: 0;
  background: var(--primary-600);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.perm-category-body {
  padding: var(--space-1) 0;
  flex: 1;
}

.perm-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--neutral-100);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 0.12s ease;
  min-width: 0;
}

.perm-row:nth-child(even) {
  background: rgba(241, 241, 239, 0.4);
}

.perm-row:last-child {
  border-bottom: none;
}

.perm-row:hover {
  background: var(--neutral-100);
}

.perm-row input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--primary-600);
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.perm-row label,
.perm-row > span {
  min-width: 0;
}

.perm-key {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--primary-900);
  font-weight: 600;
  background: var(--neutral-100);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  flex-shrink: 1;
}

.perm-desc {
  color: var(--neutral-600);
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}

.perm-sep {
  display: none;
}


/* ===== Scrollable table variant (Patient List, ~5 rows visible) ===== */
.table-card-scroll {
  max-height: 282px;
  overflow-y: auto;
}

.table-card-scroll .data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}


@media print {
  body > *:not(.modal-backdrop) {
    display: none !important;
  }
  .modal-backdrop {
    position: static !important;
    background: none !important;
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
  }
  .modal-panel {
    box-shadow: none !important;
    max-height: none !important;
    overflow: visible !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    display: block !important;
  }
  .modal-body {
    overflow: visible !important;
    flex: none !important;
    min-height: 0 !important;
  }
  @page {
    margin: 0.8cm;
  }
  .modal-header {
    padding: 0.3cm 0.5cm !important;
  }
  .modal-body {
    padding: 0.3cm 0.5cm !important;
  }
  .modal-header .modal-close-btn,
  .modal-footer {
    display: none !important;
  }
}


/* ===== SMS Management page: thin filter bar + enlarged log table ===== */
.sms-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4);
  width: 100%;
  max-width: 100%;
  margin: 0 0 var(--space-4) 0;
  background: var(--surface-white);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-sizing: border-box;
}
.sms-filter-bar > label {
  margin-bottom: 0;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--neutral-600);
  flex: 1 1 160px;
  min-width: 140px;
}
.sms-filter-bar > label input {
  margin-top: 4px;
  padding: var(--space-2);
  font-size: 13px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-sm);
  width: 100%;
  box-sizing: border-box;
}
.sms-filter-bar .sms-filter-actions {
  display: flex;
  gap: var(--space-2);
  flex: 0 0 auto;
}
.sms-filter-bar button {
  margin-top: 0;
  padding: var(--space-2) var(--space-4);
  font-size: 13px;
  background-color: var(--primary-900);
  color: var(--surface-white);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.sms-filter-bar button:hover {
  background-color: var(--primary-600);
}
.sms-filter-bar #clearFiltersBtn {
  background-color: var(--surface-white);
  color: var(--neutral-600);
  border: 1px solid var(--neutral-300);
}
.sms-filter-bar #clearFiltersBtn:hover {
  background-color: var(--neutral-100);
}

.sms-log-table {
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
  min-height: 75vh;
  display: flex;
  flex-direction: column;
}
.sms-log-table .data-table {
  font-size: 15px;
}
.sms-log-table .data-table thead th {
  height: 46px;
}
.sms-log-table .data-table tbody td {
  height: 52px;
}


/* ===== Follow-Up Dashboard: summary cards + toggle (Section 8) ===== */
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.summary-card {
  position: relative;
  background: var(--surface-white);
  border: 1px solid var(--neutral-300);
  border-left: 4px solid var(--primary-600);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  cursor: pointer;
  transition: box-shadow .15s ease, transform .1s ease;
}
.summary-card:hover {
  box-shadow: 0 4px 12px rgba(20,25,30,.12);
  transform: translateY(-1px);
}
.summary-card.active {
  border-left-color: var(--success-600);
  background: rgba(63, 125, 88, 0.06);
}
.summary-card h3 {
  margin: 0 0 var(--space-1) 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-900);
}
.summary-card .summary-role {
  margin: 0 0 var(--space-2) 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--neutral-600);
  text-transform: capitalize;
}
.summary-card .summary-total {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--neutral-900);
  margin: 0 0 var(--space-2) 0;
}
.summary-card .summary-breakdown {
  font-size: 12px;
  color: var(--neutral-600);
  margin: 0;
  line-height: 1.5;
}

#followUpFilterLabel {
  font-size: 13px;
  font-weight: 500;
  color: var(--primary-600);
  margin-left: var(--space-3);
}

#showTodayBtn,
#showAllBtn {
  margin-top: 0;
  padding: var(--space-2) var(--space-4);
  font-size: 13px;
  font-weight: 500;
  background-color: var(--surface-white);
  color: var(--neutral-600);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
#showTodayBtn:hover,
#showAllBtn:hover {
  background-color: var(--neutral-100);
}
#showTodayBtn.active-toggle,
#showAllBtn.active-toggle {
  background-color: var(--primary-900);
  color: var(--surface-white);
  border-color: var(--primary-900);
}

.inline-status-select {
  padding: 4px 6px;
  font-size: 13px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-sm);
  width: auto;
  min-width: 140px;
}


/* ===== Follow-Up Dashboard: summary card activity coloring (Section 8 v2) ===== */
.summary-card {
  user-select: none;
}
.summary-card::after {
  content: "Click to filter â†’";
  display: block;
  margin-top: var(--space-2);
  font-size: 11px;
  font-weight: 500;
  color: var(--neutral-600);
  opacity: 0;
  transition: opacity .15s ease;
}
.summary-card:hover::after {
  opacity: 1;
}
.summary-card.has-activity {
  border-left-color: var(--success-600);
}
.summary-card.has-activity .summary-total {
  color: var(--success-600);
}
.summary-card.no-activity {
  border-left-color: var(--neutral-300);
  opacity: 0.85;
}
.summary-card.no-activity .summary-total {
  color: var(--neutral-600);
}
.summary-card.active {
  border-left-color: var(--primary-600);
  border-left-width: 6px;
  background: rgba(45, 110, 126, 0.08);
  box-shadow: 0 4px 12px rgba(20,25,30,.12);
}
.summary-card.active::after {
  content: "âœ“ Filtering by this staff member";
  opacity: 1;
  color: var(--primary-600);
  font-weight: 600;
}


/* === MMC-RESPONSIVE-LAYER-V1 === */
/* Fluid device/browser compatibility layer â€” additive, does not override
   existing component rules, only adds small-screen and cross-browser behavior. */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--neutral-100);
}

body {
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Fluid type scale (min, preferred, max) so text scales smoothly instead of
   jumping at fixed breakpoints */
.dashboard-shell h1, body.app-page h1 {
  font-size: clamp(18px, 2.2vw + 12px, 22px);
}
.modal-title { font-size: clamp(16px, 2vw + 10px, 18px); }

/* Firefox scrollbar equivalent to the existing ::-webkit-scrollbar rule */
.form-card {
  scrollbar-width: thin;
  scrollbar-color: var(--neutral-300) transparent;
}

/* iOS safe-area support (notch/home-indicator) for full-screen mobile modal */
@media (max-width: 767px) {
  .modal-panel {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Touch target minimum on small screens (Section 8 accessibility rule) */
@media (max-width: 767px) {
  button, .tab-btn, .badge, a.mmc-nav-links, input, select {
    min-height: 44px;
  }
  .badge { min-height: 0; } /* badges stay pill-sized; only interactive controls need 44px */
}

/* ---- Responsive top navigation ---- */
.mmc-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--neutral-100);
  font-size: 22px;
  cursor: pointer;
  padding: var(--space-2);
  margin-left: auto;
}

@media (max-width: 900px) {
  .mmc-nav {
    flex-wrap: wrap;
  }
  .mmc-nav-toggle {
    display: block;
  }
  .mmc-nav-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    padding-right: 0;
    padding-top: var(--space-2);
  }
  .mmc-nav-links.nav-open {
    display: flex;
  }
  .mmc-nav-user {
    position: static;
    width: auto;
    height: auto;
    border-radius: var(--radius-md);
    flex-direction: row;
    gap: var(--space-2);
    padding: var(--space-2);
    margin-left: auto;
  }
}

/* ---- Responsive tables: horizontal scroll instead of overflow/breakage ---- */
@media (max-width: 900px) {
  .table-card, .table-card-wide, .sms-log-table {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table {
    font-size: 13px;
  }
  .data-table thead th, .data-table tbody td {
    padding: 0 var(--space-2);
    white-space: nowrap;
  }
}

/* ---- Responsive cards/grids tighten gutters on phones ---- */
@media (max-width: 480px) {
  .cards-grid, .cards-row, .permissions-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  body.app-page, .dashboard-shell {
    padding: var(--space-3) var(--space-4);
  }
  .form-card { margin-left: var(--space-3); margin-right: var(--space-3); }
}

/* ---- Landscape phones: prevent modal from exceeding viewport height ---- */
@media (max-height: 480px) and (orientation: landscape) {
  .modal-panel { max-height: 92vh; }
}


/* === MMC-DYNAMIC-ROW-V1 === */
.mmc-dynamic-row {
  border: 1px solid var(--neutral-300);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

/* ===== Messaging nav unread badge ===== */
.mmc-nav-badge {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 6px;
  border-radius: 999px;
  background: #C4404B;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  vertical-align: middle;
}
.mmc-nav-badge.visible {
  display: inline-flex;
}

/* ===== Split staff/patient login layout ===== */
body.auth-page--split {
  max-width: 640px;
}

.login-split {
  display: flex;
  align-items: stretch;
  gap: var(--space-4, 16px);
}

.login-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-3, 12px);
}

.login-column h2 {
  font-size: 1.05rem;
  text-align: center;
  margin: 0 0 var(--space-2, 8px);
}

.login-divider {
  width: 1px;
  background: var(--neutral-300);
  align-self: stretch;
}

/* ===== Split login panel — enhanced styling ===== */
body.auth-page--split {
  border: 2px solid var(--primary-900);
}

.login-divider {
  width: 3px;
  background: var(--neutral-600);
  border-radius: var(--radius-sm);
}

.login-column input {
  border: 1px solid var(--primary-600);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-column input:focus {
  outline: none;
  border-color: var(--primary-900);
  box-shadow: 0 0 0 3px rgba(28, 58, 82, 0.15);
}

.login-column button[type="submit"] {
  background: var(--primary-600);
  color: var(--surface-white);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-3, 12px);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.login-column button[type="submit"]:hover {
  background: var(--primary-900);
}

/* Patient button — distinct accent color */
#patientLoginForm button[type="submit"] {
  background: var(--info-600);
}

#patientLoginForm button[type="submit"]:hover {
  background: var(--primary-900);
}

.login-actions-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.login-actions-row button[type="submit"] {
  flex: 0 0 auto;
}
.link-button {
  background: none;
  border: none;
  color: #2563eb;
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  white-space: nowrap;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  width: 90%;
  max-width: 380px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}
.modal-step label {
  display: block;
  margin-bottom: 12px;
}
.modal-step input {
  width: 100%;
  box-sizing: border-box;
}

/* Force hidden to always win over modal display rules */
.modal-overlay[hidden],
.modal-step[hidden] {
  display: none !important;
}


/* ---- Page transition: smooth fade in/out to replace the hard browser flash on navigation ---- */
body.app-page,
body.dashboard-page {
  animation: mmc-page-fade-in 140ms ease-out;
}

@keyframes mmc-page-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}



/* === MMC-LOGIN-REDESIGN-V1 === */
body.auth-page.auth-page--split {
  position: static;
  inset: auto;
  margin: 0;
  width: 100%;
  max-width: none;
  height: auto;
  min-height: 100vh;
  max-height: none;
  overflow: visible;
  border: none;
  background: var(--neutral-100, #f2f4f5);
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
}

body.auth-page.auth-page--split h1 {
  color: var(--primary-900, #0a3d7a);
}

.login-hero {
  flex: 1 1 50%;
  min-width: 320px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #0a3d7a 0%, #12579e 55%, #1f6fc2 100%);
  color: #fff;
  padding: var(--space-6, 32px);
  display: flex;
  flex-direction: column;
  gap: var(--space-4, 16px);
}

.login-hero > * {
  position: relative;
  z-index: 2;
}

.login-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--space-3, 12px);
}

.login-hero-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
}

.login-hero-logo-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
}
.login-hero-logo-text span { color: #f2c94c; }

.login-hero-logo-sub {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  opacity: 0.85;
  margin-top: 2px;
}

.login-hero-tagline {
  font-style: italic;
  font-size: 0.85rem;
  text-align: right;
  opacity: 0.9;
  line-height: 1.3;
  color: #0a3d7a;
  position: relative;
  z-index: 3;
}

.login-hero-headline {
  font-size: clamp(1.4rem, 2vw + 1rem, 1.9rem);
  line-height: 1.25;
  margin: 0;
}
.login-hero-headline span { color: #f2c94c; }

.login-hero-copy {
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 420px;
  opacity: 0.92;
  margin: 0;
}

.login-hero-features {
  display: flex;
  gap: var(--space-4, 16px);
  flex-wrap: wrap;
}

.login-hero-feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1, 4px);
  font-size: 0.7rem;
  text-align: center;
  width: 84px;
  opacity: 0.95;
}

.login-hero-feature-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-hero-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(242,199,76,0.35));
  background-size: cover;
  background-position: center;
}

.login-hero-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(105deg, rgba(10,61,122,0.8) 0%, rgba(10,61,122,0.75) 42%, rgba(10,61,122,0.15) 68%, rgba(10,61,122,0.1) 100%),
    linear-gradient(180deg, rgba(10,61,122,0.3) 0%, rgba(10,61,122,0.05) 30%, rgba(10,61,122,0.55) 100%);
  z-index: 1;
}

.login-hero-swoosh {
  position: absolute;
  left: 0;
  width: 100%;
  z-index: 1;
  pointer-events: none;
}

.login-hero-topcurve {
  position: absolute;
  top: 0;
  right: 0;
  width: 160px;
  height: 45px;
  background: rgba(255,255,255,0.92);
  border-bottom-left-radius: 100% 35px;
  z-index: 1;
  pointer-events: none;
}

.login-footer-bar {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3, 12px);
  background: #0a3d7a;
  color: #fff;
  padding: var(--space-3, 12px) var(--space-6, 32px);
}

.login-footer-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  font-size: 0.95rem;
  font-weight: 700;
}

.login-footer-brand span { color: #f2c94c; }

.login-footer-tag {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  font-size: 0.85rem;
  opacity: 0.9;
}

.login-card-wrap {
  flex: 1 1 50%;
  min-width: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6, 32px);
  background-image: radial-gradient(circle, rgba(10,61,122,0.09) 2.5px, transparent 2.5px);
  background-size: 30px 30px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface-white, #fff);
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 12px 32px rgba(28, 58, 82, 0.16);
  padding: var(--space-5, 24px);
}

.login-toggle {
  display: flex;
  background: var(--neutral-100, #eef1f3);
  border-radius: var(--radius-md, 8px);
  padding: 4px;
  margin-bottom: var(--space-4, 16px);
  gap: 4px;
}

.login-toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm, 6px);
  background: transparent;
  color: var(--neutral-700, #556);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

.login-toggle-btn.active {
  background: var(--primary-900, #0a3d7a);
  color: #fff;
}

.login-panel label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--neutral-800, #333);
}

.input-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-wrapper .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: var(--neutral-500, #888);
  pointer-events: none;
}

body.auth-page .input-icon-wrapper input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--neutral-300, #ccc);
  border-radius: var(--radius-md, 8px);
  font-size: 0.95rem;
  box-sizing: border-box;
}

.input-icon-wrapper.password-field-wrapper input {
  padding-right: 40px;
}

.password-toggle-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--neutral-500, #888);
  display: flex;
  padding: 0;
}

.login-submit-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary-900, #0a3d7a);
  color: #fff;
  border: none;
  border-radius: var(--radius-md, 8px);
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s ease;
}
.login-submit-btn:hover { background: #0d4c96; }

.login-footer-links {
  text-align: center;
  margin-top: var(--space-1, 4px);
}

.login-footer-links .link-button {
  background: none;
  border: none;
  color: var(--primary-700, #1f6fc2);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.login-need-help {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
  margin: var(--space-4, 16px) 0 var(--space-2, 8px);
  color: var(--neutral-500, #999);
  font-size: 0.78rem;
}
.login-need-help::before, .login-need-help::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--neutral-300, #ddd);
}

.login-support-row {
  display: flex;
  justify-content: center;
}
.login-support-row a {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--primary-700, #1f6fc2);
  text-decoration: none;
}

#resultMessage {
  text-align: center;
  font-size: 0.85rem;
  min-height: 1.2em;
}

@media (max-width: 860px) {
  .login-hero { display: none; }
  .login-card-wrap { flex: 1 1 100%; padding: var(--space-4, 16px); }
}
