/* ============================================================
   TUNTAGRAM — Master Design System Stylesheet
   Thai Oral Healthcare Workflow Management
   ============================================================
   Glassmorphism + Soft-UI Aesthetic
   Font: Sarabun (Thai) + Inter (English/Numbers)
   8px base-unit spacing system
   ============================================================ */

/* ==========================================================
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   ========================================================== */

:root {
  /* ── Primary ── */
  /* Slate purple from the owner reference image. */
  --primary:                #6858ba;
  --primary-container:      #5849a3;
  --primary-hover:          #504395;
  --primary-fixed:          #e9e4ff;
  --primary-fixed-dim:      #c4b9ef;

  /* ── Secondary ── */
  --secondary:              #5f5a70;
  --secondary-container:    #e7e3f2;

  /* ── Tertiary ── */
  --tertiary:               #654a9a;
  --tertiary-container:     #8064b8;
  --tertiary-fixed:         #ebddff;
  --tertiary-fixed-dim:     #c4abea;

  /* ── Surfaces ── */
  --surface:                #f7f9fc;
  --surface-container-low:  #f2f4f7;
  --surface-container:      #eceef1;
  --on-surface:             #191c1e;
  --on-surface-variant:     #434655;

  /* ── Outline ── */
  --outline:                #737687;
  --outline-variant:        #c3c5d8;

  /* ── Error ── */
  --error:                  #ba1a1a;
  --error-container:        #ffdad6;

  /* ── Inverse ── */
  --inverse-surface:        #2d3133;
  --inverse-on-surface:     #eff1f4;

  /* ── Semantic ── */
  --success:                #16a34a;
  --success-bg:             #dcfce7;
  --warning:                #d97706;
  --warning-bg:             #fef3c7;
  --info:                   #0284c7;
  --info-bg:                #e0f2fe;

  /* ── Spacing (8px base unit) ── */
  --space-1:   4px;
  --space-2:   8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-7:  28px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* ── Border Radius ── */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* ── Shadows ── */
  --shadow-sm:   0  1px  3px rgba(0, 0, 0, .06),
                 0  1px  2px rgba(0, 0, 0, .04);
  --shadow-md:   0  4px  6px rgba(0, 0, 0, .06),
                 0  2px  4px rgba(0, 0, 0, .04);
  --shadow-lg:   0 10px 24px rgba(0, 0, 0, .08),
                 0  4px  8px rgba(0, 0, 0, .04);
  --shadow-glass: 0  8px 32px rgba(104, 88, 186, .10);

  /* ── Transitions ── */
  --transition-fast:   150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow:   350ms ease;

  /* ── Sidebar ── */
  --sidebar-width:      240px;
  --sidebar-width-icon:  64px;
}

/* Consistent keyboard focus and bypass navigation (WCAG 2.4.1, 2.4.7). */
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10050;
  transform: translateY(-180%);
  padding: 10px 16px;
  border-radius: 8px;
  background: #fff;
  color: #453784;
  box-shadow: 0 2px 8px rgb(0 0 0 / 20%);
  font-weight: 700;
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline: 3px solid #453784;
  outline-offset: 3px;
}

/*
 * This must override Tailwind's `outline-none` utility.  Without the
 * important declaration, the zero-specificity :where() selector can lose
 * the cascade even when it appears later in this file, leaving keyboard
 * focus invisible on controls that use the utility.
 */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid #453784 !important;
  outline-offset: 3px !important;
}

/* The navigation surface is purple.  Inactive links use a white focus ring;
 * active white links switch to the app's dark purple focus treatment. */
.sidebar-shell .sidebar-link:focus-visible {
  outline-color: #fff !important;
}

.sidebar-shell .sidebar-link.active:focus-visible {
  outline-color: #453784 !important;
}


/* ==========================================================
   2. CSS RESET & BASE STYLES
   ========================================================== */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Sarabun', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--on-surface);
  background-color: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

img, svg, video { display: block; max-width: 100%; }
a { text-decoration: none; color: inherit; }
button { font: inherit; cursor: pointer; border: none; background: none; }
ul, ol { list-style: none; }
input, select, textarea { font: inherit; }
table { border-collapse: collapse; border-spacing: 0; }

/* ── Custom Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--outline-variant);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--outline); }

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--outline-variant) transparent;
}


/* ==========================================================
   3. TYPOGRAPHY CLASSES
   ========================================================== */

.text-display-lg {
  font-size: 40px;
  line-height: 48px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.text-headline-lg {
  font-size: 28px;
  line-height: 36px;
  font-weight: 600;
}

.text-headline-md {
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
}

.text-body-lg {
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
}

.text-body-md {
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
}

.text-label-md {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
}

.text-label-sm {
  font-size: 11px;
  line-height: 14px;
  font-weight: 500;
}


/* ==========================================================
   4. LAYOUT UTILITIES
   ========================================================== */

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.content-area {
  padding: var(--space-6);
  flex: 1;
}

/* The unauthenticated unit selector is a full-width, centered entry surface. */
.public-access-shell {
  width: 100%;
  min-height: calc(100vh - 2rem);
}

.public-access-shell > main {
  margin-inline: auto;
}

/* ── Responsive Grid ── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
}

/* ── Flex Helpers ── */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.flex-col {
  display: flex;
  flex-direction: column;
}

/* Narrow viewports must let action controls wrap instead of clipping them. */
.responsive-action-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
  max-width: 100%;
}

/* Documents uses a fixed category rail on desktop and a single readable flow on mobile. */
.documents-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  min-width: 0;
}

.documents-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-width: 0;
}

.documents-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-width: 0;
}

.documents-page-header > div {
  min-width: 0;
}

.documents-search {
  width: 280px;
  flex: 0 1 280px;
  min-width: 0;
  background: #fff;
  margin: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.documents-layout .empty-state__title,
.documents-layout .empty-state__desc {
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* Detail headers and action clusters must remain shrinkable when text is
 * enlarged.  The utility classes used by the templates otherwise leave a
 * flex item with an automatic minimum width, which clips long Thai labels. */
.detail-page-header,
.detail-page-identity,
.detail-page-heading,
.detail-page-meta,
.detail-page-year,
.detail-visit-panel,
.detail-visit-date,
.detail-action-group,
.school-card {
  min-width: 0;
}

.detail-page-identity {
  flex: 1 1 420px;
}

.detail-page-heading {
  flex: 1 1 auto;
}

.detail-page-heading h2,
.detail-page-meta,
.school-card-copy h4,
.school-card-copy p {
  overflow-wrap: anywhere;
}

.detail-page-meta {
  flex-wrap: wrap;
  row-gap: var(--space-1);
}

.detail-page-year,
.detail-visit-panel,
.detail-action-group {
  max-width: 100%;
}

.detail-visit-date {
  max-width: 100%;
}

.detail-visit-date input,
.detail-page-year select {
  max-width: 100%;
}

.detail-action-group {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.detail-action-group > button,
.detail-action-group > a {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.detail-tabs > button {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.school-card-header,
.school-card-identity,
.school-card-copy {
  min-width: 0;
}

.school-card-header {
  gap: var(--space-3);
  flex-wrap: wrap;
}

.school-card-identity {
  flex: 1 1 220px;
}

.school-card-copy {
  flex: 1 1 0%;
}

.setup-nav-buttons {
  min-width: 0;
  gap: var(--space-3);
}

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }


/* ==========================================================
   5. SIDEBAR COMPONENT
   ========================================================== */

/* The live shell separates the white product panel from the purple role,
 * unit identity and navigation surface. Keep this scoped to the injected
 * sidebar so legacy component examples retain their existing styles. */
.sidebar-shell {
  background: var(--primary);
  color: #fff;
  overflow: hidden;
}

.sidebar-logo-panel {
  flex: 0 0 auto;
  background: #fff;
}

.sidebar-role-panel {
  flex: 0 0 auto;
  background: var(--primary);
  color: #fff;
}

.sidebar-identity-card {
  background: rgb(255 255 255 / 10%);
  border-color: rgb(255 255 255 / 15%);
}

.sidebar-shell .sidebar-link {
  color: rgb(255 255 255 / 80%);
}

.sidebar-shell .sidebar-link:hover {
  background: rgb(255 255 255 / 10%);
  color: #fff;
}

.sidebar-shell .sidebar-link.active,
.sidebar-shell .sidebar-link.sidebar-link-active {
  background: #fff;
  color: var(--primary);
}

.sidebar-shell .sidebar-link.sidebar-link-disabled,
.sidebar-shell .sidebar-link[disabled] {
  color: rgb(255 255 255 / 40%);
  background: transparent;
}

.sidebar-shell .sidebar-footer-panel {
  border-top: 1px solid rgb(255 255 255 / 15%);
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--primary);
  border-radius: 0 var(--radius-2xl) var(--radius-2xl) 0;
  display: flex;
  flex-direction: column;
  padding: var(--space-6) 0;
  z-index: 100;
  overflow: hidden;
  transition: width var(--transition-normal);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-6);
  margin-bottom: var(--space-8);
  color: #fff;
  white-space: nowrap;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, .45);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-4) var(--space-6) var(--space-2);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  margin-left: var(--space-3);
  border-radius: var(--radius-full) 0 0 var(--radius-full);
  color: rgba(255, 255, 255, .8);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.sidebar-link .material-symbols-outlined {
  font-size: 20px;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

.sidebar-link.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

.sidebar-footer {
  margin-top: auto;
  padding: var(--space-4) var(--space-6) 0;
  border-top: 1px solid rgba(255, 255, 255, .12);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  color: #fff;
  white-space: nowrap;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
}


/* ==========================================================
   6. TOP BAR COMPONENT
   ========================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  background: rgba(255, 255, 255, .80);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--outline-variant);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topbar-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--on-surface);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: #fff;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  min-width: 280px;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 74, 224, .12);
}

.search-bar input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font-size: 14px;
  color: var(--on-surface);
}

.search-bar input::placeholder {
  color: var(--outline);
}

.search-bar .material-symbols-outlined {
  font-size: 20px;
  color: var(--outline);
}

/* Shared page search fields remain comfortably tappable at the WCAG target size. */
.topbar__search-input {
  min-height: 36px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: #fff;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-surface-variant);
  transition: all var(--transition-fast);
  position: relative;
  border: none;
  cursor: pointer;
}

.icon-btn:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
  color: var(--primary);
}

.icon-btn .material-symbols-outlined { font-size: 20px; }

.icon-btn .badge-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--error);
  border-radius: var(--radius-full);
  border: 2px solid #fff;
}

/* Hamburger — hidden on desktop */
.hamburger-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
}


/* ==========================================================
   7. CARD COMPONENT
   ========================================================== */

.card {
  background: #fff;
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.card-title {
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  color: var(--on-surface);
}

.card-subtitle {
  font-size: 13px;
  color: var(--on-surface-variant);
  margin-top: 2px;
}

.card-glass {
  background: rgba(255, 255, 255, .90);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-glass);
  border: 1px solid rgba(255, 255, 255, .6);
}

.card-body { /* optional explicit body section */ }

.card-footer {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--outline-variant);
}


/* ==========================================================
   8. BUTTON COMPONENTS
   ========================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

/* ── Variants ── */
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--primary-fixed);
  color: var(--primary);
}
.btn-secondary:hover { background: var(--primary-fixed-dim); }

.btn-ghost {
  background: transparent;
  color: var(--on-surface-variant);
}
.btn-ghost:hover {
  background: var(--surface-container-low);
  border-color: var(--outline-variant);
}

.btn-error {
  background: var(--error);
  color: #fff;
}
.btn-error:hover { background: #a31616; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary);
  color: #fff;
}

/* ── Sizes ── */
.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
  border-radius: var(--radius-lg);
}

/* ── Shapes ── */
.btn-pill { border-radius: var(--radius-full); }

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
}
.btn-icon.btn-sm { width: 32px; height: 32px; }

/* ── Disabled ── */
.btn:disabled,
.btn.disabled {
  opacity: .45;
  pointer-events: none;
}


/* ==========================================================
   9. FORM COMPONENTS
   ========================================================== */

.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--on-surface-variant);
  margin-bottom: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  font-size: 14px;
  color: var(--on-surface);
  background: #fff;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 74, 224, .12);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--outline);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23737687'%3E%3Cpath d='M4.5 6l3.5 4 3.5-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-input-pill {
  border-radius: var(--radius-full);
}

.form-hint {
  font-size: 11px;
  color: var(--outline);
  margin-top: var(--space-1);
}

.form-error-text {
  font-size: 11px;
  color: var(--error);
  margin-top: var(--space-1);
}

.form-input.error,
.form-select.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(186, 26, 26, .10);
}


/* ==========================================================
   10. STATUS CHIPS / BADGES
   ========================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.chip-success {
  background: rgba(22, 163, 74, .10);
  color: var(--success);
}
.chip-warning {
  background: rgba(217, 119, 6, .10);
  color: var(--warning);
}
.chip-error {
  background: rgba(186, 26, 26, .10);
  color: var(--error);
}
.chip-info {
  background: rgba(2, 132, 199, .10);
  color: var(--info);
}
.chip-primary {
  background: var(--primary-fixed);
  color: var(--primary);
}
.chip-neutral {
  background: var(--surface-container);
  color: var(--on-surface-variant);
}

.chip .material-symbols-outlined {
  font-size: 14px;
}


/* ==========================================================
   11. DATA TABLE
   ========================================================== */

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

.data-table thead th {
  background: var(--surface-container-low);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--on-surface-variant);
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--outline-variant);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--on-surface);
  border-bottom: 1px solid #f0f0f5;
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--surface-container-low);
}

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

