/* ════════════════════════════════════════════════════════════════════════
   TrueDocs Franchisee Portal v2
   ════════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

.td-portal-wrap {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #1f2937;
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* Loading / error */
.td-p-loading { text-align: center; padding: 80px 20px; color: #6b7280; }
.td-spinner { width: 40px; height: 40px; border: 3px solid #e5e7eb; border-top-color: #2563eb; border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.td-p-error { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; padding: 22px 28px; border-radius: 12px; font-size: 14px; }

/* Login */
.td-p-login { display: flex; justify-content: center; padding: 40px 0; }
.td-p-login-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 38px; width: 100%; max-width: 420px; box-shadow: 0 4px 24px rgba(0,0,0,.08); }
.td-p-login-card h2 { margin: 0 0 6px; font-size: 24px; color: #0f172a; letter-spacing: -0.02em; }
.td-p-login-card p { margin: 0 0 26px; color: #6b7280; font-size: 14px; }

/* Header */
.td-p-header { background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%); color: #fff; border-radius: 14px; padding: 24px 28px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.td-p-brand { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.td-p-greeting { font-size: 14px; opacity: 0.85; margin-top: 4px; }
.td-p-stage-pill { background: rgba(255,255,255,.18); padding: 5px 14px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .04em; }

/* Progress tracker */
.td-p-tracker { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 24px 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.04); overflow-x: auto; }
.td-p-tracker-inner { display: flex; align-items: center; gap: 8px; min-width: 600px; }
.td-p-tracker-step { flex: 1; text-align: center; position: relative; }
.td-p-tracker-step:not(:last-child)::after { content: ''; position: absolute; top: 14px; left: 60%; width: 80%; height: 2px; background: #e5e7eb; z-index: 0; }
.td-p-tracker-step.done:not(:last-child)::after { background: #22c55e; }
.td-p-tracker-dot { position: relative; z-index: 1; width: 30px; height: 30px; margin: 0 auto 6px; background: #f3f4f6; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #9ca3af; }
.td-p-tracker-step.active .td-p-tracker-dot { background: #2563eb; color: #fff; box-shadow: 0 0 0 4px rgba(37,99,235,.15); }
.td-p-tracker-step.done .td-p-tracker-dot { background: #22c55e; color: #fff; }
.td-p-tracker-label { font-size: 11px; font-weight: 600; color: #6b7280; }
.td-p-tracker-step.active .td-p-tracker-label { color: #2563eb; }
.td-p-tracker-step.done .td-p-tracker-label { color: #15803d; }

/* Tabs */
.td-p-tabs { display: flex; gap: 0; border-bottom: 1px solid #e5e7eb; margin-bottom: 24px; overflow-x: auto; }
.td-p-tab { background: none; border: none; padding: 12px 18px; font-size: 14px; font-weight: 600; cursor: pointer; color: #6b7280; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s; white-space: nowrap; }
.td-p-tab.active { color: #2563eb; border-bottom-color: #2563eb; }
.td-p-tab:hover:not(.active) { color: #1f2937; }
.td-p-panel {}

/* Welcome card + quick actions */
.td-p-welcome-card { background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); color: #fff; border-radius: 14px; padding: 26px 28px; margin-bottom: 20px; box-shadow: 0 4px 16px rgba(37,99,235,.2); }
.td-p-welcome-card h3 { margin: 0 0 6px; font-size: 20px; font-weight: 700; }
.td-p-welcome-card p { margin: 0; font-size: 14px; opacity: 0.92; line-height: 1.6; }
.td-p-quick-actions { display: grid; gap: 10px; margin-bottom: 20px; }
.td-p-qa { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 16px 18px; cursor: pointer; transition: all .15s; }
.td-p-qa:hover { box-shadow: 0 4px 12px rgba(0,0,0,.06); transform: translateY(-1px); border-color: #d1d5db; }
.td-p-qa-icon { font-size: 22px; flex-shrink: 0; }
.td-p-qa-label { font-size: 14px; font-weight: 600; color: #0f172a; }
.td-p-qa-sub { font-size: 12px; color: #6b7280; margin-top: 2px; }
.td-p-qa-arr { margin-left: auto; color: #9ca3af; font-size: 20px; }

/* Stats */
.td-p-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 600px) { .td-p-stats { grid-template-columns: 1fr; } }
.td-p-stat-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 16px; text-align: center; }
.td-p-stat-n { display: block; font-size: 28px; font-weight: 800; color: #0f172a; line-height: 1; }
.td-p-stat-l { display: block; font-size: 12px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; }

/* Sections + grid */
.td-p-section { margin-bottom: 28px; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 22px 24px; }
.td-p-section h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #6b7280; margin: 0 0 16px; padding-bottom: 10px; border-bottom: 1px solid #f3f4f6; }
.td-p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .td-p-grid { grid-template-columns: 1fr; } }

/* Fields */
.td-p-field { display: flex; flex-direction: column; gap: 6px; }
.td-p-field.td-full { grid-column: 1/-1; }
.td-p-field label { font-size: 13px; font-weight: 600; color: #374151; }
.td-p-field input, .td-p-field textarea, .td-p-field select {
  width: 100%; padding: 10px 14px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; color: #1f2937; transition: border .15s; font-family: inherit;
}
.td-p-field input:focus, .td-p-field textarea:focus, .td-p-field select:focus {
  outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.td-p-hint { font-size: 11px; color: #9ca3af; margin: 2px 0 0; }
.td-req { color: #ef4444; }
.td-field-err { border-color: #ef4444 !important; }
.td-p-field-err { background: #fef2f2; color: #b91c1c; border: 1px solid #fca5a5; padding: 10px 14px; border-radius: 8px; font-size: 13px; }

/* Submitted */
.td-p-submitted { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; padding: 14px 18px; margin-bottom: 20px; font-size: 14px; color: #15803d; }

/* Actions */
.td-p-actions { padding-top: 20px; display: flex; align-items: center; gap: 14px; }
.td-p-btn { display: inline-flex; align-items: center; gap: 8px; background: #2563eb; color: #fff; border: none; padding: 12px 28px; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer; transition: all .15s; }
.td-p-btn:hover { background: #1d4ed8; box-shadow: 0 4px 12px rgba(37,99,235,.25); }
.td-p-btn:disabled { background: #93c5fd; cursor: not-allowed; }
.td-p-btn-sm { padding: 7px 16px; font-size: 13px; border-radius: 6px; }
.td-btn-secondary { background: #fff; border: 1px solid #d1d5db; color: #374151; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.td-btn-secondary:hover { background: #f9fafb; }
.td-muted { color: #6b7280; font-size: 13px; }

/* Docs list */
.td-p-docs-list { display: flex; flex-direction: column; gap: 10px; }
.td-p-doc-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.td-p-doc-name { font-size: 14px; font-weight: 600; color: #0f172a; }
.td-p-doc-meta { font-size: 11px; color: #6b7280; margin-top: 2px; text-transform: capitalize; }

/* Required docs */
.td-p-required-list { margin-bottom: 24px; }
.td-p-req-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 6px; font-size: 14px; color: #374151; }
.td-p-req-item.done { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.td-p-req-icon { font-size: 16px; }

/* Upload */
.td-p-upload-card { background: #f9fafb; border: 2px dashed #d1d5db; border-radius: 12px; padding: 24px; margin-bottom: 24px; }
.td-p-upload-card h4 { margin: 0 0 16px; font-size: 15px; color: #0f172a; }
.td-p-upload-card .td-p-field { margin-bottom: 12px; }

/* File cards */
.td-p-files-list { display: flex; flex-direction: column; gap: 8px; }
.td-p-file-card { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px 16px; }
.td-p-file-icon { font-size: 24px; flex-shrink: 0; }
.td-p-file-info { flex: 1; min-width: 0; }
.td-p-file-name { font-size: 14px; font-weight: 600; color: #0f172a; }
.td-p-file-meta { font-size: 11px; color: #6b7280; margin-top: 2px; }
.td-p-status { font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 10px; text-transform: uppercase; letter-spacing: .03em; flex-shrink: 0; }
.td-p-status.approved { background: #dcfce7; color: #15803d; }
.td-p-status.pending  { background: #fef3c7; color: #92400e; }
.td-p-status.rejected { background: #fee2e2; color: #b91c1c; }
.td-p-notice { padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.td-p-notice.success { background: #dcfce7; color: #15803d; }
.td-p-notice.error   { background: #fef2f2; color: #b91c1c; }

/* Signature card */
.td-sign-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 32px; }
.td-sign-card h3 { margin: 0 0 6px; font-size: 20px; color: #0f172a; }
.td-sign-card p { color: #6b7280; margin: 0 0 22px; font-size: 14px; }
.td-sign-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
@media (max-width: 600px) { .td-sign-fields { grid-template-columns: 1fr; } }
.td-sign-pad-wrap { margin-bottom: 18px; }
.td-sign-pad-wrap label { font-size: 13px; font-weight: 600; color: #374151; display: block; margin-bottom: 10px; }
.td-sign-pad { width: 100%; height: 180px; border: 2px dashed #d1d5db; border-radius: 10px; background: #f9fafb; cursor: crosshair; display: block; touch-action: none; }
.td-sign-pad:hover { border-color: #2563eb; }
.td-sign-agree { margin: 18px 0; font-size: 14px; color: #374151; line-height: 1.6; }
.td-sign-agree label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.td-sign-agree input[type=checkbox] { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }

/* Success */
.td-p-success { display: flex; justify-content: center; padding: 60px 20px; }
.td-success-card { text-align: center; background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 52px 40px; max-width: 480px; width: 100%; box-shadow: 0 4px 24px rgba(0,0,0,.08); }
.td-success-icon { font-size: 64px; margin-bottom: 18px; }
.td-success-card h3 { font-size: 24px; font-weight: 700; color: #0f172a; margin: 0 0 12px; }
.td-success-card p { font-size: 15px; color: #6b7280; margin: 0 0 24px; line-height: 1.7; }
