/* ================================================================
   Sustainability Intelligence — Emissions Record (Tool 2)
   Same dark theme as Tool 1 + emissions-specific styles
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,400&display=swap');

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --border: #334155;
    --border-light: #475569;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --accent-glow-strong: rgba(59, 130, 246, 0.3);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --scope1-color: #ef4444;
    --scope2-color: #f59e0b;
    --scope3-color: #3b82f6;
    --opp-green: #22c55e;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --transition: 0.2s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* --- Layout --- */
.app-container {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 20px 80px;
    min-height: 100vh;
}

/* --- Header --- */
.app-header { text-align: center; padding: 48px 0 40px; }

.app-header h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #f8fafc 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
}

.app-header .subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 520px;
    margin: 0 auto;
    line-height: 1.7;
}

/* --- Progress bar --- */
.progress-dots { margin-bottom: 32px; padding: 0 4px; }

.progress-track {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease;
    width: 0%;
}

.progress-label {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
}

/* --- Questions (one at a time) --- */
.question {
    display: none;
    animation: fadeIn 0.35s ease;
    max-width: 600px;
    margin: 0 auto;
}

.question.active { display: block; }

.question-label {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}

.question-hint {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

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

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.info-card {
    background: var(--bg-primary);
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* --- Form elements --- */
.field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    margin-top: 16px;
    letter-spacing: 0.3px;
}

.field-label:first-child { margin-top: 0; }

.required { color: var(--scope1-color); }

.text-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.text-input::placeholder { color: var(--text-muted); }
.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

input[type="number"].text-input {
    -moz-appearance: textfield;
}
input[type="number"].text-input::-webkit-inner-spin-button,
input[type="number"].text-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: vertical;
    min-height: 72px;
    transition: var(--transition);
}

textarea::placeholder { color: var(--text-muted); }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 28px var(--accent-glow-strong);
    transform: translateY(-1px);
}

.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border-light); }

.btn-small { padding: 6px 14px; font-size: 13px; }

.back-btn {
    margin-bottom: 16px;
    padding: 6px 12px;
    font-size: 13px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    font-family: inherit;
}

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

/* --- Radio pills --- */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.radio-pill {
    display: inline-flex;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.radio-pill:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.radio-pill.selected,
.radio-pill:has(input:checked) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 0 20px var(--accent-glow);
}

.radio-pill input { display: none; }

/* --- Auth bar --- */
.auth-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 8px 0;
    font-size: 13px;
}