/* Sortable header */
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.data-table th.sortable:hover {
  color: var(--primary);
}


/* ==========================================================
   12. STAT CARD
   ========================================================== */

.stat-card {
  background: #fff;
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--primary-fixed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.stat-card-icon .material-symbols-outlined { font-size: 20px; }

.stat-card-value {
  font-size: 28px;
  line-height: 36px;
  font-weight: 600;
  color: var(--on-surface);
}

.stat-card-label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--on-surface-variant);
}

.stat-card-trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 600;
}

.stat-card-trend.up   { color: var(--success); }
.stat-card-trend.down { color: var(--error); }

.stat-card-trend .material-symbols-outlined { font-size: 16px; }


/* ==========================================================
   13. PROGRESS BAR
   ========================================================== */

.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--surface-container);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary), var(--primary-container));
  transition: width var(--transition-slow);
  min-width: 0;
}

.progress-fill.success { background: linear-gradient(90deg, var(--success), #22c55e); }
.progress-fill.warning { background: linear-gradient(90deg, var(--warning), #f59e0b); }
.progress-fill.error   { background: linear-gradient(90deg, var(--error), #ef4444); }


/* ==========================================================
   14. TIMELINE
   ========================================================== */

.timeline {
  display: flex;
  align-items: center;
  gap: 0;
  padding: var(--space-4) 0;
}

.timeline-step {
  display: flex;
  align-items: center;
  position: relative;
}

.timeline-node {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 2px solid var(--outline-variant);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--outline);
  flex-shrink: 0;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  z-index: 2;
}

.timeline-node.completed {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.timeline-node.active {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 74, 224, .15);
}

.timeline-node.upcoming {
  border-color: var(--outline-variant);
  color: var(--outline);
}

.timeline-line {
  width: 48px;
  height: 2px;
  background: var(--outline-variant);
  flex-shrink: 0;
}

.timeline-line.completed {
  background: var(--primary);
}

.timeline-label {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 500;
  color: var(--on-surface-variant);
  white-space: nowrap;
}

.timeline-popover {
  position: absolute;
  bottom: calc(100% + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--outline-variant);
  min-width: 180px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.timeline-popover::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(255, 255, 255, .95);
}

.timeline-step:hover .timeline-popover {
  opacity: 1;
  pointer-events: auto;
}


/* ==========================================================
   15. MODAL
   ========================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .50);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

/* Native hidden state must remove the modal from layout and keyboard access. */
.modal-overlay[hidden] {
  display: none !important;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: #fff;
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  max-width: 540px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .15);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-normal);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-surface-variant);
  transition: background var(--transition-fast);
}
.modal-close:hover { background: var(--surface-container); }

.modal-body {
  margin-bottom: var(--space-6);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ── Large modal variant ── */
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }


/* ==========================================================
   16. EMPTY STATE
   ========================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-6);
}

.empty-state-icon {
  font-size: 64px;
  color: var(--outline-variant);
  margin-bottom: var(--space-6);
}

.empty-state-heading {
  font-size: 20px;
  font-weight: 600;
  color: var(--on-surface);
  margin-bottom: var(--space-2);
}

.empty-state-desc {
  font-size: 14px;
  color: var(--on-surface-variant);
  max-width: 360px;
  margin-bottom: var(--space-6);
}


/* ==========================================================
   17. WIZARD / STEPPER
   ========================================================== */

.wizard {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.wizard-step-item {
  display: flex;
  align-items: center;
}

.wizard-step-circle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.wizard-step-circle.completed {
  background: var(--primary);
  color: #fff;
}

.wizard-step-circle.active {
  background: #fff;
  color: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 74, 224, .12);
}

.wizard-step-circle.upcoming {
  background: var(--surface-container);
  color: var(--outline);
  border: 2px solid var(--outline-variant);
}

.wizard-connector {
  width: 48px;
  height: 2px;
  background: var(--outline-variant);
}
.wizard-connector.completed {
  background: var(--primary);
}

.wizard-step-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--on-surface-variant);
  margin-top: var(--space-2);
  text-align: center;
}

.wizard-content {
  animation: fadeIn var(--transition-normal) ease;
}


/* ==========================================================
   18. KPI GAUGE
   ========================================================== */

.kpi-gauge {
  position: relative;
  width: 140px;
  height: 70px;
  overflow: hidden;
}

.kpi-gauge-ring {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-full);
  background: conic-gradient(
    var(--primary) 0deg,
    var(--primary) calc(var(--gauge-value, 0) * 1.8deg),
    var(--surface-container) calc(var(--gauge-value, 0) * 1.8deg),
    var(--surface-container) 180deg,
    transparent 180deg
  );
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 48px, black 49px);
  mask: radial-gradient(circle at 50% 50%, transparent 48px, black 49px);
}

.kpi-gauge-ring.green  { --gauge-color: var(--success); }
.kpi-gauge-ring.amber  { --gauge-color: var(--warning); }
.kpi-gauge-ring.red    { --gauge-color: var(--error); }

.kpi-gauge-ring.green { background: conic-gradient(var(--success) 0deg, var(--success) calc(var(--gauge-value,0)*1.8deg), var(--surface-container) calc(var(--gauge-value,0)*1.8deg), var(--surface-container) 180deg, transparent 180deg); }
.kpi-gauge-ring.amber { background: conic-gradient(var(--warning) 0deg, var(--warning) calc(var(--gauge-value,0)*1.8deg), var(--surface-container) calc(var(--gauge-value,0)*1.8deg), var(--surface-container) 180deg, transparent 180deg); }
.kpi-gauge-ring.red   { background: conic-gradient(var(--error) 0deg, var(--error) calc(var(--gauge-value,0)*1.8deg), var(--surface-container) calc(var(--gauge-value,0)*1.8deg), var(--surface-container) 180deg, transparent 180deg); }

.kpi-gauge-value {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  font-weight: 700;
  color: var(--on-surface);
}

.kpi-gauge-label {
  text-align: center;
  font-size: 11px;
  color: var(--on-surface-variant);
  margin-top: var(--space-2);
}


/* ==========================================================
   19. CALENDAR
   ========================================================== */

.calendar {
  width: 100%;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--outline-variant);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.calendar-day-label {
  background: var(--surface-container-low);
  padding: var(--space-2);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--on-surface-variant);
  text-transform: uppercase;
}

.calendar-cell {
  background: #fff;
  padding: var(--space-2);
  min-height: 80px;
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
}

.calendar-cell:hover {
  background: var(--surface-container-low);
}

.calendar-cell.today {
  border: 2px solid var(--primary);
}

.calendar-cell.selected {
  background: var(--primary);
  color: #fff;
}

.calendar-cell.other-month {
  opacity: .35;
}

.calendar-date {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.calendar-event-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--primary);
  display: inline-block;
  margin-right: 2px;
}

.calendar-event-dot.success { background: var(--success); }
.calendar-event-dot.warning { background: var(--warning); }
.calendar-event-dot.error   { background: var(--error); }


/* ==========================================================
   20. ANIMATIONS & KEYFRAMES
   ========================================================== */

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .5; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-slide-up  { animation: slideUp var(--transition-normal) ease forwards; }
.animate-scale-in  { animation: scaleIn var(--transition-normal) ease forwards; }
.animate-fade-in   { animation: fadeIn var(--transition-normal) ease forwards; }
.animate-pulse     { animation: pulse 2s ease-in-out infinite; }
.animate-spin      { animation: spin 1s linear infinite; }

