/* ==========================================================================
   Summit IFP — Client Portal Styles
   Layers on top of the main site's style.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   Auth loading overlay
   -------------------------------------------------------------------------- */

.auth-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.94);
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Also support .auth-loading-spinner for any existing markup */
.auth-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.auth-loading-text {
  font-size: 0.875rem;
  color: var(--text-light);
}

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

/* --------------------------------------------------------------------------
   Login / Auth page
   -------------------------------------------------------------------------- */

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 72px);
  padding-top: 72px;
  padding-bottom: 48px;
  background: var(--bg-light);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: var(--shadow-lg);
  padding: 40px;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin: 0 0 8px;
}

.login-card .subtitle {
  font-size: 0.9375rem;
  color: var(--text-light);
  text-align: center;
  margin: 0 0 28px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-form .portal-form-group {
  gap: 0;
}

.login-form .portal-label {
  margin-bottom: 6px;
}

.password-wrapper {
  position: relative;
}

.password-wrapper input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-light);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:hover {
  color: var(--text);
}

.login-form .btn {
  width: 100%;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.login-form .btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.btn.loading .btn-spinner {
  display: inline-block;
}

.btn.loading .btn-text {
  opacity: 0.8;
}

.login-forgot {
  text-align: center;
  font-size: 0.875rem;
}

.login-forgot a {
  color: var(--primary);
  text-decoration: none;
}

.login-forgot a:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Portal-wide alerts
   -------------------------------------------------------------------------- */

.portal-alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
}

.portal-alert-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.portal-alert-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.portal-alert-info {
  background: var(--primary-light);
  border-color: #bfdbfe;
  color: #1e40af;
}

.portal-alert-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

/* --------------------------------------------------------------------------
   Form styles
   -------------------------------------------------------------------------- */

.portal-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.portal-form-section {
  padding: 28px 32px;
  border-bottom: 1px solid var(--border);
}

.portal-form-section:last-child {
  border-bottom: none;
}

.portal-form-section-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--bg-section);
}

.portal-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px 24px;
}

.portal-form-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.portal-form-grid.cols-1,
.portal-form-grid.single {
  grid-template-columns: 1fr;
}

.portal-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portal-form-group.full-width {
  grid-column: 1 / -1;
}

.portal-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0;
}

.portal-label .required {
  color: #dc2626;
  margin-left: 2px;
}

.portal-input,
.portal-select,
.portal-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9375rem;
  font-family: var(--font), Inter, sans-serif;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  box-sizing: border-box;
}

.portal-input:focus,
.portal-select:focus,
.portal-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

.portal-input::placeholder,
.portal-textarea::placeholder {
  color: #9ca3af;
}

.portal-input:disabled,
.portal-select:disabled,
.portal-textarea:disabled,
.portal-input[readonly] {
  background: var(--bg-section);
  color: var(--text-light);
  cursor: not-allowed;
}

.portal-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

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

.portal-hint {
  font-size: 0.8125rem;
  color: var(--text-light);
  margin-top: 3px;
}

.portal-field-error {
  font-size: 0.8125rem;
  color: #dc2626;
  margin-top: 3px;
}

.portal-input.error,
.portal-select.error,
.portal-textarea.error {
  border-color: #dc2626;
}

/* Checkbox group */
.portal-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.portal-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9375rem;
  color: var(--text);
  cursor: pointer;
  line-height: 1.45;
}

.portal-checkbox-label input[type="checkbox"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Radio group */
.portal-radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.portal-radio-label,
.portal-radio-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9375rem;
  color: var(--text);
  cursor: pointer;
  line-height: 1.45;
}

.portal-radio-label input[type="radio"],
.portal-radio-option input[type="radio"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
}

.portal-radio-group.inline,
.portal-checkbox-group.inline {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 16px;
}

