a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 7px; padding: 8px 13px; border: 1px solid transparent; border-radius: 7px; font-size: 12px; font-weight: 700; line-height: 1.25; text-decoration: none; }
.button.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.button.button-primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.button.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); color: #fff; }
.button.secondary { border-color: #b8c6d4; background: var(--surface); color: var(--primary); }
.button.button-secondary { border-color: #b8c6d4; background: var(--surface); color: var(--primary); }
.button.secondary:hover { border-color: var(--primary); background: #eef5fb; }
.button.danger { border-color: #d8a7a3; background: var(--surface); color: var(--danger); }
.button.button-danger { border-color: #d8a7a3; background: var(--surface); color: var(--danger); }
.button.text { min-height: 34px; padding: 5px 7px; border-color: transparent; background: transparent; color: var(--primary); }
.button:disabled, .button.disabled { cursor: not-allowed; border-color: #d5dde5; background: #eef1f4; color: #7b8795; opacity: .72; }
.button-group { display: flex; flex-wrap: wrap; gap: 8px; }

.page-header { margin-bottom: 12px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 0 0 10px; color: var(--muted); font-size: 10px; }
.breadcrumbs a { text-decoration: none; }
.page-header-row { display: flex; align-items: center; gap: 14px; }
.page-icon { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 8px; background: #eaf1f7; color: var(--primary); font-size: 19px; font-weight: 800; }
.page-heading { min-width: 0; margin-right: auto; }
.page-heading h1 { margin: 0; color: var(--text-strong); font-size: 20px; line-height: 1.25; }
.page-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panel-body { padding: 15px; }
.panel + .panel { margin-top: 12px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 15px 11px; }
.panel-heading.with-border { border-bottom: 1px solid var(--border); }
.panel-heading h2, .panel-heading h3 { margin: 0; color: var(--text-strong); font-size: 15px; }
.panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.section-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.section-heading .step-number { display: grid; width: 24px; height: 24px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--navy); color: #fff; font-size: 10px; font-weight: 800; }
.section-heading h3 { margin: 0; color: var(--text-strong); font-size: 14px; }
.section-heading small { margin-left: auto; color: var(--muted); font-size: 10px; }

.status-badge { display: inline-flex; min-height: 26px; max-width: 100%; align-items: center; gap: 6px; padding: 4px 9px; border: 1px solid #cad4de; border-radius: 999px; background: #f4f6f8; color: #526477; font-size: 10px; font-weight: 750; line-height: 1.25; }
.status-badge::before { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: currentColor; content: ""; }
.status-badge.success { border-color: #acd3b6; background: var(--success-bg); color: var(--success); }
.status-badge.warning { border-color: #e0c283; background: var(--warning-bg); color: var(--warning); }
.status-badge.danger { border-color: #e2aaa5; background: var(--danger-bg); color: var(--danger); }
.status-badge.info { border-color: #b9cee0; background: var(--info-bg); color: var(--info); }
.priority { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 750; }
.priority.overdue { color: var(--danger); }
.priority.today, .priority.soon { color: var(--warning); }

.field { min-width: 0; }
.field label, .check-field { display: block; margin-bottom: 5px; color: #34485d; font-size: 11px; font-weight: 700; }
.field > span:first-child { display: block; margin-bottom: 5px; color: #34485d; font-size: 11px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: 7px; background: #fff; color: var(--text); font-size: 12px; }
.field input, .field select { min-height: 40px; padding: 0 10px; }
.field textarea { min-height: 88px; padding: 9px 10px; resize: vertical; }
.field input[readonly], .field textarea[readonly], .field select:disabled { background: #f3f5f7; color: #536577; }
.field small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.field-error { display: block; margin-top: 4px; color: var(--danger); font-size: 10px; font-weight: 650; }
.required { color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field.wide { grid-column: 1 / -1; }
.form-grid + .button-group, .field + .button-group, .readiness-checklist + .button-group, .day180-checklist + .button-group { margin-top: 14px; }
.check-row { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 7px; background: #fff; }
.check-row:has(input:checked) { border-color: var(--primary); background: var(--surface-selected); }
.check-row input { margin-top: 3px; accent-color: var(--primary); }
.check-row span { font-size: 11.5px; line-height: 1.5; }
.radio-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.radio-card { position: relative; display: flex; min-height: 76px; align-items: flex-start; gap: 9px; padding: 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: #fff; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--surface-selected); box-shadow: inset 0 -3px var(--gold); }
.radio-card input { margin-top: 3px; accent-color: var(--primary); }
.radio-card strong, .radio-card small { display: block; }
.radio-card strong { color: var(--text-strong); font-size: 12px; }
.radio-card small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.inline-message { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0; padding: 9px 11px; border: 1px solid #b9cee0; border-radius: 7px; background: var(--info-bg); color: #345b7c; font-size: 11px; }
.inline-message.success { border-color: #a8d2b4; background: var(--success-bg); color: var(--success); }
.inline-message.warning { border-color: #dbc184; background: var(--warning-bg); color: #684b17; }
.inline-message.danger { border-color: #e1aaa6; background: var(--danger-bg); color: var(--danger); }
.validation-summary { margin: 10px 0; padding: 10px 12px; border: 1px solid #e1aaa6; border-radius: 7px; background: var(--danger-bg); color: var(--danger); font-size: 11px; }
.validation-summary strong { display: block; margin-bottom: 4px; }
.validation-summary ul { margin: 0; padding-left: 20px; }

.table-wrap { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.data-table { width: 100%; min-width: 980px; border-collapse: collapse; }
.data-table.compact { min-width: 760px; }
.data-table caption { text-align: left; }
.data-table th { position: sticky; z-index: 1; top: 0; padding: 9px 10px; border-block: 1px solid var(--border); background: var(--surface-muted); color: #4e6074; font-size: 10px; font-weight: 800; text-align: left; white-space: nowrap; }
.data-table td { padding: 11px 10px; border-bottom: 1px solid #e8edf2; color: #33475c; font-size: 11px; line-height: 1.45; vertical-align: top; }
.data-table tbody tr:hover { background: #f7fafc; }
.data-table td strong, .data-table td small { display: block; }
.data-table td strong { color: var(--text-strong); font-size: 12px; }
.data-table td small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-link { font-size: 11px; font-weight: 750; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 15px; color: var(--muted); font-size: 11px; }
.pagination div { display: flex; gap: 7px; }
.pagination button { min-height: 34px; padding: 5px 10px; border: 1px solid #cbd5df; border-radius: 6px; background: #fff; color: var(--primary); }

.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; color: var(--muted); font-size: 10px; }
.filter-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border: 1px solid #b9cee0; border-radius: 999px; background: #f2f7fb; color: var(--primary); }
.tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--border); background: var(--surface-muted); scrollbar-width: thin; }
.tabs button, .tabs a { position: relative; display: inline-flex; min-height: 44px; flex: 0 0 auto; align-items: center; gap: 6px; padding: 8px 13px; border: 0; background: transparent; color: #586a7d; font-size: 11px; font-weight: 700; text-decoration: none; }
.tabs button[aria-selected="true"], .tabs a[aria-current="page"] { color: var(--text-strong); }
.tabs button[aria-selected="true"]::after, .tabs a[aria-current="page"]::after { position: absolute; right: 0; bottom: 0; left: 0; height: 3px; background: var(--gold); content: ""; }
.tabs .count { display: inline-grid; min-width: 20px; height: 20px; place-items: center; border-radius: 10px; background: #e7edf3; font-size: 9px; }

.timeline { position: relative; display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.timeline::before { position: absolute; top: 13px; bottom: 13px; left: 7px; width: 1px; background: #c8d4df; content: ""; }
.timeline li { position: relative; display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; padding: 0 0 13px; }
.timeline-marker { z-index: 1; width: 15px; height: 15px; margin-top: 3px; border: 3px solid #fdfefe; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 1px #91abc1; }
.timeline-content { min-width: 0; }
.timeline-content strong, .timeline-content small, .timeline-content time { display: block; }
.timeline-content strong { color: var(--text-strong); font-size: 11px; }
.timeline-content p { margin: 2px 0; color: #465b70; font-size: 10px; }
.timeline-content time, .timeline-content small { color: var(--muted); font-size: 9px; }

.document-list { display: grid; gap: 7px; }
.document-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 90px 100px auto; align-items: center; gap: 9px; padding: 9px 10px; border-bottom: 1px solid #e4eaf0; }
.document-row:last-child { border-bottom: 0; }
.document-row strong, .document-row small { display: block; }
.document-row strong { color: var(--text-strong); font-size: 11px; }
.document-row small { color: var(--muted); font-size: 9px; }
.document-paper { width: min(100%, 760px); min-height: 820px; margin: 0 auto; padding: 54px 58px; border: 1px solid #ccd4dc; background: #fff; color: #18283a; box-shadow: 0 3px 10px rgba(13, 27, 62, .08); font-family: "Sarabun", Tahoma, sans-serif; }
.document-paper .demo-watermark { padding: 5px 8px; border: 1px solid #dbc184; background: var(--gold-soft); color: #6c4c12; font-size: 10px; text-align: center; }
.document-paper h2 { margin: 28px 0 18px; font-size: 18px; text-align: center; }
.document-paper p { margin: 8px 0; font-size: 12px; line-height: 1.8; }
.document-paper .doc-meta { display: grid; grid-template-columns: 90px 1fr; gap: 5px 10px; font-size: 11px; }
.document-paper .signature { width: 280px; margin: 70px 20px 0 auto; text-align: center; }
.document-demo { padding: 5px 8px; border: 1px solid #dbc184; background: var(--gold-soft); color: #6c4c12; font-size: 10px; text-align: center; }
.document-header { display: flex; align-items: center; gap: 14px; margin-top: 24px; text-align: left; }
.document-header img { width: 58px; height: 58px; border-radius: 50%; }
.document-header div, .document-header strong, .document-header span { display: block; }
.document-header strong { font-size: 14px; }
.document-header span { color: var(--muted); font-size: 10px; }
.document-meta { display: flex; justify-content: space-between; gap: 20px; margin-top: 28px; font-size: 11px; }
.document-paper .indent { text-indent: 2.5em; }
.document-table { width: 100%; margin: 20px 0; border-collapse: collapse; }
.document-table th, .document-table td { padding: 7px; border: 1px solid #adb7c1; font-size: 10px; text-align: left; }
.document-table th { width: 18%; background: #f3f5f7; }
.document-attachments { margin-top: 20px; font-size: 11px; }
.document-signature { display: grid; width: 280px; gap: 26px; margin: 70px 12px 40px auto; text-align: center; }
.document-signature strong, .document-signature span { display: block; }
.document-paper footer { display: flex; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid #ccd4dc; color: var(--muted); font-size: 9px; }
.document-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.popover-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.popover-title strong { color: var(--text-strong); font-size: 12px; }
.popover-title small, .muted { color: var(--muted); font-size: 10px; }
.kv-list { display: grid; gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: var(--border); }
.kv-list > div { display: grid; grid-template-columns: minmax(100px, .8fr) minmax(140px, 1.2fr); gap: 10px; padding: 8px 9px; background: #fff; }
.kv-list span { color: var(--muted); font-size: 9px; }
.kv-list strong { color: var(--text-strong); font-size: 10px; text-align: right; }
.attempt-section + .attempt-section { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--border); }
.attempt-section h3 { color: var(--text-strong); font-size: 12px; }

.drawer { position: fixed; z-index: 1800; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); overflow-y: auto; border-left: 1px solid #cbd5df; background: #fdfefe; box-shadow: -14px 0 36px rgba(13, 27, 62, .2); }
.drawer-header { position: sticky; z-index: 2; top: 0; display: flex; align-items: flex-start; gap: 12px; padding: 15px 17px; border-bottom: 1px solid var(--border); background: #f7f9fb; }
.drawer-header div { margin-right: auto; }
.drawer-header h2 { margin: 0; color: var(--text-strong); font-size: 16px; }
.drawer-header p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.drawer-body { padding: 16px; }

.skeleton-state { display: grid; gap: 10px; padding: 18px; }
.skeleton { height: 16px; border-radius: 5px; background: #e7ecf1; animation: pulse 1.2s ease-in-out infinite alternate; }
.skeleton:nth-child(2) { width: 82%; }
.skeleton:nth-child(3) { width: 62%; }
@keyframes pulse { to { opacity: .45; } }
.empty-state, .error-state { display: grid; min-height: 220px; place-items: center; align-content: center; gap: 8px; padding: 28px; text-align: center; }
.empty-state strong, .error-state strong { color: var(--text-strong); font-size: 15px; }
.empty-state p, .error-state p { max-width: 60ch; margin: 0; color: var(--muted); font-size: 11px; }
.error-state { color: var(--danger); }

.toast-region { position: fixed; z-index: 2600; right: 18px; bottom: 20px; display: grid; width: min(390px, calc(100vw - 28px)); gap: 8px; }
.toast { padding: 11px 13px; border: 1px solid #a8d2b4; border-radius: 8px; background: #f3fbf5; color: var(--success); box-shadow: var(--shadow-md); font-size: 11px; }
.toast.info { border-color: #b7c8de; background: #f0f4fa; color: var(--primary); }
.toast strong { display: block; margin-bottom: 2px; }
.toast.error { border-color: #e1aaa6; background: var(--danger-bg); color: var(--danger); }

.sticky-action-bar { position: fixed; z-index: 900; right: 0; bottom: 0; left: var(--sidebar-width); display: flex; min-height: 68px; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 22px; border-top: 1px solid #ccd6e0; background: rgba(253, 254, 254, .98); box-shadow: 0 -5px 18px rgba(13, 27, 62, .08); }
.sticky-action-bar .impact { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.sticky-action-bar .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.notification-item { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 9px; padding: 12px 14px; border-bottom: 1px solid #e3e9ef; text-decoration: none; }
.notification-item:hover { background: #f5f8fb; }
.notification-item .notification-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 7px; background: #e8eef5; color: var(--primary); }
.notification-item strong, .notification-item small { display: block; }
.notification-item strong { color: var(--text-strong); font-size: 11px; }
.notification-item p { margin: 2px 0; color: #465b70; font-size: 10px; }
.notification-item small { color: var(--muted); font-size: 9px; }
.notification-item.is-read { opacity: .55; }

@media (max-width: 980px) { .sticky-action-bar { left: 0; } }
@media (max-width: 760px) {
  .page-header-row { align-items: flex-start; flex-wrap: wrap; }
  .page-heading { flex: 1; }
  .page-actions { width: 100%; justify-content: flex-start; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .radio-cards { grid-template-columns: 1fr; }
  .document-paper { min-height: 720px; padding: 34px 24px; }
  .document-row { grid-template-columns: 1fr auto; }
  .document-row > :nth-child(2), .document-row > :nth-child(3) { display: none; }
}
@media (max-width: 560px) {
  .page-header { padding: 13px; }
  .page-icon { width: 36px; height: 36px; }
  .page-heading h1 { font-size: 17px; }
  .page-actions .button { flex: 1 1 auto; }
  .sticky-action-bar { align-items: stretch; flex-direction: column; padding: 8px 10px; }
  .sticky-action-bar .impact { display: none; }
  .sticky-action-bar .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky-action-bar .button:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media print {
  body.printing-document .app-shell > * { display: none !important; }
  body.printing-document #print-root { display: block !important; }
  .document-paper { width: 100%; min-height: 0; border: 0; box-shadow: none; }
}

[data-outcome-group] button.is-selected {
  outline: 3px solid var(--primary, #2563eb);
  outline-offset: 1px;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
[data-outcome-group] button.is-selected::after {
  content: " ✓";
}