/* Skeleton loading placeholder */
.skeleton {
  background: linear-gradient(90deg, var(--surface-container) 25%, var(--surface-container-low) 50%, var(--surface-container) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}


/* ==========================================================
   21. UTILITY CLASSES
   ========================================================== */

.text-primary   { color: var(--primary); }
.text-success   { color: var(--success); }
.text-warning   { color: var(--warning); }
.text-error     { color: var(--error); }
.text-info      { color: var(--info); }
.text-muted     { color: var(--on-surface-variant); }
.text-center     { text-align: center; }
.text-right      { text-align: right; }
.font-semibold   { font-weight: 600; }
.font-bold       { font-weight: 700; }

.bg-surface       { background: var(--surface); }
.bg-surface-low   { background: var(--surface-container-low); }
.bg-surface-cont  { background: var(--surface-container); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.ml-auto { margin-left: auto; }

.p-4  { padding: var(--space-4); }
.p-6  { padding: var(--space-6); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-2 { padding-top: var(--space-2);  padding-bottom: var(--space-2); }

.w-full   { width: 100%; }
.h-full   { height: 100%; }
.rounded  { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-2xl { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: var(--radius-full); }

.overflow-hidden { overflow: hidden; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.divider {
  height: 1px;
  background: var(--outline-variant);
  margin: var(--space-4) 0;
}


/* ==========================================================
   22. RESPONSIVE — TABLET (≤1024px)
   ========================================================== */

@media (max-width: 1024px) {
  :root {
    /* The live app keeps a 240px drawer at narrow widths so labels remain
       readable.  The previous 64px rule hid every non-icon span and only
       restored labels for the unused `.sidebar.open` state. */
    --sidebar-width: 240px;
  }

  .sidebar {
    width: var(--sidebar-width);
    padding: var(--space-4) 0;
  }

  .sidebar-brand-name,
  .sidebar-section-label,
  .sidebar-link span:not(.material-symbols-outlined),
  .sidebar-user-info {
    display: unset;
  }

  .sidebar-brand {
    justify-content: center;
    padding: var(--space-2) 0;
    margin-bottom: var(--space-6);
  }

  .sidebar-link {
    justify-content: flex-start;
    padding: var(--space-3) var(--space-6);
    margin-left: var(--space-3);
    margin-right: 0;
    border-radius: var(--radius-full) 0 0 var(--radius-full);
  }

  .sidebar-footer {
    padding: var(--space-3) var(--space-2) 0;
  }

  .sidebar-user {
    justify-content: center;
  }

  .main-content {
    margin-left: var(--sidebar-width);
  }

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

  .search-bar { min-width: 200px; }
}


/* ==========================================================
   23. RESPONSIVE — MOBILE (≤600px)
   ========================================================== */

@media (max-width: 600px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    width: var(--sidebar-width);
    border-radius: 0;
  }

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

  /* Restore labels on mobile when sidebar is open */
  .sidebar.open .sidebar-brand-name,
  .sidebar.open .sidebar-section-label,
  .sidebar.open .sidebar-link span,
  .sidebar.open .sidebar-user-info,
  #sidebar.sidebar-open .sidebar-brand-name,
  #sidebar.sidebar-open .sidebar-section-label,
  #sidebar.sidebar-open .sidebar-link span,
  #sidebar.sidebar-open .sidebar-user-info {
    display: unset;
  }

  .sidebar.open .sidebar-link,
  #sidebar.sidebar-open .sidebar-link {
    justify-content: flex-start;
    padding: var(--space-3) var(--space-6);
    margin-left: var(--space-3);
    margin-right: 0;
    border-radius: var(--radius-full) 0 0 var(--radius-full);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 199;
  }

  .sidebar-backdrop.show {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .hamburger-btn {
    display: flex;
  }

  .content-area {
    padding: var(--space-4);
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: var(--space-3) var(--space-4);
  }

  /* The app-shell topbar is Tailwind-rendered, so constrain it explicitly here. */
  #topbar {
    flex-wrap: wrap;
    align-items: center;
    column-gap: var(--space-2);
    row-gap: var(--space-2);
  }

  #topbar > #hamburger-btn {
    margin-right: 0;
    flex: 0 0 auto;
  }

  #topbar > .flex-1 {
    min-width: 0;
    max-width: none;
    flex: 1 1 0%;
  }

  #topbar > .ml-auto {
    flex: 1 0 100%;
    justify-content: flex-end;
    margin-left: 0;
  }

  #topbar > .ml-auto > .flex {
    gap: var(--space-2);
  }

  .search-bar {
    min-width: 0;
    flex: 1;
  }

  .responsive-action-group {
    width: 100%;
    justify-content: flex-start;
  }

  .documents-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }

  .documents-layout > .card,
  .documents-layout > .flex-col {
    min-width: 0;
  }

  .documents-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .documents-page-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .documents-page-header > button {
    width: 100%;
    justify-content: center;
  }

  .documents-header > h3,
  .documents-header > .documents-search {
    max-width: 100%;
  }

  .documents-search {
    width: 100% !important;
    flex-basis: 100%;
  }

  .detail-page-header {
    width: 100%;
    align-items: stretch;
  }

  .detail-page-identity {
    width: 100%;
    flex-basis: 100%;
    align-items: flex-start;
  }

  .detail-page-heading h2 {
    line-height: 1.25;
  }

  .detail-page-year {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .detail-page-year .relative {
    flex: 1 1 160px;
    min-width: 0;
  }

  .detail-page-year select {
    width: 100%;
  }

  .detail-visit-panel {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .detail-visit-date {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .detail-visit-date input {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .detail-visit-panel > button {
    width: 100%;
    justify-content: center;
  }

  .detail-action-group {
    width: 100%;
    justify-content: flex-start;
  }

  .detail-action-group > button,
  .detail-action-group > a {
    flex: 1 1 auto;
  }

  .detail-tabs {
    flex-wrap: wrap;
    overflow: visible;
  }

  .detail-tabs > button {
    flex: 1 1 50%;
    max-width: 50%;
    min-height: 56px;
    padding-left: var(--space-2);
    padding-right: var(--space-2);
    line-height: 1.25;
  }

  .school-card-header {
    align-items: flex-start;
  }

  .school-card-identity {
    flex-basis: 100%;
  }

  .setup-nav-buttons {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .setup-nav-buttons > button {
    width: 100%;
    max-width: 100%;
    justify-content: center;
  }

  .sealant-audit-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: stretch;
  }

  .sealant-audit-meta > label,
  .sealant-audit-meta > span {
    width: 100%;
  }

  .sealant-audit-meta > label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: var(--space-2);
  }

  .sealant-audit-meta input,
  .sealant-audit-meta select {
    width: 100%;
    min-width: 0;
  }

  .dental-compare-toolbar {
    padding-left: 0;
    padding-right: 0;
  }

  .empty-state {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .empty-state__desc,
  .empty-state-desc {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .modal {
    width: 95%;
    max-height: 90vh;
    margin: var(--space-4);
  }

  .timeline {
    flex-direction: column;
    align-items: flex-start;
  }

  .timeline-line {
    width: 2px;
    height: 32px;
    margin-left: 15px;
  }
}


/* ==========================================================
   24. PRINT STYLES
   ========================================================== */

@media print {
  .sidebar,
  .topbar,
  .sidebar-backdrop,
  .hamburger-btn,
  .topbar-actions,
  .modal-overlay {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }

  .content-area {
    padding: 0;
  }

a { text-decoration: underline; }
  .btn { display: none; }
}

/* ==========================================================
   25. SCHOOL EXAM EDIT TABLE
   ========================================================== */

.student-exam-input {
  border-radius: 0 !important;
  min-width: 0;
}

.student-exam-display-text {
  display: flex;
  min-height: 42px;
  width: 100%;
  align-items: center;
  border: 1px solid #cbd5e1;
  background: #e2e8f0;
  padding: 4px 6px;
  color: #475569;
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: break-word;
}

.student-exam-number {
  appearance: textfield;
  -moz-appearance: textfield;
  font-variant-numeric: tabular-nums;
}

.student-exam-number::-webkit-outer-spin-button,
.student-exam-number::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.student-exam-select {
  appearance: none;
  height: 30px !important;
  min-height: 30px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  line-height: 28px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 3px center;
  background-repeat: no-repeat;
  background-size: 12px 12px;
}

.student-tooth-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}

.student-sealant-group {
  border-color: #bae6fd;
  background: #f0f9ff;
  color: #0369a1;
  font-weight: 700;
}

.student-sealant-all-grid {
  display: grid;
  grid-template-columns: 1.35fr repeat(4, 1fr);
  gap: 2px;
}

.student-sealant-all-grid .student-tooth-chip {
  font-size: 9px;
}

.student-tooth-chip-number {
  background: #fff;
}

.student-tooth-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.student-tooth-chip.is-selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.student-sealant-group.is-selected {
  border-color: #0284c7;
  background: #0ea5e9;
  color: #fff;
}

.student-treatment-plan-cell {
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.student-exam-row-even > td {
  background: #ffffff;
}

.student-exam-row-odd > td {
  background: #f8fafc;
}

.student-treatment-plan-cell.has-plan.is-waiting,
.student-treatment-status-summary.is-waiting {
  border-color: #fecaca;
  background: #fee2e2;
  color: #991b1b;
}

.student-treatment-plan-cell.has-plan.is-progress,
.student-treatment-status-summary.is-progress {
  border-color: #fde68a;
  background: #fef3c7;
  color: #92400e;
}

.student-treatment-plan-cell.has-plan.is-done,
.student-treatment-status-summary.is-done {
  border-color: #bbf7d0;
  background: #dcfce7;
  color: #166534;
}

.student-treatment-plan-static,
.student-treatment-plan-toggle,
.student-treatment-status-summary {
  width: 100%;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px 5px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
}

.student-treatment-plan-toggle {
  cursor: pointer;
  text-align: left;
}

.student-treatment-plan-toggle:hover,
.student-treatment-plan-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgb(25 118 210 / 0.14);
}

.student-treatment-plan-value {
  min-width: 0;
  flex: 1 1 auto;
  overflow: visible;
  text-overflow: clip;
  text-align: center;
  white-space: normal;
  word-break: break-word;
}

.student-treatment-plan-empty {
  color: #cbd5e1;
  font-weight: 700;
}

.student-treatment-status-summary {
  min-height: 30px;
  text-align: center;
}

.student-treatment-status-icon {
  flex: 0 0 auto;
  font-size: 16px;
  line-height: 1;
}

.sealant-audit-table {
  border-collapse: collapse;
  font-family: Sarabun, Inter, sans-serif;
}

.sealant-audit-head,
.sealant-audit-subhead,
.sealant-audit-cell {
  border: 1px solid #1f2937;
}

.sealant-audit-head {
  padding: 10px 8px;
  text-align: center;
  vertical-align: middle;
  font-size: 14px;
  font-weight: 800;
  color: #111827;
  line-height: 1.25;
}

.sealant-audit-subhead {
  padding: 8px 4px;
  text-align: center;
  vertical-align: middle;
  font-size: 13px;
  font-weight: 700;
  color: #111827;
}

.sealant-audit-cell {
  padding: 6px 6px;
  vertical-align: middle;
  color: #334155;
}

.sealant-audit-meta {
  min-width: 0;
  max-width: 100%;
}

.sealant-audit-meta > * {
  min-width: 0;
  max-width: 100%;
}

.sealant-audit-meta input,
.sealant-audit-meta select {
  max-width: 100%;
}

.sealant-audit-cell input:disabled,
.sealant-audit-cell select:disabled,
.sealant-audit-page textarea:disabled,
.sealant-audit-page input:disabled {
  cursor: default;
  opacity: 1;
}

.sealant-audit-done-checkbox:disabled {
  background-color: #f8fafc;
}

.sealant-audit-done-checkbox:disabled:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.sealant-audit-select {
  border-radius: 0 !important;
  appearance: auto;
}

.dental-chart-overlay {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(15 23 42 / 0.42);
}

.dental-chart-modal {
  width: min(1260px, 100%);
  max-height: min(860px, calc(100vh - 32px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgb(15 23 42 / 0.24);
}

.dental-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 2px solid #0f172a;
  background: #dff3f6;
}

.dental-chart-header h3 {
  margin: 0;
  color: #0f172a;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
}

.dental-chart-header p {
  margin: 2px 0 0;
  color: #475569;
  font-size: 12px;
}

.dental-chart-eyebrow {
  color: #0f172a !important;
  font-size: 13px !important;
  font-weight: 700;
}

.dental-chart-icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(15 23 42 / 0.12);
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
}

.dental-chart-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px;
}

.dental-chart-main {
  min-width: 0;
}

.dental-chart-main > .dental-chart-usage {
  margin-bottom: 12px;
}

.dental-chart-stage {
  --dental-chart-cell-size: 52px;
  --dental-chart-column-count: 14;
  min-width: calc((var(--dental-chart-cell-size) * 14) + (4px * 13));
  padding: 8px 4px 4px;
}

.dental-chart-stage.is-childcare-compact {
  --dental-chart-column-count: 12;
  min-width: calc((var(--dental-chart-cell-size) * 12) + (4px * 11));
}

.dental-chart-row {
  display: grid;
  grid-template-columns: repeat(var(--dental-chart-column-count), minmax(var(--dental-chart-cell-size), 1fr));
  gap: 4px;
  margin: 0 auto;
  width: 100%;
}

.dental-chart-row.primary-row {
  width: 100%;
}

.dental-chart-row.permanent-row {
  width: 100%;
}

.dental-chart-tooth-slot {
  min-width: 0;
  min-height: 66px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dental-chart-tooth-slot.is-spacer {
  visibility: hidden;
}

.dental-chart-tooth-slot.number-bottom {
  flex-direction: column-reverse;
}

.dental-chart-tooth-number {
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Keep the FDI label visually clear of the tooth-status box. The glyph
   * descenders can otherwise touch the box border in the PNG renderer even
   * though the flex gap is technically present. */
  transform: translateY(-3px);
  color: #0f172a;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.dental-chart-tooth {
  width: 100%;
  height: 42px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0f172a;
  border-radius: 0;
  background: #fff;
  color: #0f172a;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.dental-chart-tooth.is-primary {
  border-color: #64748b;
}

.dental-chart-tooth:hover,
.dental-chart-tooth:focus-visible {
  border-color: var(--primary);
  outline: none;
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgb(25 118 210 / 0.14);
}

.dental-chart-tooth.is-drag-resetting {
  border-color: #dc2626;
  background: #fee2e2;
  color: #991b1b;
  transform: scale(0.94);
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.18);
}

.dental-chart-tooth-trash {
  font-size: 20px;
  line-height: 1;
}

.dental-chart-tooth.is-paired-locked {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
}

.dental-chart-tooth.is-paired-locked:hover,
.dental-chart-tooth.is-paired-locked:focus-visible {
  border-color: #cbd5e1;
  transform: none;
  box-shadow: none;
}

.dental-chart-tooth.is-condition-blocked {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.65);
}

.dental-chart-tooth.is-condition-blocked:hover,
.dental-chart-tooth.is-condition-blocked:focus-visible {
  border-color: #cbd5e1;
  transform: none;
  box-shadow: none;
}

.dental-chart-tooth-lock {
  font-size: 18px;
  line-height: 1;
}

.dental-chart-tooth-status-stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.dental-chart-tooth-status-main,
.dental-chart-tooth-status-sub {
  display: block;
  text-align: center;
  line-height: 1;
}

.dental-chart-tooth-status-main {
  font-size: 11px;
  font-weight: 900;
}

.dental-chart-tooth-status-divider {
  display: block;
  height: 1px;
  margin: 2px 3px;
  background: currentColor;
  opacity: 0.58;
}

.dental-chart-tooth-status-sub {
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.dental-chart-divider {
  height: 4px;
  margin: 6px 0;
  border-radius: 2px;
  background: #0f172a;
}

.dental-chart-tooth.status-a,
.dental-chart-tooth.status-0 {
  border-color: #16a34a;
  background: #dcfce7;
  color: #166534;
}

.dental-chart-tooth.status-b-plus,
.dental-chart-tooth.status-b-plus-smart,
.dental-chart-tooth.status-b-plus-sdf,
.dental-chart-tooth.status-c,
.dental-chart-tooth.status-1-plus,
.dental-chart-tooth.status-1,
.dental-chart-tooth.status-2 {
  border-color: #f59e0b;
  background: #fef3c7;
  color: #92400e;
}

.dental-chart-tooth.status-b-minus,
.dental-chart-tooth.status-1-minus {
  border-color: #dc2626;
  background: #fee2e2;
  color: #991b1b;
}

.dental-chart-tooth.status-rr {
  border-color: #b91c1c;
  background: #fee2e2;
  color: #7f1d1d;
}

.dental-chart-tooth.status-d,
.dental-chart-tooth.status-3 {
  border-color: #2563eb;
  background: #dbeafe;
  color: #1e40af;
}

.dental-chart-tooth.status-e,
.dental-chart-tooth.status-4 {
  border-color: #64748b;
  background: #e2e8f0;
  color: #334155;
}

.dental-chart-tooth.status-f,
.dental-chart-tooth.status-5 {
  border-color: #0891b2;
  background: #cffafe;
  color: #155e75;
}

.dental-chart-tooth.status-g,
.dental-chart-tooth.status-6 {
  border-color: #7c3aed;
  background: #ede9fe;
  color: #5b21b6;
}

.dental-chart-tooth.status-8,
.dental-chart-tooth.status-9,
.dental-chart-tooth.status-pe {
  border-color: #94a3b8;
  background: #f1f5f9;
  color: #475569;
}

/* ANC: permanent-only 32-tooth chart, including third molars. */
.anc-dental-chart-stage {
  --dental-chart-column-count: 16;
  position: relative;
  min-width: calc((var(--dental-chart-cell-size) * 16) + (4px * 15));
}

.anc-staining-guidance-toast {
  position: absolute;
  top: 90%;
  left: 50%;
  z-index: 12;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  background: rgb(239 246 255 / 0.96);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgb(30 64 175 / 0.2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, calc(-50% + 8px)) scale(0.97);
}

.anc-staining-guidance-toast .material-symbols-outlined {
  font-size: 17px;
}

.anc-staining-guidance-toast.is-visible {
  visibility: visible;
  animation: anc-staining-guidance-fade 2.2s ease-out both;
}

@keyframes anc-staining-guidance-fade {
  0% {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 8px)) scale(0.97);
  }
  14%, 62% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, calc(-50% - 8px)) scale(0.98);
    visibility: hidden;
  }
}

.anc-dental-chart-row {
  grid-template-columns: repeat(16, minmax(0, 1fr));
}

.anc-dental-midline-start {
  position: relative;
}

.anc-dental-midline-start::before {
  content: '';
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: -3px;
  width: 0;
  border-left: 2px dashed #94a3b8;
  pointer-events: none;
}

.dental-chart-tooth.status-wisdom-absent,
.anc-legend-swatch.status-wisdom-absent {
  border-color: #94a3b8;
  background: #f8fafc;
  color: #64748b;
}

.dental-chart-tooth.status-wisdom-keep,
.anc-legend-swatch.status-wisdom-keep {
  border-color: #16a34a;
  background: #dcfce7;
  color: #166534;
}

.dental-chart-tooth.status-wisdom-fill,
.anc-legend-swatch.status-wisdom-fill {
  border-color: #d97706;
  background: #fef3c7;
  color: #92400e;
}

.dental-chart-tooth.status-wisdom-extract,
.anc-legend-swatch.status-wisdom-extract {
  border-color: #f59e0b;
  background: #fef3c7;
  color: #92400e;
}

.dental-chart-tooth.status-wisdom-surgery,
.anc-legend-swatch.status-wisdom-surgery {
  border-color: #dc2626;
  background: #fee2e2;
  color: #991b1b;
}