/* Form actions footer */
.portal-form-actions {
  padding: 20px 32px;
  background: var(--bg-section);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* --------------------------------------------------------------------------
   Dashboard / Stats
   -------------------------------------------------------------------------- */

.portal-welcome {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: calc(var(--radius) * 1.5);
  padding: 32px 36px;
  color: var(--text-white);
  margin-bottom: 28px;
}

.portal-welcome h1,
.portal-welcome h2 {
  color: var(--text-white);
  margin: 0 0 6px;
}

.portal-welcome p {
  color: rgba(255, 255, 255, 0.82);
  margin: 0;
  font-size: 0.9375rem;
}

.portal-stats,
.portal-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.portal-stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}

.portal-stat-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

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

.portal-stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
  margin-bottom: 6px;
}

.portal-stat-label {
  font-size: 0.8rem;
  color: var(--text-light);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --------------------------------------------------------------------------
   Table styles
   -------------------------------------------------------------------------- */

.portal-table-wrapper,
.portal-table-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: var(--shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.portal-table thead {
  background: var(--bg-section);
}

.portal-table thead th,
.portal-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.portal-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

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

.portal-table tbody tr:hover {
  background: var(--primary-light);
}

.portal-table tbody td,
.portal-table td {
  padding: 13px 16px;
  color: var(--text);
  vertical-align: middle;
}

.portal-table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.portal-table-actions a,
.portal-table-actions button {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
}

.portal-table-actions a:hover,
.portal-table-actions button:hover {
  background: var(--bg-section);
  border-color: #d1d5db;
}

.portal-table-actions .action-edit {
  color: var(--primary);
  border-color: #bfdbfe;
  background: var(--primary-light);
}

.portal-table-actions .action-edit:hover {
  background: #dbeafe;
}

.portal-table-actions .action-delete {
  color: #dc2626;
  border-color: #fecaca;
  background: #fef2f2;
}

.portal-table-actions .action-delete:hover {
  background: #fee2e2;
}

/* Loading row */
.loading-row td {
  text-align: center;
  padding: 32px;
  color: var(--text-light);
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.portal-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.portal-badge-active {
  background: #d1fae5;
  color: #065f46;
}

.portal-badge-prospect {
  background: #fef3c7;
  color: #92400e;
}

.portal-badge-archived {
  background: #f3f4f6;
  color: #6b7280;
}

.portal-badge-pending,
.portal-badge-published {
  background: #dbeafe;
  color: #1e40af;
}

.portal-badge-draft {
  background: #f3f4f6;
  color: #374151;
}

/* --------------------------------------------------------------------------
   Workbook styles
   -------------------------------------------------------------------------- */

.workbook-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 28px;
  align-items: flex-start;
}

.workbook-nav {
  position: sticky;
  top: calc(72px + 24px);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.workbook-nav-header {
  padding: 16px 20px;
  background: var(--bg-section);
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.workbook-nav-items {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.workbook-nav-item {
  display: block;
}

.workbook-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  border-left: 3px solid transparent;
}

.workbook-nav-link:hover {
  background: var(--bg-light);
  color: var(--primary);
}

.workbook-nav-link.active {
  color: var(--primary);
  background: var(--primary-light);
  border-left-color: var(--primary);
  font-weight: 600;
}

.workbook-nav-link .nav-check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}

.workbook-nav-link.completed .nav-check {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}

.workbook-progress {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 24px;
}

.workbook-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.workbook-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-light);
  margin-bottom: 8px;
}

.workbook-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.workbook-section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  cursor: pointer;
  user-select: none;
  background: var(--bg);
  transition: background 0.12s;
  border-bottom: 1px solid transparent;
}

.workbook-section-header:hover {
  background: var(--bg-light);
}

.workbook-section.open .workbook-section-header {
  border-bottom-color: var(--border);
}

.workbook-section-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.8125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.workbook-section.complete .workbook-section-num {
  background: #dcfce7;
  color: #16a34a;
}

.workbook-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.workbook-section-chevron {
  color: var(--text-light);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.workbook-section.open .workbook-section-chevron {
  transform: rotate(180deg);
}

/* Also support Alpine.js x-show pattern */
.collapsible-chevron {
  transition: transform 0.2s;
}

.collapsible-chevron.open {
  transform: rotate(180deg);
}

.workbook-section-body {
  padding: 24px;
  display: none;
}

.workbook-section.open .workbook-section-body {
  display: block;
}

.workbook-dynamic-table,
.dynamic-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 0.875rem;
}

