/* internal.css — Internal-only layout + auth UI */

.internal-shell {
  min-height: calc(100vh - 72px);
  min-height: calc(100dvh - 72px);
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: var(--space-6);
  padding-block: var(--space-6);
  align-items: start;
}

.internal-sidebar {
  background: var(--brand-royal-blue);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-left: 1px solid var(--brand-gold-a35);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
  position: sticky;
  top: calc(72px + var(--space-6));
  height: calc(100vh - 72px - (var(--space-6) * 2));
  height: calc(100dvh - 72px - (var(--space-6) * 2));
  overflow: auto;
  align-self: start;
}

.internal-overlay {
  display: none;
}

.internal-overlay[hidden] {
  display: none !important;
}

.internal-sidebar h2 {
  font-size: var(--h3);
  margin-bottom: var(--space-3);
  color: var(--brand-dorado-light);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.internal-nav {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.internal-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  box-shadow: inset 3px 0 0 transparent;
  font-weight: 800;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

@supports (-webkit-background-clip: text) or (background-clip: text) {
  .internal-nav a:not(.is-active):not([aria-current="page"]) {
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.74));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
}

.internal-nav a:focus-visible {
  outline-color: var(--brand-gold);
}

.internal-nav a.is-active,
.internal-nav a[aria-current="page"] {
  color: var(--brand-gold);
  background: rgba(198, 167, 86, 0.22);
  border-color: rgba(228, 201, 120, 0.55);
  box-shadow: inset 3px 0 0 var(--brand-gold);
  font-weight: 900;
}

.internal-nav a:hover {
  color: var(--brand-gold);
  background: rgba(198, 167, 86, 0.16);
  border-color: rgba(228, 201, 120, 0.40);
  box-shadow: inset 3px 0 0 var(--brand-gold);
}

.internal-main {
  min-width: 0;
}

.is-internal .card {
  border-color: rgba(15, 42, 74, 0.10);
  box-shadow: 0 12px 28px rgba(15, 42, 74, 0.10);
  background: linear-gradient(180deg, #ffffff, #f7f6f3);
}

.is-internal .kpi {
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.is-internal .kpi:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(15, 42, 74, 0.12);
  border-color: rgba(198, 167, 86, 0.22);
}

.kpi {
  display: grid;
  gap: 8px;
  align-content: start;
}

.kpi-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  font-weight: 900;
}

.kpi-value {
  font-size: clamp(26px, 1.2vw + 18px, 38px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 900;
  color: var(--brand-gold);
}

.kpi-note {
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.35;
  max-width: 52ch;
}

.kpi-status {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--color-heading);
}

.kpi-reading {
  margin-top: 6px;
  font-size: 13px;
  color: var(--color-muted);
  max-width: 64ch;
}

.kpi-trend {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--color-muted);
  border: 1px dashed var(--color-border);
  border-radius: 999px;
  padding: 6px 10px;
  width: fit-content;
}

.kpi-trend-success {
  border-color: var(--brand-emerald-a35);
  color: var(--brand-emerald);
  background: var(--brand-emerald-a12);
}

.kpi-wide {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-4);
  align-items: center;
}

.kpi-wide .kpi-trend {
  justify-self: end;
}

.integrity-table-wrap {
  overflow: auto;
}

.integrity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.integrity-table th,
.integrity-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(15, 42, 74, 0.10);
  vertical-align: top;
}

.integrity-table thead th {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  font-weight: 900;
  color: var(--color-heading);
  z-index: 1;
}

/* Shared modern internal tables (scroll card + zebra + gridlines) */
.tbg-table-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: baseline;
  padding: 2px 2px 10px;
}

.tbg-table-wrap {
  max-height: 560px;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid rgba(15, 42, 74, 0.18);
  background: #ffffff;
}

.tbg-table {
  min-width: 960px;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
}

.tbg-table thead th {
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid rgba(15, 42, 74, 0.20);
}

.tbg-table th,
.tbg-table td {
  border-right: 1px solid rgba(15, 42, 74, 0.18);
  background-clip: padding-box;
}

.tbg-table th:last-child,
.tbg-table td:last-child {
  border-right: none;
}

.tbg-table tbody td {
  border-bottom: 1px solid rgba(15, 42, 74, 0.14);
}

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

.tbg-table tbody tr:nth-child(odd) td {
  background: #f3f8ff !important;
}

.tbg-table tbody tr:nth-child(even) td {
  background: #fff1d9 !important;
}

.tbg-table tr[data-row-href] {
  cursor: pointer;
}

.tbg-table tr[data-row-href]:hover td {
  background: #f2e5b4 !important;
}

.tbg-table tr[data-row-href]:focus-visible td {
  outline: 2px solid rgba(228, 201, 120, 0.90);
  outline-offset: -2px;
}

@media (max-width: 480px) {
  .tbg-table-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

.appt-table-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: baseline;
  padding: 2px 2px 10px;
}

.appt-table-wrap {
  max-height: 560px;
  overflow: auto;
  border-radius: var(--radius-md);
}

.appt-table {
  min-width: 920px;
}

.appt-table {
  border-collapse: separate;
  border-spacing: 0;
}

.appt-table th,
.appt-table td {
  border-right: 1px solid rgba(15, 42, 74, 0.08);
}

.appt-table th:last-child,
.appt-table td:last-child {
  border-right: none;
}

/* Zebra stripes: two alternating row colors */
.appt-table tbody tr:nth-child(odd) td {
  background: rgba(15, 42, 74, 0.02);
}

.appt-table tbody tr:nth-child(even) td {
  background: rgba(228, 201, 120, 0.04);
}