.anc-code-table {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.anc-code-table > div {
  display: grid;
  grid-template-columns: 42px 1fr;
  border-top: 1px solid #e2e8f0;
  font-size: 10px;
  line-height: 1.3;
}

.anc-code-table > div:first-child { border-top: 0; }
.anc-code-table strong,
.anc-code-table span { padding: 6px 7px; }
.anc-code-table strong {
  border-right: 1px solid #e2e8f0;
  color: var(--primary);
  text-align: center;
}

.anc-dental-guideline > [data-anc-status-guideline] {
  display: grid;
  gap: 10px;
}

.anc-dental-guideline > [data-anc-status-guideline][hidden] {
  display: none;
}

.anc-staining-guideline {
  display: grid;
  gap: 8px;
}

.anc-staining-guideline[hidden] {
  display: none;
}

.anc-staining-guideline-title {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-bottom: 7px;
  border-bottom: 1px solid #bfdbfe;
}

.anc-staining-guideline-title .material-symbols-outlined {
  width: 27px;
  height: 27px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 16px;
}

.anc-staining-guideline-title h4 {
  text-decoration: none;
}

.anc-staining-guideline section {
  padding: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.anc-staining-guideline h5,
.anc-staining-guideline p {
  margin: 0;
}

.anc-staining-guideline h5 {
  margin-bottom: 4px;
  color: #1e3a8a;
  font-size: 10px;
  font-weight: 900;
}

.anc-staining-guideline p {
  color: #334155;
  font-size: 9px;
  line-height: 1.45;
}

.anc-staining-score-guide {
  overflow: hidden;
  border: 1px solid #dbeafe;
  border-radius: 7px;
  background: #fff;
}

.anc-staining-score-guide > div {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  border-top: 1px solid #e2e8f0;
}

.anc-staining-score-guide > div:first-child {
  border-top: 0;
}

.anc-staining-score-guide strong {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 3px;
  border-right: 1px solid #dbeafe;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
}

.anc-staining-score-guide span {
  padding: 5px 6px;
  color: #334155;
  font-size: 8.5px;
  line-height: 1.35;
}

.anc-wisdom-cycle {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #334155;
  font-size: 10px;
}

.anc-legend-swatch {
  width: 42px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  border: 1px solid;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 800;
}

.anc-exam-extra-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.anc-exam-extra-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
}

.anc-exam-extra-grid select,
.anc-exam-extra-grid input,
.anc-exam-extra-grid textarea {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #0f172a;
  font-size: 12px;
  font-weight: 500;
}

.anc-exam-note { grid-column: 1 / -1; }

@media (max-width: 760px) {
  .anc-exam-extra-grid { grid-template-columns: 1fr; }
  .anc-exam-note { grid-column: auto; }
}

.dental-chart-tooth.is-condition-picking {
  cursor: crosshair;
}

.dental-chart-tooth.is-condition-selected {
  box-shadow: inset 0 0 0 3px rgb(20 184 166 / 0.52), 0 0 0 3px rgb(20 184 166 / 0.14);
}

.dental-chart-tooth.is-status-picking {
  cursor: crosshair;
}

.dental-chart-tooth.is-status-blocked {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.65);
}

.dental-chart-tooth.is-status-blocked:hover,
.dental-chart-tooth.is-status-blocked:focus-visible {
  border-color: #cbd5e1;
  transform: none;
  box-shadow: none;
}

.dental-chart-tooth.is-status-selected {
  box-shadow: inset 0 0 0 3px rgb(20 184 166 / 0.52), 0 0 0 3px rgb(20 184 166 / 0.14);
}

.anc-tooth-overlay-markers {
  position: absolute;
  inset: 2px;
  display: flex;
  align-items: flex-start;
  gap: 2px;
  pointer-events: none;
  z-index: 2;
}

.anc-tooth-overlay-marker {
  min-width: 16px;
  height: 14px;
  padding: 0 3px;
  border-radius: 999px;
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  line-height: 14px;
  white-space: nowrap;
}

.anc-tooth-overlay-marker.is-pr { background: #0f766e; }
.anc-tooth-overlay-marker.is-rr { background: #b91c1c; }
.anc-tooth-overlay-marker.is-class-v { background: #7c3aed; }
.anc-tooth-overlay-marker.is-periodontal { background: #c2410c; }
.anc-tooth-overlay-marker.is-mobility {
  margin-left: auto;
  background: #b91c1c;
}

.dental-chart-tooth.has-condition-overlay-markers > span:first-child {
  transform: translateY(7px);
}

.dental-chart-tooth.is-drag-resetting > span:first-child {
  transform: none;
}

.dental-chart-summary {
  margin-top: 8px;
}

.dental-chart-summary-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 4px;
}

.dental-chart-summary-grid div {
  min-width: 0;
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 4px 6px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}

.dental-chart-summary-grid span {
  display: block;
  color: #64748b;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.15;
}

.dental-chart-summary-grid strong {
  display: block;
  color: #0f172a;
  font-size: 16px;
  line-height: 1;
}

.dental-chart-extra-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.36fr);
  gap: 8px;
  margin-top: 8px;
}

/* WCC occupies the two unused columns to the right of SMART and SDF, rather
 * than opening a second side panel. The ABCD body keeps its normal scroll
 * behavior when additional teaching rows genuinely need more height. */
.dental-chart-extra-grid.is-childcare.is-wcc [data-wcc-teaching-editor] {
  grid-column: span 2;
  min-width: 0;
}

.wcc-teaching-panel {
  min-width: 0;
  padding: 8px;
  border: 1px solid rgb(109 90 194 / 0.25);
  border-radius: 8px;
  background: #fbfaff;
}

.wcc-teaching-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
}

.wcc-teaching-summary h4 {
  margin: 0;
  color: #0f172a;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
}

.wcc-teaching-title {
  margin: 0;
  color: #0f172a;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
}

.wcc-teaching-brushing-choice {
  display: grid;
  gap: 2px;
  min-width: 0;
  margin: 4px 0;
  padding: 2px 5px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
  color: #475569;
  font-size: 9px;
  font-weight: 800;
}

.wcc-teaching-choice-row,
.wcc-teaching-straw-choice {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 4px;
  white-space: nowrap;
}

.wcc-teaching-choice-label {
  flex: 0 0 auto;
  color: #475569;
  font-size: 8px;
  font-weight: 900;
}

.wcc-teaching-choice-row label,
.wcc-teaching-straw-choice label {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 3px;
  margin: 0;
}

.wcc-teaching-brushing-choice .wcc-teaching-clear {
  margin: 0 0 0 auto;
}

.wcc-teaching-straw-choice {
  font-size: 8px;
}

.wcc-teaching-summary fieldset {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  white-space: nowrap;
}

.wcc-teaching-summary fieldset label {
  font-size: 10px;
  font-weight: 800;
}

.wcc-teaching-details {
  margin-top: 6px;
}

.wcc-teaching-assessment-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.wcc-teaching-assessment-button {
  min-width: 0;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 6px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #475569;
  font-size: 9px;
  font-weight: 900;
}

.wcc-teaching-assessment-button small {
  padding: 2px 4px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #64748b;
  font-size: 8px;
}

.wcc-teaching-assessment-button.is-complete {
  border-color: #16a34a;
  background: #f0fdf4;
  color: #166534;
}

.wcc-teaching-assessment-button.is-active {
  border-color: var(--primary);
  background: #ede9fe;
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgb(109 90 194 / 0.18);
}

.wcc-teaching-assessment-button:disabled {
  border-color: #d8e0e9;
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
}

.dental-chart-extra-grid.is-childcare.is-wcc [data-wcc-teaching-rows] {
  min-width: 0;
}

.dental-chart-extra-grid.is-childcare.is-wcc .wcc-teaching-row {
  display: grid;
  grid-template-columns: minmax(105px, 0.7fr) minmax(180px, 1.35fr);
  gap: 4px;
  align-items: center;
  margin-top: 4px;
}

.dental-chart-extra-grid.is-childcare.is-wcc .wcc-teaching-row[hidden] {
  display: none;
}

.dental-chart-extra-grid.is-childcare.is-wcc .wcc-teaching-row > label,
.dental-chart-extra-grid.is-childcare.is-wcc .wcc-teaching-row fieldset {
  min-width: 0;
  margin: 0;
  color: #475569;
  font-size: 9px;
  font-weight: 800;
}

.dental-chart-extra-grid.is-childcare.is-wcc .wcc-teaching-row input[type="date"],
.dental-chart-extra-grid.is-childcare.is-wcc .wcc-teaching-row select {
  width: 100%;
  height: 28px;
  margin-top: 2px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  padding: 0 5px;
  font-size: 9px;
}

.dental-chart-extra-grid.is-childcare.is-wcc .wcc-teaching-row fieldset {
  min-height: 45px;
  padding: 3px 5px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}

.dental-chart-extra-grid.is-childcare.is-wcc .wcc-teaching-row fieldset legend {
  padding: 0;
  font-size: 8px;
  line-height: 1.15;
}

.dental-chart-extra-grid.is-childcare.is-wcc .wcc-teaching-row fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 2px 8px 0 0;
}

.wcc-teaching-clear {
  min-height: 20px;
  padding: 0 5px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #64748b;
  font-size: 8px;
  font-weight: 800;
  white-space: nowrap;
}

.wcc-teaching-clear:hover:not(:disabled) {
  border-color: #b91c1c;
  background: #fef2f2;
  color: #b91c1c;
}

.wcc-teaching-clear:disabled {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
}

@media (min-width: 981px) {
  /* WCC has no examination-note column. Reclaim that reserved desktop column
   * so SMART, SDF and teaching use the entire band width. */
  .dental-chart-modal.is-wcc .dental-chart-extra-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .dental-chart-extra-grid.is-childcare.is-wcc {
    grid-template-columns: minmax(138px, 0.65fr) minmax(138px, 0.65fr) minmax(0, 2.7fr);
    align-items: stretch;
  }

  .dental-chart-extra-grid.is-childcare.is-wcc [data-wcc-teaching-editor] {
    grid-column: span 1;
  }

  .dental-chart-modal.is-wcc .wcc-teaching-panel {
    height: 100px;
    display: grid;
    grid-template-columns: 245px minmax(0, 1fr);
    grid-template-rows: 30px minmax(0, 1fr);
    gap: 4px 8px;
    overflow: hidden;
  }

  .dental-chart-modal.is-wcc .wcc-teaching-title {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    align-self: center;
  }

  .dental-chart-modal.is-wcc .wcc-teaching-assessment-list {
    grid-column: 2;
    grid-row: 1;
  }

  .dental-chart-modal.is-wcc .wcc-teaching-brushing-choice {
    grid-column: 1;
    grid-row: 2;
    margin-top: 0;
    margin-bottom: 0;
    align-self: stretch;
  }

  .dental-chart-modal.is-wcc .wcc-teaching-choice-row,
  .dental-chart-modal.is-wcc .wcc-teaching-straw-choice {
    gap: 3px;
  }

  .dental-chart-modal.is-wcc [data-wcc-teaching-rows] {
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
    overflow: hidden;
  }

  .dental-chart-modal.is-wcc .wcc-teaching-row {
    grid-template-columns: minmax(105px, 0.7fr) minmax(180px, 1.35fr);
    margin-top: 0;
  }

  .dental-chart-modal.is-wcc .dental-chart-status-tooth-mode,
  .dental-chart-modal.is-wcc .dental-chart-extra-grid.is-childcare .dental-chart-status-tooth-mode {
    min-height: 100px;
    justify-content: center;
  }
}

.dental-chart-extra-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.dental-chart-extra-grid.is-anc {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.anc-staining-panel {
  position: relative;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr);
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}

.anc-staining-service-title {
  position: absolute;
  top: 0;
  left: 12px;
  z-index: 1;
  padding: 0 5px;
  background: #fff;
  color: #334155;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  transform: translateY(-55%);
  pointer-events: none;
}

.anc-staining-prevention-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  min-width: 0;
}

.anc-staining-panel .dental-chart-extra-check.is-choice {
  min-height: 30px;
  padding: 3px 5px;
  border-color: #dbe3ee;
  background: #f8fafc;
}

.anc-staining-panel .dental-chart-extra-check.is-choice .dental-chart-extra-choice-label {
  font-size: 9px;
}

.anc-staining-panel .dental-chart-extra-check.is-choice .dental-chart-choice-option {
  min-width: 40px;
  min-height: 22px;
  padding: 0 5px;
  font-size: 8px;
}

.anc-staining-heading {
  display: flex;
  justify-content: space-between;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  color: #0f172a;
  font-size: 11px;
}

.anc-staining-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.anc-staining-choice .dental-chart-choice-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 25px;
  padding: 0 4px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #475569;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}

.anc-staining-choice .dental-chart-choice-option input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.anc-staining-choice .dental-chart-choice-option.is-selected,
.anc-staining-choice .dental-chart-choice-option:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, white);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent);
}

.anc-staining-assessment-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  min-width: 0;
}

.anc-staining-assessment-list.is-chart-mode {
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(118px, 1.2fr);
}

.anc-staining-assessment-button {
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 0 7px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
}

.anc-staining-assessment-button small {
  min-width: 29px;
  padding: 2px 4px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #64748b;
  font-size: 8px;
  font-weight: 800;
  text-align: center;
}

.anc-staining-assessment-button:hover:not(:disabled) {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
}

.anc-staining-assessment-button.is-complete {
  border-color: #16a34a;
  background: #f0fdf4;
  color: #166534;
}

.anc-staining-assessment-button.is-active {
  border-color: var(--primary);
  background: #dbeafe;
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgb(37 99 235 / 0.2);
}