.workbook-dynamic-table th,
.dynamic-table th {
  background: var(--bg-section);
  padding: 9px 12px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.workbook-dynamic-table td,
.dynamic-table td {
  padding: 7px 8px;
  border: 1px solid var(--border);
  vertical-align: middle;
}

.workbook-dynamic-table td .portal-input,
.dynamic-table td input,
.dynamic-table td select {
  padding: 6px 10px;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  width: 100%;
  outline: none;
}

.dynamic-table td input:focus,
.dynamic-table td select:focus {
  border-color: var(--primary);
}

.row-remove,
.remove-btn,
.workbook-dynamic-table .row-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #dc2626;
  padding: 4px 6px;
  border-radius: var(--radius);
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
  font-size: 1rem;
}

.row-remove:hover,
.remove-btn:hover,
.workbook-dynamic-table .row-remove:hover {
  opacity: 1;
  background: #fee2e2;
}

.dynamic-table .col-remove { width: 36px; text-align: center; }

.workbook-add-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px dashed #93c5fd;
  border-radius: var(--radius);
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  font-family: inherit;
}

.workbook-add-row:hover {
  background: #dbeafe;
  border-color: var(--primary);
}

/* --------------------------------------------------------------------------
   Plan view styles
   -------------------------------------------------------------------------- */

.plan-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: var(--shadow);
  padding: 24px 28px;
  margin-bottom: 20px;
}

.plan-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.plan-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.plan-card-subtitle {
  font-size: 0.875rem;
  color: var(--text-light);
  margin: 4px 0 0;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px 24px;
}

.plan-data-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.plan-data-label {
  font-size: 0.8125rem;
  color: var(--text-light);
  font-weight: 500;
}

.plan-data-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* Progress bars */
.progress-bar {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  transition: width 0.5s ease;
}

.progress-fill.success { background: linear-gradient(90deg, #16a34a 0%, #22c55e 100%); }
.progress-fill.warning { background: linear-gradient(90deg, #d97706 0%, #f59e0b 100%); }
.progress-fill.danger  { background: linear-gradient(90deg, #dc2626 0%, #ef4444 100%); }

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-light);
}

/* Action items / checklist */
.action-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text);
  transition: background 0.12s;
}

.action-item .action-check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: background 0.15s, border-color 0.15s;
}

.action-item.completed {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.action-item.completed .action-check {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}

.action-item.completed .action-text {
  text-decoration: line-through;
  color: var(--text-light);
}

.action-item .action-due {
  margin-left: auto;
  font-size: 0.8125rem;
  color: var(--text-light);
  white-space: nowrap;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */

.portal-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}

.portal-tabs::-webkit-scrollbar {
  display: none;
}

.portal-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-light);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  text-decoration: none;
  border-radius: var(--radius) var(--radius) 0 0;
  font-family: inherit;
}

.portal-tab:hover {
  color: var(--primary);
  background: var(--bg-section);
}

.portal-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.portal-tab-content {
  display: none;
}

.portal-tab-content.active {
  display: block;
}

/* --------------------------------------------------------------------------
   Collapsible sections (generic pattern)
   -------------------------------------------------------------------------- */

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 2px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.12s;
  user-select: none;
}

.collapsible-header:hover {
  background: var(--primary-light);
}

.collapsible-body {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  font-size: 0.875rem;
  background: var(--bg);
}

/* --------------------------------------------------------------------------
   Portal layout / page structure
   -------------------------------------------------------------------------- */

.portal-page {
  padding-top: calc(72px + 32px);
  padding-bottom: 60px;
  min-height: 100vh;
  background: var(--bg-light);
}

.portal-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.portal-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.portal-section-title h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.portal-section-title .section-action {
  flex-shrink: 0;
}

.portal-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-light);
  text-decoration: none;
  margin-bottom: 16px;
  transition: color 0.15s;
}

.portal-back-link:hover {
  color: var(--primary);
}

