*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --accent: #3b6bff; --accent-dark: #2a50d6; --accent-light: #5a84ff;
  --black: #0a0a0a; --dark: #111318; --text: #1a1d27; --muted: #6b7280;
  --border: #e5e7eb; --white: #fff; --off-white: #f5f6fa; --success: #10b981;
  --warning: #f59e0b; --danger: #ef4444; --radius: 12px; --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08); --nav-width: 256px;
}
html, body { height: 100%; font-family: 'Inter', -apple-system, sans-serif; color: var(--text); background: var(--off-white); -webkit-font-smoothing: antialiased; }

/* AUTH */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0d1117 0%, #111827 60%, #1a1f3a 100%); padding: 24px; }
.auth-container { width: 100%; max-width: 560px; }
.auth-brand { text-align: center; margin-bottom: 32px; }
.logo-link { font-size: 28px; font-weight: 800; color: var(--accent-light); text-decoration: none; }
.auth-brand p { color: rgba(255,255,255,0.5); font-size: 14px; margin-top: 4px; }
.auth-card { background: var(--white); border-radius: 16px; padding: 36px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.auth-card h2 { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  padding: 11px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; outline: none; background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,107,255,0.12);
}
.form-group input:disabled { background: var(--off-white); color: var(--muted); cursor: not-allowed; }
.form-group textarea { resize: vertical; }
.form-error { color: var(--danger); font-size: 13px; padding: 10px 14px; background: rgba(239,68,68,0.08); border-radius: var(--radius-sm); display: none; }
.form-error.visible { display: block; }
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); margin-top: 16px; }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }
.muted-link { color: var(--muted) !important; font-weight: 400 !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 11px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; border: 2px solid transparent; transition: all 0.15s; white-space: nowrap; font-family: inherit; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--off-white); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-block { display: block; width: 100%; text-align: center; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* PORTAL LAYOUT */
#portalApp { display: flex; height: 100vh; overflow: hidden; }
.portal-nav { width: var(--nav-width); background: var(--dark); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; transition: transform 0.25s; z-index: 200; }
.portal-nav-top { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 8px; }
.portal-logo { font-size: 22px; font-weight: 800; color: var(--accent-light); text-decoration: none; }
.nav-close-btn { display: none; background: none; border: none; color: rgba(255,255,255,0.6); font-size: 18px; cursor: pointer; }
.portal-user-info { padding: 12px 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.portal-user-info .user-name { font-size: 14px; font-weight: 600; color: #fff; }
.portal-user-info .user-company { font-size: 12px; color: rgba(255,255,255,0.45); margin-top: 2px; }
.portal-user-info .user-package { display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 100px; background: rgba(59,107,255,0.25); color: var(--accent-light); }
.portal-nav-links { flex: 1; padding: 16px 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 11px 20px; color: rgba(255,255,255,0.55); font-size: 14px; font-weight: 500; text-decoration: none; border-radius: 0; transition: color 0.15s, background 0.15s; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.05); }
.nav-link.active { color: #fff; background: rgba(59,107,255,0.2); border-right: 3px solid var(--accent); }
.nav-icon { font-size: 16px; width: 20px; flex-shrink: 0; }
.portal-nav-bottom { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08); }
.logout-btn { background: none; border: 1px solid rgba(255,255,255,0.15); color: rgba(255,255,255,0.5); padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; width: 100%; transition: all 0.15s; font-family: inherit; }
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

.portal-main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.portal-topbar { display: flex; align-items: center; gap: 16px; padding: 14px 24px; background: var(--white); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.hamburger-btn { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); }
.topbar-title { font-weight: 700; font-size: 16px; flex: 1; }
.topbar-right { font-size: 13px; color: var(--muted); }

.portal-view { padding: 28px 28px 64px; flex: 1; }
.view-header { margin-bottom: 28px; }
.view-header h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.view-subtitle { color: var(--muted); font-size: 15px; margin-top: 4px; }

/* DASHBOARD */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 32px; font-weight: 800; color: var(--text); margin: 4px 0; letter-spacing: -1px; }
.stat-sub { font-size: 12px; color: var(--muted); }
.dash-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dash-card { background: var(--white); border-radius: var(--radius); padding: 24px; border: 1px solid var(--border); }
.dash-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.progress-bar-wrap { background: var(--off-white); border-radius: 100px; height: 10px; margin-bottom: 10px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-light)); border-radius: 100px; transition: width 0.5s ease; }
#progressText { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