.anc-staining-back-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 9px;
  border: 2px solid #2563eb;
  border-radius: 7px;
  background: #2563eb;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 8px rgb(37 99 235 / 0.2);
}

.anc-staining-back-button:hover {
  background: #1d4ed8;
}

.anc-staining-back-button .material-symbols-outlined {
  font-size: 15px;
}

.anc-staining-assessment-button.is-complete small {
  background: #dcfce7;
  color: #166534;
}

.anc-staining-panel.is-disabled .anc-staining-assessment-list {
  opacity: 0.55;
  filter: grayscale(1);
}

.anc-staining-assessment-button:disabled {
  border-color: #d8e0e9;
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
}

.anc-staining-stage {
  min-height: 126px;
  padding: 2px 4px 0;
}

.anc-staining-stage-header,
.anc-staining-stage-header > div,
.anc-staining-stage-footer {
  display: flex;
  align-items: center;
}

.anc-staining-stage-header {
  justify-content: center;
  gap: 12px;
  min-height: 19px;
  margin-bottom: 1px;
}

.anc-staining-stage-header > div {
  gap: 7px;
}

.anc-staining-stage-header .material-symbols-outlined {
  width: 19px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
}

.anc-staining-stage-header > div > div {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.anc-staining-stage-header strong,
.anc-staining-stage-header small {
  display: block;
}

.anc-staining-stage-header strong {
  color: #0f172a;
  font-size: 11px;
}

.anc-staining-stage-header small {
  margin-top: 0;
  color: #64748b;
  font-size: 8px;
}

.anc-staining-assessment-meta {
  display: grid;
  grid-template-columns: minmax(156px, 0.65fr) minmax(220px, 0.9fr) minmax(260px, 1.65fr);
  gap: 5px;
  min-height: 27px;
  margin-bottom: 1px;
}

.anc-staining-date-field,
.anc-staining-note-field,
.anc-staining-timing-field {
  min-width: 0;
  height: 27px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 2px 5px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #f8fafc;
  color: #475569;
  font-size: 8px;
  font-weight: 900;
}

.anc-staining-date-field > span,
.anc-staining-note-field > span,
.anc-staining-timing-field > span {
  flex: 0 0 auto;
  white-space: nowrap;
}

.anc-staining-date-field input,
.anc-staining-note-field input {
  min-width: 0;
  height: 21px;
  flex: 1 1 auto;
  padding: 1px 5px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  color: #0f172a;
  font-size: 9px;
  outline: none;
}

.anc-staining-date-field input:focus,
.anc-staining-note-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 20%, transparent);
}

.anc-staining-timing-field {
  padding-left: 6px;
}

.anc-staining-timing-field label {
  position: relative;
  min-width: 0;
  height: 21px;
  display: inline-flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  color: #475569;
  font-size: 8px;
  white-space: nowrap;
  cursor: pointer;
}

.anc-staining-timing-field label.is-selected,
.anc-staining-timing-field label:has(input:checked) {
  border-color: var(--primary);
  background: #dbeafe;
  color: #1d4ed8;
}

.anc-staining-timing-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.anc-staining-region-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px 7px;
}

.anc-staining-region-card {
  min-width: 0;
  margin: 0;
  padding: 0 5px 2px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}

.anc-staining-region-card:nth-child(-n + 3) {
  border-top-color: #60a5fa;
  background: #f8fbff;
}

.anc-staining-region-card:nth-child(n + 4) {
  border-bottom-color: #818cf8;
  background: #fafaff;
}

.anc-staining-region-card legend {
  padding: 0 5px;
  color: #475569;
  font-size: 9px;
  font-weight: 900;
  line-height: 9px;
}

.anc-staining-region-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.anc-staining-region-options label {
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.anc-staining-region-options label.is-selected,
.anc-staining-region-options label:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 13%, white);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent);
}

.anc-staining-region-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.anc-staining-stage-footer {
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
  color: #64748b;
  font-size: 8px;
}

.anc-staining-stage-footer strong {
  color: #1d4ed8;
  font-size: 10px;
}

.dental-chart-overlay.is-staining-mode [data-chart-fill-normal],
.dental-chart-overlay.is-staining-mode [data-chart-clear] {
  visibility: hidden;
}

.working-age-screening-panel {
  grid-column: 1 / -1;
  overflow: hidden;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #f8fbff;
}

.working-age-screening-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 7px 10px;
  border-bottom: 1px solid #dbeafe;
  background: linear-gradient(135deg, #eff6ff, #f0fdfa);
  color: #0f172a;
}

.working-age-screening-header > .material-symbols-outlined {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 19px;
}

.working-age-screening-header div,
.working-age-screening-card-title {
  min-width: 0;
}

.working-age-screening-header strong,
.working-age-screening-header small {
  display: block;
}

.working-age-screening-header strong {
  font-size: 12px;
  font-weight: 900;
}

.working-age-screening-header small {
  margin-top: 1px;
  color: #64748b;
  font-size: 9px;
}

.working-age-screening-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 8px;
}

.working-age-screening-card {
  min-width: 0;
  padding: 8px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #fff;
  transition: opacity 160ms ease, background 160ms ease;
}

.working-age-screening-card.is-diabetes {
  border-color: #fecaca;
  background: #fffafa;
}

.working-age-screening-card-title {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 7px;
  color: #0f172a;
  font-size: 10px;
}

.working-age-screening-card-title > .material-symbols-outlined {
  color: #2563eb;
  font-size: 16px;
}

.working-age-screening-card.is-diabetes .working-age-screening-card-title > .material-symbols-outlined {
  color: #dc2626;
}

.working-age-screening-card-title strong {
  font-weight: 900;
}

.working-age-screening-card-title small {
  margin-left: auto;
  color: #64748b;
  font-size: 8px;
  font-weight: 700;
}

.working-age-vital-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.working-age-treatment-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(110px, 0.55fr);
  gap: 6px;
}

.working-age-screening-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
  color: #334155;
  font-size: 9px;
  font-weight: 800;
}

.working-age-screening-field > input,
.working-age-screening-input-wrap input {
  width: 100%;
  height: 31px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font-size: 11px;
  font-weight: 700;
  outline: none;
}

.working-age-screening-field > input:focus,
.working-age-screening-input-wrap input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgb(37 99 235 / 0.12);
}

.working-age-screening-input-wrap {
  position: relative;
  display: block;
}

.working-age-screening-input-wrap input {
  padding-right: 48px;
}

.working-age-screening-input-wrap em {
  position: absolute;
  top: 50%;
  right: 7px;
  color: #64748b;
  font-size: 8px;
  font-style: normal;
  font-weight: 800;
  pointer-events: none;
  transform: translateY(-50%);
}

.working-age-disease-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 7px;
}

.working-age-disease-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 29px;
  padding: 0 5px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #475569;
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
}

.working-age-disease-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.working-age-disease-option.is-selected,
.working-age-disease-option:has(input:checked) {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgb(37 99 235 / 0.12);
}

.working-age-screening-dependent.is-disabled {
  border-color: #e2e8f0;
  background: #f1f5f9;
  color: #94a3b8;
  opacity: 0.68;
}

.working-age-screening-dependent.is-disabled input,
.working-age-screening-dependent input:disabled {
  border-color: #d8e0e9;
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
}

/* Working-age form: preserve the original layout and reclaim small gaps. */
@media (min-width: 981px) {
  .dental-chart-modal.is-working-age {
    max-height: calc(100vh - 16px);
  }

  .dental-chart-modal.is-working-age .dental-chart-header {
    padding: 9px 16px;
  }

  .dental-chart-modal.is-working-age .dental-chart-header h3 {
    font-size: 18px;
  }

  .dental-chart-modal.is-working-age .dental-chart-header p {
    font-size: 11px;
  }

  .dental-chart-modal.is-working-age .dental-chart-eyebrow {
    font-size: 11px !important;
  }

  .dental-chart-modal.is-working-age .dental-chart-body {
    gap: 10px;
    padding: 8px 12px;
  }

  .dental-chart-modal.is-working-age .dental-chart-stage {
    padding: 4px 4px 2px;
  }

  .dental-chart-modal.is-working-age .dental-chart-tooth-slot {
    min-height: 60px;
    gap: 3px;
  }

  .dental-chart-modal.is-working-age .dental-chart-tooth-number {
    height: 18px;
    font-size: 16px;
  }

  .dental-chart-modal.is-working-age .dental-chart-tooth {
    height: 38px;
    font-size: 12px;
  }

  .dental-chart-modal.is-working-age .dental-chart-extra-panel {
    gap: 6px;
    margin-top: 6px;
  }

  .dental-chart-modal.is-working-age .dental-chart-extra-check.is-choice {
    min-height: 38px;
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    gap: 6px;
    padding: 5px 7px;
  }

  .dental-chart-modal.is-working-age .dental-chart-extra-choice-label {
    flex: 1 1 auto;
    font-size: 10px;
  }

  .dental-chart-modal.is-working-age .dental-chart-choice-options {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
  }

  .dental-chart-modal.is-working-age .dental-chart-extra-check.is-choice .dental-chart-choice-option {
    width: auto;
    min-width: 45px;
    min-height: 24px;
    padding: 0 6px;
    font-size: 9px;
  }

  .dental-chart-modal.is-working-age .working-age-inline-date {
    min-height: 38px;
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    gap: 7px;
    padding: 5px 7px;
  }

  .dental-chart-modal.is-working-age .working-age-inline-date > span {
    font-size: 10px;
    white-space: nowrap;
  }

  .dental-chart-modal.is-working-age .working-age-inline-date input[type="date"] {
    width: min(135px, 68%);
    height: 27px;
    font-size: 10px;
  }

  .dental-chart-modal.is-working-age .dental-chart-extra-check.has-teeth.is-inline-wide {
    grid-column: 1 / -1;
    min-height: 40px;
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 5px 7px;
  }

  .dental-chart-modal.is-working-age .dental-chart-extra-check.has-teeth.is-inline-wide > label {
    flex: 0 0 min(310px, 42%);
    align-items: center;
  }

  .dental-chart-modal.is-working-age .dental-chart-extra-check.has-teeth.is-inline-wide .dental-chart-tooth-note-row {
    flex: 1 1 auto;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .dental-chart-modal.is-anc-detailed .dental-chart-extra-check.has-teeth.is-inline-wide {
    grid-column: span 2;
  }

  .dental-chart-modal.is-anc-detailed .anc-dental-chart-stage {
    height: 142px;
    min-height: 142px;
  }

  .dental-chart-modal.is-anc-detailed .dental-chart-extra-check.has-teeth.is-inline-wide > label {
    flex-basis: min(260px, 48%);
  }

  .dental-chart-modal.is-anc-detailed .dental-chart-note-box textarea {
    min-height: 82px;
    max-height: 82px;
  }

  .dental-chart-modal.is-working-age .anc-dental-chart-extra-notes {
    grid-template-rows: 1fr;
  }

  .dental-chart-modal.is-working-age .dental-chart-note-box textarea {
    min-height: 92px;
    max-height: 92px;
  }

  .dental-chart-modal.is-working-age .working-age-screening-header {
    min-height: 28px;
    padding: 3px 7px;
  }

  .dental-chart-modal.is-working-age .working-age-screening-header > .material-symbols-outlined {
    width: 21px;
    height: 21px;
    border-radius: 6px;
    font-size: 14px;
  }

  .dental-chart-modal.is-working-age .working-age-screening-header strong {
    font-size: 10px;
  }

  .dental-chart-modal.is-working-age .working-age-screening-layout {
    gap: 5px;
    padding: 5px;
  }

  .dental-chart-modal.is-working-age .working-age-screening-card {
    padding: 6px;
  }

  .dental-chart-modal.is-working-age .working-age-screening-card-title {
    margin-bottom: 4px;
  }

  .dental-chart-modal.is-working-age .working-age-disease-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px;
    margin-bottom: 0;
  }

  .dental-chart-modal.is-working-age .working-age-disease-option {
    min-height: 25px;
  }

  .dental-chart-modal.is-working-age .working-age-screening-field {
    gap: 2px;
  }

  .dental-chart-modal.is-working-age .working-age-screening-field > input,
  .dental-chart-modal.is-working-age .working-age-screening-input-wrap input {
    height: 28px;
  }

  .dental-chart-modal.is-working-age .working-age-disease-row {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(145px, 0.85fr);
    align-items: end;
    gap: 5px;
  }

  .dental-chart-modal.is-working-age .dental-chart-actions {
    padding: 8px 14px;
  }

.dental-chart-modal.is-working-age .dental-chart-primary,
.dental-chart-modal.is-working-age .dental-chart-secondary {
  height: 34px;
}
}

/* WCC uses the same compact desktop rhythm as the working-age chart. The
 * teaching panel stays small until the user chooses “ใช่”; added occurrences
 * are the only content that may require the normal modal scroll. */