.portal-back-link svg {
  transition: transform 0.15s;
}

.portal-back-link:hover svg {
  transform: translateX(-2px);
}

.portal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* Section headings (used inside cards) */
.section-heading,
.portal-form-section-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

/* --------------------------------------------------------------------------
   Client detail layout
   -------------------------------------------------------------------------- */

.client-detail-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: start;
}

.client-sidebar {
  position: sticky;
  top: calc(72px + 24px);
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-row-label {
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
}

.info-row-value {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Auth nav additions
   -------------------------------------------------------------------------- */

.nav-user {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-user-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.nav-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-logout {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-light);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.nav-logout:hover {
  background: var(--bg-section);
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Search bar
   -------------------------------------------------------------------------- */

.portal-search-wrap {
  position: relative;
  max-width: 380px;
}

.portal-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.portal-search-input {
  padding: 9px 12px 9px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  width: 100%;
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}

.portal-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

/* --------------------------------------------------------------------------
   Notes
   -------------------------------------------------------------------------- */

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.note-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.note-item-meta {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 6px;
}

.note-item-text {
  font-size: 0.875rem;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Workbook Q&A view
   -------------------------------------------------------------------------- */

.wb-qa {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wb-question {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 4px;
}

.wb-answer {
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 10px 14px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
}

.wb-answer.empty {
  color: var(--text-light);
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Confirm dialog
   -------------------------------------------------------------------------- */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}

.confirm-dialog {
  background: var(--bg);
  border-radius: calc(var(--radius) * 1.5);
  padding: 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.confirm-dialog h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.confirm-dialog p {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 20px;
}

.confirm-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */

.portal-empty-state,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 24px;
  color: var(--text-light);
}

.portal-empty-state .empty-icon,
.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-section);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: #9ca3af;
  font-size: 1.5rem;
  opacity: 0.7;
}

.portal-empty-state h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.portal-empty-state p,
.empty-state p {
  font-size: 0.9375rem;
  margin: 0 0 20px;
  max-width: 360px;
}

/* --------------------------------------------------------------------------
   Utility classes
   -------------------------------------------------------------------------- */

.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-light);
}

.text-primary {
  color: var(--primary);
}

.text-success {
  color: #16a34a;
}

.text-danger {
  color: #dc2626;
}

.font-semibold {
  font-weight: 600;
}

.font-mono {
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
}

/* --------------------------------------------------------------------------
   Responsive breakpoints
   -------------------------------------------------------------------------- */

@media (max-width: 1060px) {
  .workbook-layout {
    grid-template-columns: 220px 1fr;
  }

  .client-detail-layout {
    grid-template-columns: 260px 1fr;
  }
}

@media (max-width: 900px) {
  .client-detail-layout {
    grid-template-columns: 1fr;
  }

  .client-sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  .portal-form-grid,
  .portal-form-grid.cols-3 {
    grid-template-columns: 1fr;
  }

  .portal-form-section {
    padding: 20px;
  }

  .portal-form-actions {
    padding: 16px 20px;
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .portal-form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .workbook-layout {
    grid-template-columns: 1fr;
  }

  .workbook-nav {
    position: static;
  }

  .portal-welcome {
    padding: 24px;
  }

  .login-card {
    padding: 28px 24px;
  }

  .portal-container {
    padding: 0 16px;
  }

  .portal-page {
    padding-top: calc(72px + 20px);
  }

  .portal-section-title {
    flex-direction: column;
    align-items: flex-start;
  }

  .plan-grid {
    grid-template-columns: 1fr 1fr;
  }

  .nav-inner {
    padding: 0 16px;
  }
}

@media (max-width: 640px) {
  .portal-stats,
  .portal-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .plan-grid {
    grid-template-columns: 1fr;
  }

  .login-container {
    align-items: flex-start;
    padding-top: calc(72px + 16px);
  }
}

@media (max-width: 600px) {
  .portal-table-wrapper,
  .portal-table-wrap {
    border-radius: var(--radius);
  }

  .section {
    padding: 24px 0;
  }

  .container {
    padding: 0 16px;
  }
}