/* QUESTIONNAIRE */
.sections-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.section-card { background: var(--white); border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.section-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.section-card.completed { border-color: var(--success); }
.section-num { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.section-title-text { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.section-desc { font-size: 13px; color: var(--muted); line-height: 1.4; }
.section-status { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 12px; font-weight: 600; }
.section-status.done { color: var(--success); }
.section-status.pending { color: var(--muted); }

.q-form-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.q-back-btn { background: none; border: 1.5px solid var(--border); padding: 8px 16px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit; color: var(--text); transition: border-color 0.15s; }
.q-back-btn:hover { border-color: var(--accent); color: var(--accent); }
.q-form-title { font-size: 22px; font-weight: 800; }
.q-form-desc { color: var(--muted); font-size: 14px; margin-top: 2px; }
.q-form-card { background: var(--white); border-radius: var(--radius); padding: 28px; border: 1px solid var(--border); }
.q-questions { display: flex; flex-direction: column; gap: 20px; margin-bottom: 24px; }
.q-question label { font-size: 14px; font-weight: 600; display: block; margin-bottom: 8px; }
.q-question .q-hint { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.q-question input[type="text"], .q-question input[type="number"], .q-question select, .q-question textarea {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; outline: none; transition: border-color 0.15s;
}
.q-question input:focus, .q-question select:focus, .q-question textarea:focus { border-color: var(--accent); }
.q-question textarea { min-height: 90px; resize: vertical; }
.q-question .radio-group, .q-question .check-group { display: flex; flex-direction: column; gap: 8px; }
.q-question .radio-item, .q-question .check-item { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.q-question .radio-item input, .q-question .check-item input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.q-form-actions { display: flex; gap: 12px; justify-content: flex-end; }
.q-progress { font-size: 12px; color: var(--muted); margin-bottom: 20px; }

/* DOCUMENTS */
.upload-area { background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); padding: 24px; margin-bottom: 24px; }
.upload-box { border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px 24px; text-align: center; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.upload-box:hover, .upload-box.drag-over { border-color: var(--accent); background: rgba(59,107,255,0.04); }
.upload-icon { font-size: 32px; color: var(--accent); margin-bottom: 10px; }
.upload-box p { color: var(--muted); font-size: 14px; }
.upload-hint { font-size: 12px; margin-top: 4px; }
.upload-category-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.upload-category-row label { font-size: 13px; font-weight: 600; }
.upload-category-row select { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; outline: none; }
.upload-status { margin-top: 12px; font-size: 13px; }
.upload-status.success { color: var(--success); }
.upload-status.error { color: var(--danger); }

.docs-list { display: flex; flex-direction: column; gap: 10px; }
.doc-item { background: var(--white); border-radius: var(--radius-sm); padding: 14px 18px; border: 1px solid var(--border); display: flex; align-items: center; gap: 14px; }
.doc-icon { font-size: 24px; flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.doc-delete { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; padding: 4px; transition: color 0.15s; flex-shrink: 0; }
.doc-delete:hover { color: var(--danger); }
.doc-category { font-size: 11px; padding: 3px 10px; background: var(--off-white); border-radius: 100px; color: var(--muted); font-weight: 600; text-transform: capitalize; white-space: nowrap; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* REPORTS */
.report-card { background: var(--white); border-radius: var(--radius); padding: 24px; border: 1px solid var(--border); margin-bottom: 16px; display: flex; align-items: center; gap: 20px; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.report-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.report-icon { font-size: 32px; flex-shrink: 0; }
.report-info { flex: 1; }
.report-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.report-meta { font-size: 13px; color: var(--muted); }
.status-badge { display: inline-block; padding: 3px 12px; border-radius: 100px; font-size: 12px; font-weight: 700; }
.status-generating { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-ready { background: rgba(59,107,255,0.15); color: var(--accent); }
.status-delivered { background: rgba(16,185,129,0.15); color: var(--success); }
.status-failed { background: rgba(239,68,68,0.15); color: var(--danger); }
.report-pending { background: var(--white); border-radius: var(--radius); padding: 40px 24px; border: 1px solid var(--border); text-align: center; }
.report-pending-icon { font-size: 40px; margin-bottom: 12px; }
.report-detail-back { margin-bottom: 20px; }
.report-content { background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.report-content-header { background: linear-gradient(135deg, var(--dark) 0%, #1a1f3a 100%); padding: 32px; color: #fff; }
.report-content-header h2 { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.report-content-header p { color: rgba(255,255,255,0.6); font-size: 14px; }
.report-disclaimer { margin: 20px 24px; padding: 14px 16px; background: rgba(245,158,11,0.08); border-left: 3px solid var(--warning); border-radius: 4px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.report-section { padding: 24px; border-bottom: 1px solid var(--border); }
.report-section:last-child { border-bottom: none; }
.report-section h3 { font-size: 17px; font-weight: 700; margin-bottom: 12px; color: var(--accent); }
.report-section-body { font-size: 14px; line-height: 1.7; color: var(--text); white-space: pre-wrap; }
.report-actions-card { margin: 0; border-bottom: 1px solid var(--border); }
.report-action-item { display: flex; align-items: center; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.report-action-item:last-child { border-bottom: none; }
.report-action-icon { font-size: 28px; flex-shrink: 0; width: 44px; text-align: center; }
.report-action-body { flex: 1; }
.report-action-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.report-action-desc { font-size: 13px; color: var(--muted); line-height: 1.4; }
.report-action-btn { flex-shrink: 0; min-width: 100px; text-align: center; text-decoration: none; }
.rating-row { display: flex; gap: 8px; margin-top: 8px; }
.rating-btn { background: none; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 6px 12px; cursor: pointer; font-size: 16px; transition: all 0.15s; }
.rating-btn:hover { border-color: var(--accent); }
.rating-btn.active { border-color: var(--accent); background: rgba(59,107,255,0.1); }

/* PROFILE */
.profile-card { background: var(--white); border-radius: var(--radius); padding: 32px; border: 1px solid var(--border); max-width: 600px; }
.profile-success { color: var(--success); font-size: 13px; padding: 10px 14px; background: rgba(16,185,129,0.1); border-radius: var(--radius-sm); margin-bottom: 12px; }

/* STATUS WIDGET */
.report-status-pending { display: flex; flex-direction: column; gap: 8px; }
.report-status-pending p { font-size: 13px; color: var(--muted); }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* NAV OVERLAY */
.nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 190; }
.nav-overlay.visible { display: block; }

/* RESPONSIVE */
@media (max-width: 768px) {
  .portal-nav { position: fixed; top: 0; left: 0; height: 100vh; transform: translateX(-100%); }
  .portal-nav.open { transform: translateX(0); }
  .nav-close-btn { display: block; }
  .hamburger-btn { display: block; }
  .dash-sections { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .portal-view { padding: 20px 16px 64px; }
  .upload-category-row { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .auth-card { padding: 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