@media (min-width: 981px) {
  .dental-chart-modal.is-wcc {
    max-height: calc(100vh - 16px);
  }

  .dental-chart-modal.is-wcc .dental-chart-header {
    padding: 9px 16px;
  }

  .dental-chart-modal.is-wcc .dental-chart-header h3 {
    font-size: 18px;
  }

  .dental-chart-modal.is-wcc .dental-chart-header p,
  .dental-chart-modal.is-wcc .dental-chart-eyebrow {
    font-size: 11px !important;
  }

  .dental-chart-modal.is-wcc .dental-chart-body {
    gap: 10px;
    padding: 8px 12px;
  }

  .dental-chart-modal.is-wcc .dental-chart-stage {
    padding: 4px 4px 2px;
  }

  .dental-chart-modal.is-wcc .dental-chart-tooth-slot {
    min-height: 60px;
    gap: 3px;
  }

  .dental-chart-modal.is-wcc .dental-chart-tooth-number {
    height: 18px;
    font-size: 16px;
  }

  .dental-chart-modal.is-wcc .dental-chart-tooth {
    height: 38px;
    font-size: 12px;
  }

  .dental-chart-modal.is-wcc .dental-chart-summary {
    margin-top: 4px;
  }

  .dental-chart-modal.is-wcc .dental-chart-summary-grid div {
    min-height: 30px;
  }

  .dental-chart-modal.is-wcc .dental-chart-extra-panel {
    gap: 6px;
    margin-top: 6px;
  }

  .dental-chart-modal.is-wcc .dental-chart-status-tooth-mode,
  .dental-chart-modal.is-wcc .dental-chart-extra-grid.is-childcare .dental-chart-status-tooth-mode {
    min-height: 58px;
    gap: 4px;
    padding: 6px 8px;
  }

  .dental-chart-modal.is-wcc .dental-chart-status-tooth-mode-label {
    font-size: 12px;
  }

  .dental-chart-modal.is-wcc .dental-chart-status-tooth-mode-teeth {
    font-size: 11px;
  }

  .dental-chart-modal.is-wcc .wcc-teaching-panel {
    padding: 6px 8px;
  }

  .dental-chart-modal.is-wcc .wcc-teaching-summary {
    min-height: 24px;
  }

  .dental-chart-modal.is-wcc .dental-chart-actions {
    padding: 8px 14px;
  }

  .dental-chart-modal.is-wcc .dental-chart-primary,
  .dental-chart-modal.is-wcc .dental-chart-secondary {
    height: 34px;
  }
}

.dental-chart-extra-grid.is-childcare {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dental-chart-extra-grid.is-childcare .dental-chart-extra-check {
  padding: 5px 6px;
  font-size: 10px;
}

.dental-chart-extra-grid.is-childcare .dental-chart-extra-check.has-teeth {
  grid-column: span 2;
}

.dental-chart-extra-grid.is-childcare .dental-chart-choice-options {
  gap: 3px;
}

.dental-chart-extra-grid.is-childcare .dental-chart-extra-check.is-choice .dental-chart-choice-option {
  gap: 3px;
  min-height: 25px;
  padding: 0 4px;
  font-size: 9px;
}

.dental-chart-status-tooth-mode {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-height: 78px;
}

.dental-chart-extra-grid.is-childcare .dental-chart-status-tooth-mode {
  padding: 9px 12px;
}

.dental-chart-extra-grid.is-childcare .dental-chart-status-tooth-mode-head {
  justify-content: space-between;
  gap: 8px;
}

.dental-chart-status-tooth-mode-head,
.dental-chart-status-tooth-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  min-width: 0;
}

.dental-chart-status-tooth-mode-label {
  color: #0f172a;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.dental-chart-status-tooth-mode-teeth {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
  color: #475569;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.3;
  overflow-wrap: anywhere;
  text-align: center;
  white-space: normal;
}

.dental-chart-extra-grid.is-childcare .dental-chart-status-tooth-mode-row {
  justify-content: flex-start;
  align-items: flex-start;
  gap: 0;
}

.dental-chart-status-tooth-mode button {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.dental-chart-status-tooth-mode button.is-active {
  border-color: #0f766e;
  background: #ccfbf1;
  color: #0f766e;
}

.dental-chart-extra-check,
.dental-chart-note-box {
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.dental-chart-extra-check {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  color: #0f172a;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
}

.dental-chart-extra-check.is-choice {
  align-items: stretch;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}

.dental-chart-extra-check.has-teeth {
  align-items: stretch;
  flex-direction: column;
  gap: 5px;
}

.dental-chart-extra-choice-label {
  min-width: 0;
}

.dental-chart-extra-check label {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-width: 0;
}

.dental-chart-extra-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  flex: 0 0 auto;
}

.dental-chart-extra-check span {
  min-width: 0;
}

.dental-chart-choice-options {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.dental-chart-extra-check.is-choice .dental-chart-choice-option {
  position: relative;
  z-index: 1;
  display: flex !important;
  align-items: center !important;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #475569;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  outline: none;
}

.dental-chart-choice-option.is-selected,
.dental-chart-choice-option:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, white);
  color: var(--primary);
}

.dental-chart-choice-option input[type="radio"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--primary);
  flex: 0 0 auto;
}

.dental-chart-choice-option span {
  min-width: 0;
}

.dental-chart-choice-option:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(25 118 210 / 0.14);
}

.dental-chart-tooth-note-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
}

.dental-chart-tooth-note-row input,
.dental-chart-note-box textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  outline: none;
}

.anc-dental-chart-extra-notes {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  min-width: 0;
}

.anc-dental-chart-date-box input[type="date"] {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font-size: 11px;
  outline: none;
}


.dental-chart-tooth-note-row input {
  height: 28px;
  padding: 0 7px;
  font-size: 11px;
  cursor: default;
}

.dental-chart-tooth-note-row input:read-only {
  background: #f8fafc;
  color: #0f172a;
}

.dental-chart-tooth-note-row input:disabled {
  background: #f8fafc;
  color: #94a3b8;
}

.dental-chart-tooth-note-row button {
  height: 28px;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #475569;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

.dental-chart-tooth-note-row button.is-active {
  border-color: #b91c1c;
  background: #fee2e2;
  color: #b91c1c;
}

.dental-chart-tooth-note-row button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.dental-chart-note-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #0f172a;
  font-size: 11px;
  font-weight: 800;
}

.dental-chart-note-box textarea {
  min-height: 74px;
  max-height: 74px;
  resize: none;
  padding: 7px 8px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
}

.dental-chart-guideline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.dental-chart-guideline h4 {
  margin: 0;
  color: #0f172a;
  font-size: 12px;
  font-weight: 800;
  text-decoration: underline;
}

.dental-chart-usage {
  padding: 10px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
}

.dental-chart-usage h4 {
  margin-bottom: 6px;
  color: #1e40af;
  text-decoration: none;
}

.dental-chart-usage ul {
  margin: 0;
  padding-left: 18px;
  color: #334155;
  font-size: 11px;
  line-height: 1.45;
}

.dental-chart-usage li + li {
  margin-top: 4px;
}

.dental-chart-code-table {
  display: grid;
  gap: 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.dental-chart-code-head,
.dental-chart-code-row {
  display: grid;
  grid-template-columns: 44px 42px minmax(0, 1fr);
  align-items: stretch;
}

.dental-chart-code-head {
  background: #f8fafc;
  color: #475569;
  font-size: 10px;
  font-weight: 800;
}

.dental-chart-code-head span,
.dental-chart-code-row span {
  min-width: 0;
  padding: 7px 8px;
  border-right: 1px solid #e2e8f0;
}

.dental-chart-code-head span:last-child,
.dental-chart-code-row span:last-child {
  border-right: 0;
}

.dental-chart-code-row {
  border-top: 1px solid #e2e8f0;
  color: #334155;
  font-size: 11px;
  line-height: 1.35;
}

.dental-chart-code-row.is-unavailable {
  background: #f8fafc;
  color: #94a3b8;
}

.dental-chart-code-primary,
.dental-chart-code-permanent {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.dental-chart-code-permanent.is-unavailable {
  background: #f1f5f9;
  color: #94a3b8;
}

.dental-chart-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.dental-chart-primary,
.dental-chart-secondary {
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.dental-chart-primary {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.dental-chart-secondary {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
}

.dental-chart-primary:disabled,
.dental-chart-secondary:disabled {
  cursor: wait;
}

@media (max-width: 980px) {
  .dental-chart-overlay {
    align-items: stretch;
    padding: 10px;
  }

  .dental-chart-modal {
    max-height: calc(100vh - 20px);
  }

  .dental-chart-body {
    grid-template-columns: 1fr;
  }

  .dental-chart-main {
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

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

  .dental-chart-extra-panel {
    grid-template-columns: 1fr;
  }

  .dental-chart-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dental-chart-actions > div {
    justify-content: stretch;
  }

  .dental-chart-primary,
  .dental-chart-secondary {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .dental-chart-stage {
    --dental-chart-cell-size: 40px;
  }

  .dental-chart-tooth {
    height: 36px;
    font-size: 12px;
  }

  .dental-chart-tooth-number {
    height: 18px;
    font-size: 15px;
  }

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

  .dental-chart-extra-grid,
  .dental-chart-extra-grid.is-childcare,
  .dental-chart-extra-grid.is-anc {
    grid-template-columns: 1fr;
  }

  .anc-staining-panel { grid-template-columns: 1fr; }
  .anc-staining-assessment-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .anc-staining-region-grid { grid-template-columns: 1fr; }

  .working-age-screening-layout,
  .working-age-treatment-grid {
    grid-template-columns: 1fr;
  }

  .working-age-vital-grid {
    grid-template-columns: 1fr;
  }

  .working-age-disease-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dental-chart-extra-grid.is-childcare .dental-chart-extra-check.has-teeth {
    grid-column: auto;
  }
}

.dental-compare-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 0 0 32px;
}

.dental-compare-toolbar {
  width: min(210mm, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.dental-compare-toolbar-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #0f172a;
  font-size: 12px;
  line-height: 1.35;
}

.dental-compare-toolbar-title strong {
  font-size: 16px;
  font-weight: 900;
}

.dental-compare-toolbar-title span {
  max-width: 360px;
  overflow: hidden;
  color: #475569;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dental-compare-toolbar-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.dental-compare-toolbar-btn.is-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.dental-compare-warning {
  width: min(210mm, 100%);
  padding: 10px 12px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
  font-weight: 800;
}

.dental-compare-print-root {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: max-content;
  min-width: 210mm;
}

.dental-compare-print-scroll {
  width: min(210mm, 100%);
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 8px;
}

.dental-compare-page {
  width: 210mm;
  height: 297mm;
  display: flex;
  flex-direction: column;
  gap: 3mm;
  padding: 8mm 8mm;
  overflow: hidden;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 18px 44px rgb(15 23 42 / 0.18);
}

.dental-compare-page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86mm;
  gap: 8mm;
  align-items: start;
  padding-bottom: 3mm;
  border-bottom: 2px solid #0f172a;
}

.dental-compare-page-header p {
  margin: 0 0 0.5mm;
  color: #475569;
  font-size: 9.5pt;
  font-weight: 800;
}

.dental-compare-page-header h2 {
  margin: 0;
  color: #0f172a;
  font-size: 17pt;
  font-weight: 900;
  line-height: 1.15;
}

.dental-compare-page-meta {
  display: grid;
  gap: 0.8mm;
  color: #334155;
  font-size: 8pt;
  line-height: 1.25;
}

.dental-compare-page-meta span {
  min-width: 0;
}

.dental-compare-page-meta strong,
.dental-compare-grade-block .has-ink,
.dental-compare-field-value.has-ink,
.dental-compare-summary-grid strong.has-ink,
.dental-compare-tooth.has-ink {
  color: #174ea6;
}

.dental-compare-grade-stack {
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: 2.3mm;
  min-height: 0;
  flex: 1;
}

.dental-compare-grade-block {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1mm;
  padding: 1.8mm;
  border: 1.5px solid #0f172a;
  background: #fff;
}

.dental-compare-grade-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4mm;
  border-bottom: 1px solid #cbd5e1;
  padding-bottom: 1mm;
}

.dental-compare-grade-header h3 {
  margin: 0;
  color: #0f172a;
  font-size: 13pt;
  font-weight: 900;
  line-height: 1;
}

.dental-compare-grade-header p {
  margin: 0.6mm 0 0;
  color: #64748b;
  font-size: 8pt;
  font-weight: 800;
  line-height: 1.2;
}

.dental-compare-chart {
  --dental-compare-cell-size: 6.9mm;
  --dental-compare-column-count: 14;
  display: flex;
  flex-direction: column;
  gap: 0.45mm;
  padding-top: 0.5mm;
}

.dental-compare-chart.is-childcare-compact {
  --dental-compare-column-count: 12;
}

.dental-compare-chart-row {
  display: grid;
  grid-template-columns: repeat(var(--dental-compare-column-count), minmax(0, var(--dental-compare-cell-size)));
  justify-content: center;
  gap: 0.55mm;
}

.dental-compare-tooth-slot {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35mm;
}

.dental-compare-tooth-slot.number-bottom {
  flex-direction: column-reverse;
}

.dental-compare-tooth-slot.is-spacer {
  visibility: hidden;
}

.dental-compare-tooth-number {
  height: 2.4mm;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0f172a;
  font-size: 6pt;
  font-weight: 900;
  line-height: 1;
}

.dental-compare-tooth {
  width: var(--dental-compare-cell-size);
  height: 4.4mm;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.2px solid #0f172a;
  background: #fff;
  font-size: 7pt;
  font-weight: 900;
  line-height: 1;
}

.dental-compare-tooth.is-primary {
  border-color: #64748b;
}

.dental-compare-tooth.has-pr::after,
.dental-compare-tooth.has-rr::before {
  position: absolute;
  right: 0.4mm;
  min-width: 3.5mm;
  height: 2.5mm;
  color: #174ea6;
  font-size: 4.5pt;
  font-weight: 900;
  line-height: 2.5mm;
  text-align: center;
}

.dental-compare-tooth.has-pr::after {
  content: "PR";
  top: 0.2mm;
}

.dental-compare-tooth.has-rr::before {
  content: "RR";
  bottom: 0.2mm;
}

.dental-compare-chart-divider {
  height: 1mm;
  margin: 0.15mm 0;
  background: #0f172a;
}

.dental-compare-summary-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.7mm;
}

.dental-compare-summary-grid div {
  min-width: 0;
  min-height: 5.7mm;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1mm;
  padding: 0.75mm 1mm;
  border: 1px solid #cbd5e1;
}

.dental-compare-summary-grid span {
  min-width: 0;
  color: #475569;
  font-size: 5.8pt;
  font-weight: 800;
  line-height: 1.1;
}

.dental-compare-summary-grid strong {
  flex: 0 0 auto;
  color: #0f172a;
  font-size: 9pt;
  font-weight: 900;
  line-height: 1;
}

.dental-compare-extra-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.6mm;
}

.dental-compare-field {
  min-width: 0;
  min-height: 5.8mm;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(10mm, 1fr);
  align-items: end;
  gap: 1.2mm;
  padding: 0.65mm 0.85mm;
  border: 1px solid #cbd5e1;
  background: #fff;
}

.dental-compare-field.is-wide {
  grid-column: span 2;
}

.dental-compare-field-label {
  color: #334155;
  font-size: 5.8pt;
  font-weight: 800;
  line-height: 1.15;
}

.dental-compare-field-value {
  min-width: 0;
  display: block;
  border-bottom: 1px dotted #94a3b8;
  color: #0f172a;
  font-size: 7pt;
  font-weight: 900;
  line-height: 1.2;
  word-break: break-word;
}

.dental-compare-field.is-note .dental-compare-field-value.has-ink {
  color: #c21f32;
}

.dental-compare-legend {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
  gap: 2mm;
  padding: 2mm;
  border: 1px solid #0f172a;
  background: #fff;
}

.dental-compare-legend-section {
  min-width: 0;
  color: #334155;
}

.dental-compare-legend-section strong {
  display: block;
  margin-bottom: 0.8mm;
  color: #0f172a;
  font-size: 7pt;
  font-weight: 900;
  line-height: 1.1;
}

.dental-compare-legend-section strong span {
  color: #64748b;
  font-size: 6pt;
  font-weight: 800;
}

.dental-compare-legend-section p {
  margin: 0;
  font-size: 5.8pt;
  font-weight: 700;
  line-height: 1.28;
}

.dental-compare-legend-section p + p {
  margin-top: 0.6mm;
}

.dental-compare-code-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55mm 1.6mm;
}

.dental-compare-code-legend span {
  min-width: 0;
  color: #334155;
  font-size: 5.6pt;
  font-weight: 700;
  line-height: 1.18;
}

.dental-compare-code-legend b {
  color: #0f172a;
  font-weight: 900;
}

@media (max-width: 900px) {
  .dental-compare-shell {
    align-items: stretch;
    width: 100%;
    min-width: 0;
  }

  .dental-compare-toolbar,
  .dental-compare-warning {
    width: 100%;
    min-width: 0;
  }

  .dental-compare-toolbar {
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .dental-compare-toolbar-btn {
    flex: 1 1 150px;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .dental-compare-toolbar-title {
    order: 3;
    flex: 1 0 100%;
    align-items: flex-start;
  }

  .dental-compare-toolbar-title span {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .dental-compare-print-scroll {
    width: 100%;
  }
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  body * {
    visibility: hidden !important;
  }

  #dental-compare-print-root,
  #dental-compare-print-root * {
    visibility: visible !important;
  }

  #dental-compare-print-root {
    position: absolute;
    inset: 0 auto auto 0;
    width: 210mm;
    display: block;
  }

  .dental-compare-toolbar,
  .dental-compare-warning {
    display: none !important;
  }

  .dental-compare-page {
    width: 210mm;
    height: 297mm;
    margin: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  .dental-compare-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}

.overwrite-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(15 23 42 / 0.42);
}

.overwrite-confirm-modal {
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgb(15 23 42 / 0.24);
}

.overwrite-confirm-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 22px 24px 12px;
  color: #0f172a;
}

.overwrite-confirm-header .material-symbols-outlined {
  color: #d97706;
  font-size: 28px;
  line-height: 1;
}

.overwrite-confirm-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 800;
}