.auth-email { color: var(--text-muted); }
.auth-badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.badge-active { background: rgba(34,197,94,0.15); color: #22c55e; }
.badge-trial { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-expired { background: rgba(239,68,68,0.15); color: #ef4444; }
.auth-signout { color: var(--text-muted); text-decoration: none; }
.auth-signout:hover { color: var(--text-primary); }
.auth-signin-link { color: var(--accent); text-decoration: none; }

/* --- Repeatable list --- */
.repeatable-list { display: flex; flex-direction: column; gap: 6px; }

.repeatable-item {
    display: flex;
    gap: 8px;
    align-items: center;
}

.repeatable-item input { flex: 1; }

.remove-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
}

.remove-btn:hover { color: var(--scope1-color); }

/* --- Text helpers --- */
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

/* ================================================================
   DASHBOARD
   ================================================================ */

.dashboard-period-header { margin-bottom: 24px; }
.dashboard-period-header h2 { font-size: 20px; font-weight: 700; }

.dash-progress-card { text-align: center; }
.dash-progress-text { font-size: 14px; color: var(--text-secondary); }

/* Scope cards */
.scope-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.scope-card {
    text-align: center;
    padding: 20px 12px;
}

.scope-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.scope1-card .scope-label { color: var(--scope1-color); }
.scope2-card .scope-label { color: var(--scope2-color); }
.scope3-card .scope-label { color: var(--scope3-color); }
.total-card .scope-label { color: var(--opp-green); }

.scope-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.scope-unit {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Checklist */
.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.checklist-item:last-child { border-bottom: none; }

.checklist-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.checklist-icon.done {
    background: rgba(34,197,94,0.15);
    color: #22c55e;
}

.checklist-icon.na {
    background: rgba(100,116,139,0.15);
    color: var(--text-muted);
}

.checklist-icon.pending {
    background: rgba(248,250,252,0.05);
    color: var(--text-muted);
    border: 1px dashed var(--border-light);
}

.checklist-name { flex: 1; }
.checklist-value { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Dashboard actions */
.dash-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 24px;
}

/* ================================================================
   EMISSIONS TABLE (per-category entry form)
   ================================================================ */

.emissions-table-wrap {
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.emissions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 700px;
}

.emissions-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 10px 8px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.emissions-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.emissions-table input[type="number"],
.emissions-table input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    min-width: 60px;
}

.emissions-table input:focus {
    border-color: var(--accent);
}

.emissions-table .source-col { min-width: 150px; }
.emissions-table .unit-col { min-width: 80px; }
.emissions-table .gas-col { min-width: 70px; }
.emissions-table .total-col {
    font-weight: 700;
    background: rgba(59,130,246,0.05);
    min-width: 80px;
}

.emissions-table .row-total {
    text-align: right;
    padding-right: 12px;
    font-variant-numeric: tabular-nums;
}

/* Category detail panel */
.category-detail {
    margin: 12px 0;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.category-detail summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.category-detail ul {
    margin: 12px 0 0 20px;
    list-style: disc;
}

.category-detail li { margin-bottom: 4px; }

/* Calculator link */
.calculator-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(59,130,246,0.08);
    border: 1px solid rgba(59,130,246,0.2);
    border-radius: var(--radius);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    margin: 12px 0;
    transition: var(--transition);
}

.calculator-link:hover {
    background: rgba(59,130,246,0.15);
    border-color: var(--accent);
}

/* NA reason box */
.na-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.na-hint {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 8px;
}

/* ================================================================
   MODAL
   ================================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

/* ================================================================
   LOADING
   ================================================================ */

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

/* ================================================================
   FOOTER
   ================================================================ */

.app-footer {
    margin-top: 60px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.app-footer .links {
    text-align: center;
    margin-bottom: 12px;
}

.app-footer .links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
    margin: 0 6px;
}

.app-footer .links a:hover { color: var(--text-primary); }

.app-footer .copyright {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Gas breakdown --- */
.gas-breakdown {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 16px;
    margin-top: 12px;
}

.gas-breakdown summary {
    padding: 12px 0;
}

.gas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.gas-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gas-row label {
    font-size: 12px;
    color: var(--text-muted);
}

.gas-row input {
    max-width: 140px;
}

@media (max-width: 640px) {
    .gas-grid { grid-template-columns: 1fr; }
}

/* --- Running total --- */
.running-total {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.running-total-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.running-total-row strong {
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* --- Guide content --- */
.guide-content {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.guide-content h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 28px 0 12px;
}

.guide-content p { margin-bottom: 14px; }

.guide-content ul, .guide-content ol {
    margin: 0 0 14px 24px;
}

.guide-content li { margin-bottom: 6px; }

.guide-content a {
    color: var(--accent);
    text-decoration: none;
}

.guide-content a:hover { text-decoration: underline; }

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

/* --- TOC --- */
.toc-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.toc-item:last-child { border-bottom: none; }

.toc-item:hover { padding-left: 8px; }

.toc-number {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 32px;
    text-align: center;
}

.toc-title {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.toc-status {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* ================================================================
   COOKIE BANNER
   ================================================================ */

.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 16px 20px;
    z-index: 2000;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
}

.cookie-content {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.cookie-content p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
}

.cookie-content a {
    color: var(--accent);
    text-decoration: none;
}

.cookie-content a:hover {
    text-decoration: underline;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

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

    .app-header h1 { font-size: 22px; }
    .app-container { padding: 16px 16px 60px; }

    .dash-actions {
        flex-direction: column;
    }

    .dash-actions .btn {
        width: 100%;
    }

    .emissions-table-wrap {
        margin-left: -16px;
        margin-right: -16px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}