.integrity-table tr[data-row-href] {
  cursor: pointer;
}

.integrity-table tr[data-row-href]:hover td {
  background: rgba(228, 201, 120, 0.10);
}

.integrity-table tr[data-row-href]:focus-visible td {
  outline: 2px solid rgba(228, 201, 120, 0.75);
  outline-offset: -2px;
}

.integrity-msg {
  max-width: 64ch;
  color: rgba(26, 26, 26, 0.82);
  word-break: break-word;
}

.integrity-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.02em;
  border: 1px solid rgba(15, 42, 74, 0.14);
  background: rgba(15, 42, 74, 0.04);
}

.integrity-pill-success {
  border-color: var(--brand-emerald-a35);
  color: var(--brand-emerald);
  background: var(--brand-emerald-a12);
}

.integrity-pill-failed {
  border-color: rgba(210, 56, 56, 0.30);
  color: rgb(210, 56, 56);
  background: rgba(210, 56, 56, 0.08);
}

.integrity-pill-neutral {
  border-color: rgba(26, 26, 26, 0.18);
  color: rgba(26, 26, 26, 0.78);
  background: rgba(26, 26, 26, 0.05);
}

/* Modern System Integrity cards */
.integrity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-5);
}

.integrity-card {
  display: grid;
  gap: 12px;
}

.integrity-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-4);
  align-items: start;
}

.integrity-title {
  font-size: 15px;
  font-weight: 950;
  letter-spacing: -0.01em;
  color: var(--color-heading);
}

.integrity-sub {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.integrity-kv strong {
  font-weight: 900;
  color: var(--color-heading);
}

.integrity-dot {
  opacity: 0.5;
}

.integrity-status {
  justify-self: end;
}

.integrity-pill {
  gap: 8px;
}

.integrity-pill-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
  background: rgba(26, 26, 26, 0.35);
  box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.08);
}

.integrity-pill-success .integrity-pill-dot {
  background: var(--brand-emerald);
  box-shadow: 0 0 0 3px var(--brand-emerald-a12);
}

.integrity-pill-failed .integrity-pill-dot {
  background: rgb(210, 56, 56);
  box-shadow: 0 0 0 3px rgba(210, 56, 56, 0.10);
}

.integrity-pill-neutral .integrity-pill-dot {
  background: rgba(26, 26, 26, 0.45);
  box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.08);
}

.integrity-body {
  border-top: 1px dashed rgba(15, 42, 74, 0.14);
  padding-top: 10px;
}

.integrity-msg {
  color: rgba(26, 26, 26, 0.82);
  line-height: 1.45;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.integrity-msg-empty {
  opacity: 0.7;
}

.integrity-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

@media (max-width: 480px) {
  .integrity-top {
    grid-template-columns: 1fr;
  }
  .integrity-status {
    justify-self: start;
  }
  .integrity-actions {
    justify-content: stretch;
  }
  .integrity-actions .btn {
    width: 100%;
  }
}

/* Modern appointment list */
.appt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-5);
}

.appt-card {
  display: grid;
  gap: 12px;
}

.appt-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-4);
  align-items: start;
}

.appt-name {
  font-size: 15px;
  font-weight: 950;
  letter-spacing: -0.01em;
  color: var(--color-heading);
}

.appt-email {
  margin-top: 4px;
  word-break: break-word;
}

.appt-badges {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.appt-meta {
  border-top: 1px dashed rgba(15, 42, 74, 0.14);
  padding-top: 10px;
  display: grid;
  gap: 10px;
}

.appt-kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  align-items: baseline;
}

.appt-k {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  font-weight: 900;
}

.appt-v {
  color: rgba(26, 26, 26, 0.86);
  word-break: break-word;
}

.appt-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

@media (max-width: 480px) {
  .appt-top {
    grid-template-columns: 1fr;
  }
  .appt-badges {
    justify-content: flex-start;
  }
  .appt-kv {
    grid-template-columns: 1fr;
  }
  .appt-actions {
    justify-content: stretch;
  }
  .appt-actions .btn {
    width: 100%;
  }
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 var(--space-5);
  color: rgba(26, 26, 26, 0.72);
  font-size: 13px;
}

.breadcrumbs a {
  color: rgba(26, 26, 26, 0.72);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--color-heading);
  text-decoration: underline;
}

.crumb-current {
  color: var(--color-heading);
  font-weight: 900;
}

.banner-restricted {
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--brand-gold-subtle-a35);
  background: var(--brand-gold-subtle-a08);
  color: var(--color-text);
}

.auth-page {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
  padding-block: var(--space-8);
}

.auth-card {
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
}

.auth-card h1 {
  font-size: var(--h2);
  line-height: 1.2;
}

.auth-card p {
  margin-top: var(--space-2);
  color: var(--color-muted);
}

.auth-form {
  margin-top: var(--space-5);
}

.btn-block {
  width: 100%;
}

.formset-row {
  margin-top: var(--space-3);
}

@media (max-width: 1023px) {
  .internal-shell {
    grid-template-columns: 1fr;
  }

  .internal-sidebar {
    position: fixed;
    z-index: 60;
    top: 72px;
    bottom: 0;
    left: 0;
    width: min(86vw, 320px);
    max-height: none;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    transform: translateX(-110%);
    transition: transform 220ms ease;
  }

  .internal-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(15, 42, 74, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  body.internal-drawer-open {
    overflow: hidden;
  }

  body.internal-drawer-open .internal-sidebar {
    transform: translateX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .internal-sidebar {
    transition: none !important;
  }
}