.overwrite-confirm-body {
  padding: 0 24px 18px;
  color: #334155;
  font-size: 14px;
  line-height: 1.65;
}

.overwrite-confirm-body p {
  margin: 8px 0;
}

.overwrite-confirm-affected,
.overwrite-confirm-advice ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.overwrite-confirm-advice {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #78350f;
}

.overwrite-confirm-advice-title {
  margin: 0 0 6px !important;
  font-weight: 800;
}

.overwrite-confirm-question {
  margin-top: 16px !important;
  font-weight: 800;
  color: #0f172a;
}

.overwrite-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 22px;
  border-top: 1px solid #e2e8f0;
}

.overwrite-confirm-cancel,
.overwrite-confirm-ok {
  min-height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.overwrite-confirm-cancel {
  border-color: #cbd5e1;
  background: #fff;
  color: #334155;
}

.overwrite-confirm-ok {
  background: #dc2626;
  color: #fff;
}

.overwrite-confirm-cancel:focus,
.overwrite-confirm-ok:focus {
  outline: 3px solid rgb(37 99 235 / 0.28);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .overwrite-confirm-overlay {
    align-items: flex-end;
    padding: 12px;
  }

  .overwrite-confirm-modal {
    border-radius: 14px;
  }

  .overwrite-confirm-actions {
    flex-direction: column-reverse;
  }

  .overwrite-confirm-cancel,
  .overwrite-confirm-ok {
    width: 100%;
  }
}

/* DENT-194: each register has one scrollport for both axes. Only its column
 * headings are sticky; page controls and card headers remain in normal flow. */
.age-register-table-viewport {
  max-height: min(68vh, 46rem);
  overflow: auto;
  overscroll-behavior: contain;
}

.age-register-table-viewport > table {
  border-collapse: separate;
  border-spacing: 0;
}

.age-register-table-viewport thead {
  position: sticky;
  top: 0;
  z-index: 20;
}

.age-register-table-viewport thead th {
  background: #fff;
  box-shadow: inset 0 -1px 0 rgb(226 232 240 / 0.9);
}

/* ==========================================================
   DENTAL FILE MODAL — HOSxP-style Dental Care Form
   ========================================================== */

.dental-file-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.dental-file-modal {
  width: 100%;
  max-width: 900px;
  background: #f0f4f8;
  border: 2px solid #5a7fc0;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 13px;
  font-family: 'Sarabun', 'Tahoma', sans-serif;
}

/* ── Header ── */
.dental-file-header {
  background: linear-gradient(180deg, #4a72c4 0%, #2b55b0 100%);
  color: #fff;
  border-bottom: 2px solid #1e4090;
}

.dental-file-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
}

.dental-file-header-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.dental-file-task-btn {
  padding: 3px 14px;
  background: #3a60b5;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.dental-file-task-btn:hover { background: #2d4d9a; }

.dental-file-sub-bar {
  padding: 4px 12px;
  background: rgba(0,0,0,0.12);
  font-size: 12px;
  color: rgba(255,255,255,0.85);
}

/* ── Body ── */
.dental-file-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: calc(90vh - 120px);
}

/* ── Top Info Row ── */
.dental-file-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  background: #fff;
  border: 1px solid #c0c8d8;
  border-radius: 4px;
}

.dental-file-info-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Student name bar ── */
.dental-file-name-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: linear-gradient(90deg, #e8f0ff 0%, #f0f4ff 100%);
  border: 1px solid #c5d3f0;
  border-radius: 4px;
  font-size: 13px;
}

/* ── Two-column layout ── */
.dental-file-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: start;
}

/* ── Section ── */
.dental-file-section {
  border: 1px solid #a8b8d0;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  margin-bottom: 6px;
}

.dental-file-section:last-child { margin-bottom: 0; }

.dental-file-section-title {
  background: linear-gradient(180deg, #d4e2f5 0%, #c5d6ee 100%);
  padding: 4px 10px;
  font-weight: 700;
  font-size: 12px;
  color: #1a3a6e;
  border-bottom: 1px solid #a8b8d0;
}

.dental-file-section-body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* ── Two inline fields ── */
.dental-file-two-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Field row ── */
.dental-file-field-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dental-file-label {
  font-size: 12px;
  color: #2a4070;
  white-space: nowrap;
  min-width: 160px;
  flex-shrink: 0;
}

/* ── Number spinner ── */
.dental-file-spinner-wrap {
  position: relative;
  width: 72px;
  flex-shrink: 0;
}

.dental-file-spinner {
  width: 100%;
  height: 26px;
  border: 1px solid #9aaac0;
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--on-surface);
  background: #fff;
  outline: none;
  text-align: center;
  transition: border-color 0.15s;
}
.dental-file-spinner:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(104,88,186,0.12);
}

/* ── Text input ── */
.dental-file-text-input {
  height: 26px;
  border: 1px solid #9aaac0;
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--on-surface);
  background: #fff;
  outline: none;
  flex: 1;
  transition: border-color 0.15s;
}
.dental-file-text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(104,88,186,0.12);
}
.dental-file-text-input[readonly] {
  background: #f0f4f8;
  color: var(--on-surface-variant);
}

.dental-file-text-short {
  height: 26px;
  border: 1px solid #9aaac0;
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--on-surface);
  background: #fff;
  outline: none;
  flex: 1;
  min-width: 0;
  transition: border-color 0.15s;
}
.dental-file-text-short:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(104,88,186,0.12);
}

/* ── Select ── */
.dental-file-select {
  height: 26px;
  border: 1px solid #9aaac0;
  border-radius: 3px;
  padding: 2px 20px 2px 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--on-surface);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23737687'%3E%3Cpath d='M3 4l3 3.5L9 4z'/%3E%3C/svg%3E") no-repeat right 5px center;
  appearance: none;
  outline: none;
  flex: 1;
  transition: border-color 0.15s;
}
.dental-file-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(104,88,186,0.12);
}

/* ── Checkboxes group ── */
.dental-file-checks-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #a8b8d0;
  border-radius: 4px;
  margin-bottom: 6px;
}

.dental-file-check-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #1a3a6e;
  cursor: pointer;
  user-select: none;
}

.dental-file-checkbox {
  width: 14px;
  height: 14px;
  border: 1px solid #9aaac0;
  border-radius: 2px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Right column ── */
.dental-file-right-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dental-file-section--right .dental-file-section-body {
  gap: 6px;
}

.dental-file-right-num-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.dental-file-right-label {
  font-size: 12px;
  color: #2a4070;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

.dental-file-right-label-small {
  font-size: 11px;
  color: #2a4070;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Textarea ── */
.dental-file-textarea {
  width: 100%;
  border: 1px solid #9aaac0;
  border-radius: 3px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--on-surface);
  background: #fff;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
}
.dental-file-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(104,88,186,0.12);
}

/* ── Search button ── */
.dental-file-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 26px;
  padding: 0 10px;
  background: #d0182a;
  color: #fff;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}
.dental-file-search-btn:hover { background: #b01020; }

/* ── Footer ── */
.dental-file-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #e4ecf5;
  border-top: 1px solid #a8b8d0;
}

.dental-file-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.dental-file-btn--primary {
  background: #2b55b0;
  color: #fff;
  border-color: #1e4090;
}
.dental-file-btn--primary:hover { background: #1e4090; }

.dental-file-btn--secondary {
  background: #e0e8f4;
  color: #2a4070;
  border-color: #a8b8d0;
}
.dental-file-btn--secondary:hover { background: #c8d5ea; }

.dental-file-btn--danger {
  background: #d0182a;
  color: #fff;
  border-color: #a01020;
}
.dental-file-btn--danger:hover { background: #a01020; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .dental-file-two-col {
    grid-template-columns: 1fr;
  }
  .dental-file-top-row {
    grid-template-columns: 1fr;
  }
  .dental-file-two-inline {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================
   df-* classes — new HOSxP-accurate layout for Dental File Modal
   ========================================================== */

/* Window title bar */
.df-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1f3b7a;
  padding: 3px 6px;
  gap: 8px;
  user-select: none;
}
.df-titlebar-left {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #fff;
  font-size: 12px;
  overflow: hidden;
}
.df-titlebar-icon { color: #a8c8f8; font-size: 14px !important; }
.df-titlebar-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.df-titlebar-winbtns { display: flex; gap: 2px; flex-shrink: 0; }
.df-winbtn {
  width: 22px; height: 18px;
  font-size: 10px; line-height: 1;
  background: #3a5fac; border: 1px solid #5a7fd0;
  color: #fff; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  border-radius: 2px; padding: 0;
  transition: background 0.1s;
}
.df-winbtn:hover { background: #4a74c0; }
.df-winbtn--close:hover { background: #c0182a; }

/* Blue app bar */
.df-appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #4a72c4 0%, #2b55b0 100%);
  padding: 6px 12px;
  border-bottom: 2px solid #1e4090;
}
.df-appbar-title { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: 0.01em; }
.df-task-btn {
  padding: 3px 14px;
  background: #3a60b5; border: 1px solid rgba(255,255,255,0.4);
  border-radius: 4px; color: #fff; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background 0.15s;
}
.df-task-btn:hover { background: #2d4d9a; }

/* Tab strip */
.df-tabstrip {
  padding: 3px 8px 0;
  background: rgba(0,0,0,0.10);
  border-bottom: 1px solid #2b55b0;
  display: flex;
}
.df-tab {
  padding: 3px 12px;
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  cursor: default;
  border-radius: 3px 3px 0 0;
  background: transparent;
}
.df-tab--active {
  background: #f0f4f8;
  color: #1a3a6e;
  font-weight: 600;
  border: 1px solid #a8b8d0;
  border-bottom: 1px solid #f0f4f8;
}

/* Body */
.df-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: calc(90vh - 100px);
  background: #f0f4f8;
}

/* Top grid: left col (ประเภท + ผู้ให้บริการ) | right col (สถานที่) */
.df-top-grid {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 8px;
  padding: 8px;
  background: #fff;
  border: 1px solid #c0c8d8;
  border-radius: 3px;
}
.df-top-left, .df-top-right { display: flex; flex-direction: column; gap: 5px; }

/* Main two-column grid */
.df-main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: start;
}
.df-col-left, .df-col-right { display: flex; flex-direction: column; gap: 0; }

/* Fieldset sections */
.df-fieldset {
  border: 1px solid #a8b8d0;
  border-radius: 3px;
  background: #fff;
  margin-bottom: 6px;
  padding: 0;
}
.df-fieldset:last-child { margin-bottom: 0; }
.df-fieldset--right { margin-bottom: 0; padding: 0; }

.df-legend {
  font-size: 11px;
  font-weight: 700;
  color: #1a3a6e;
  background: linear-gradient(180deg, #d4e2f5 0%, #c5d6ee 100%);
  padding: 3px 8px;
  width: 100%;
  display: block;
  border-bottom: 1px solid #a8b8d0;
  box-sizing: border-box;
}

.df-fieldset-body {
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* ── Left column: label + input inline row ── */
.df-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}

/* Label takes up ~65% left side, number box sits right */
.df-row-label {
  font-size: 12px;
  color: #1a3a6e;
  flex: 1;
  line-height: 1.3;
  white-space: normal;
}

.df-row--inline .df-row-label {
  flex: none;
}

/* Two fields side-by-side in top row */
.df-two-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Number input */
.df-num-box {
  width: 66px;
  flex-shrink: 0;
  height: 22px;
  border: 1px solid #9aaac0;
  border-radius: 2px;
  padding: 1px 4px;
  font-size: 12px;
  font-family: inherit;
  text-align: right;
  background: #eef2f8;
  color: #1a3a6e;
  cursor: default;
  outline: none;
}
.df-num-box:disabled { opacity: 1; -webkit-text-fill-color: #1a3a6e; }

/* Text input */
.df-txt-box {
  height: 22px;
  border: 1px solid #9aaac0;
  border-radius: 2px;
  padding: 1px 6px;
  font-size: 12px;
  font-family: inherit;
  background: #eef2f8;
  color: #1a3a6e;
  cursor: default;
  outline: none;
  flex: 1;
}
.df-txt-box--wide { flex: 1; min-width: 0; }
.df-txt-box:disabled { opacity: 1; -webkit-text-fill-color: #1a3a6e; }

.df-txt-short {
  height: 22px;
  border: 1px solid #9aaac0;
  border-radius: 2px;
  padding: 1px 4px;
  font-size: 12px;
  font-family: inherit;
  background: #eef2f8;
  color: #1a3a6e;
  cursor: default;
  outline: none;
  flex: 1;
  min-width: 0;
}
.df-txt-short:disabled { opacity: 1; -webkit-text-fill-color: #1a3a6e; }

/* Select */
.df-sel-box {
  height: 22px;
  border: 1px solid #9aaac0;
  border-radius: 2px;
  padding: 1px 18px 1px 4px;
  font-size: 12px;
  font-family: inherit;
  background: #eef2f8 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23737687'%3E%3Cpath d='M2 3l3 3.5L8 3z'/%3E%3C/svg%3E") no-repeat right 4px center;
  color: #1a3a6e;
  appearance: none;
  cursor: default;
  outline: none;
  flex: 1;
}
.df-sel-box--wide { flex: 1; min-width: 0; }
.df-sel-box:disabled { opacity: 1; -webkit-text-fill-color: #1a3a6e; }

/* Textarea */
.df-textarea {
  width: 100%;
  border: 1px solid #9aaac0;
  border-radius: 2px;
  padding: 4px 6px;
  font-size: 12px;
  font-family: inherit;
  background: #eef2f8;
  color: #1a3a6e;
  resize: none;
  cursor: default;
  outline: none;
}
.df-textarea:disabled { opacity: 1; -webkit-text-fill-color: #1a3a6e; }

/* Search button */
.df-search-btn {
  display: inline-flex; align-items: center; gap: 3px;
  height: 22px; padding: 0 8px;
  background: #d0182a; color: #fff; border-radius: 2px;
  font-size: 11px; font-weight: 600; font-family: inherit;
  cursor: default; white-space: nowrap; flex-shrink: 0;
  opacity: 0.7;
}

/* ── Checkboxes panel ── */
.df-checks-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 8px;
  background: #fff;
  border: 1px solid #a8b8d0;
  border-radius: 3px;
  margin-bottom: 6px;
}
.df-check-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #1a3a6e;
  cursor: default; user-select: none;
}
.df-check-row--checked { font-weight: 700; color: #0a2a60; }
.df-checkbox {
  width: 14px; height: 14px;
  accent-color: #2b55b0;
  cursor: default; flex-shrink: 0;
}

/* ── Right column rows ── */
.df-rrow {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
  padding: 2px 0;
}
.df-rrow--full { flex-wrap: wrap; gap: 4px; padding: 4px 0; }

.df-rrow-label {
  font-size: 11px; color: #1a3a6e;
  flex: 1; min-width: 0; line-height: 1.3;
}
.df-rrow-sublabel {
  font-size: 11px; color: #1a3a6e;
  white-space: nowrap; flex-shrink: 0;
}

/* ── Footer ── */
.df-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px;
  background: #e4ecf5;
  border-top: 1px solid #a8b8d0;
  flex-shrink: 0;
}
.df-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 14px;
  border-radius: 3px; font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer; border: 1px solid transparent;
  transition: background 0.12s;
}
.df-btn--primary { background: #2b55b0; color: #fff; border-color: #1e4090; }
.df-btn--primary:hover { background: #1e4090; }
.df-btn--secondary { background: #e0e8f4; color: #2a4070; border-color: #a8b8d0; }
.df-btn--secondary:hover { background: #c8d5ea; }
.df-btn--danger { background: #d0182a; color: #fff; border-color: #a01020; }
.df-btn--danger:hover { background: #a01020; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .df-main-grid { grid-template-columns: 1fr; }
  .df-top-grid { grid-template-columns: 1fr; }
  .df-two-inline { grid-template-columns: 1fr; }
}

/* ── Top panel (ประเภทผู้รับบริการ + สถานที่) ── */
.df-top-panel {
  display: flex;
  gap: 8px;
  padding: 8px;
  background: #fff;
  border: 1px solid #c0c8d8;
  border-radius: 3px;
}
.df-top-main { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.df-top-side { width: 220px; flex-shrink: 0; display: flex; flex-direction: column; gap: 5px; }

.df-top-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.df-top-lbl {
  font-size: 12px;
  color: #1a3a6e;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 130px;
}
.df-top-sel {
  height: 22px;
  border: 1px solid #9aaac0;
  border-radius: 2px;
  padding: 1px 18px 1px 4px;
  font-size: 12px;
  font-family: inherit;
  background: #eef2f8 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23737687'%3E%3Cpath d='M2 3l3 3.5L8 3z'/%3E%3C/svg%3E") no-repeat right 4px center;
  color: #1a3a6e;
  appearance: none;
  cursor: default;
  outline: none;
  flex: 1;
  min-width: 0;
}
.df-top-sel:disabled { opacity: 1; -webkit-text-fill-color: #1a3a6e; }
.df-top-inp {
  height: 22px;
  border: 1px solid #9aaac0;
  border-radius: 2px;
  padding: 1px 6px;
  font-size: 12px;
  font-family: inherit;
  background: #eef2f8;
  color: #1a3a6e;
  cursor: default;
  outline: none;
  flex: 1;
  min-width: 0;
}
.df-top-inp:disabled { opacity: 1; -webkit-text-fill-color: #1a3a6e; }

/* Editable spinner variant — ฟันแท้ and ฟันน้ำนม sections only */
.df-num-box--edit {
  background: #fff;
  border-color: #7090c0;
  color: #1a2e5a;
  cursor: text;
  text-align: right;
}
.df-num-box--edit:focus {
  border-color: #2b55b0;
  box-shadow: 0 0 0 2px rgba(43,85,176,0.18);
  outline: none;
}

/* Student profile ordering and new-entry cue */
.student-profile-sort-item {
  position: relative;
  transition: opacity 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.student-profile-sort-item.is-dragging {
  z-index: 2;
  opacity: 0.48;
  transform: scale(0.985);
}

.student-profile-sort-item.is-drag-over {
  box-shadow: 0 -2px 0 #2457d6;
}

.student-profile-drag-handle {
  touch-action: none;
}

body.student-profile-is-sorting {
  cursor: grabbing;
  user-select: none;
}

[data-student-sort-list].is-saving {
  pointer-events: none;
  opacity: 0.65;
}

@keyframes student-profile-entry-attention {
  0%, 100% {
    background-color: #fff;
    box-shadow: inset 0 0 0 0 rgba(36, 87, 214, 0);
  }
  25%, 70% {
    background-color: #f3f7ff;
    box-shadow: inset 0 0 0 4px rgba(36, 87, 214, 0.3);
  }
}

.student-profile-entry-attention {
  animation: student-profile-entry-attention 1.7s ease-in-out;
}

/* DENT-180: wide screens place the activity catalog at the left and the
   fiscal calendar at the right.  Each age group has one card-width column
   whose cards stack vertically; the calendar deliberately uses three months
   per row.  A single-column mobile layout preserves the same reading order. */
.unit-planner-workspace {
  display: grid;
  /* Four explicit equal tracks are more reliable than two proportional
     tracks: the catalog occupies one, while the calendar spans the other
     three.  A card therefore always has one track's usable width. */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  gap: 1rem;
  min-width: 0;
}

.activity-catalog-frame,
.fiscal-month-frame {
  display: flex;
  flex-direction: column;
  height: min(72rem, calc(100dvh - 8rem));
  min-width: 0;
}

.activity-catalog-frame {
  grid-column: span 1;
}

.fiscal-month-frame {
  grid-column: span 3;
}

.activity-catalog-scroll,
.fiscal-month-scroll {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #cbd5e1;
  border-radius: 1rem;
  background: #f1f5f9;
  padding: 0.5rem;
}

.activity-catalog-scroll {
  max-height: min(72rem, calc(100dvh - 8rem));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
}

.activity-catalog-track {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.activity-catalog-column {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  border: 1px solid #cbd5e1;
  border-radius: 1rem;
  background: #fff;
}

.activity-catalog-column-heading {
  flex: 0 0 auto;
  min-height: 96px;
}

.activity-catalog-column-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.625rem;
}

.activity-catalog-card {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  width: 100%;
  height: auto;
  min-height: 0;
}

.activity-catalog-card[draggable="true"] {
  cursor: pointer;
}

.activity-catalog-card[draggable="true"]:active {
  cursor: pointer;
}

/* The coloured title panel is a deliberate drag surface, while controls and
   the native details summary retain their normal click/tap semantics. */
.activity-catalog-card-drag-handle[draggable="true"] {
  cursor: pointer;
  user-select: none;
  touch-action: none;
}

.activity-catalog-card-drag-handle[draggable="true"]:active {
  cursor: pointer;
}

.activity-catalog-card > :first-child,
.activity-catalog-card > :last-child {
  flex: 0 0 auto;
}

.activity-catalog-card-details {
  display: block;
}

.activity-catalog-card-footer {
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.activity-catalog-card-details > summary {
  list-style: none;
}

.activity-catalog-card-details > summary::-webkit-details-marker {
  display: none;
}

.activity-catalog-card-details[open] > summary .material-symbols-outlined {
  transform: rotate(180deg);
}

.activity-catalog-card-detail-list {
  max-height: 18rem;
}

.activity-catalog-empty {
  flex: 0 0 auto;
}

.fiscal-month-scroll {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
}

.fiscal-month-track {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 0.75rem;
  min-width: 0;
}

.month-bucket {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  background: rgb(248 250 252 / 0.78);
  /* Match the catalog's card-area inset so a placed card keeps its usable width. */
  padding: 0.625rem;
}

.month-bucket-items {
  min-height: 11rem;
}

/* A temporary drag target must not reflow the planner beneath the pointer. */
.planner-month-drop-rail {
  position: fixed;
  z-index: 90;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 50%;
  box-sizing: border-box;
  width: min(80rem, calc(100vw - 1.5rem));
  max-width: calc(100vw - 1.5rem);
  transform: translateX(-50%);
  overscroll-behavior-x: contain;
}

/* Native calendar dialogs must not depend on UA positioning after resets. */
.planner-native-dialog[open] {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: min(28rem, calc(100vw - 1rem));
  max-width: calc(100vw - 1rem);
  max-height: calc(100dvh - 1rem);
  margin: auto;
}

@media (max-width: 1023px) {
  .unit-planner-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .activity-catalog-frame,
  .fiscal-month-frame {
    grid-column: span 1;
  }

  .activity-catalog-frame,
  .fiscal-month-frame {
    height: auto;
  }

  .activity-catalog-scroll {
    flex: 0 0 auto;
    max-height: none;
    overflow: visible;
    scrollbar-gutter: auto;
  }

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

@media (max-width: 639px) {
  .fiscal-month-track {
    grid-template-columns: minmax(0, 1fr);
  }

  .activity-catalog-card-footer > .flex {
    width: 100%;
    justify-content: flex-end;
  }
}

@media (prefers-reduced-motion: reduce) {
  .student-profile-entry-attention {
    animation: none;
    background-color: #f3f7ff;
    box-shadow: inset 0 0 0 3px rgba(36, 87, 214, 0.25);
  }
}
