/* ============================================
   CARBON CALCULATOR - PHASE 1 STYLES
   Modern Xero-style Interface with Dark Mode
   ============================================ */

:root {
    /* Light mode: ocean + slate palette */
    --primary-color: #0EA5E9;
    --primary-dark: #0369A1;
    --secondary-color: #64748B;
    --success-color: #16A34A;
    --danger-color: #DC2626;
    --warning-color: #F59E0B;

    --bg-main: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-sidebar: #0F172A;
    --bg-header: #FFFFFF;
    
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-light: #94A3B8;
    --text-sidebar: #FFFFFF;
    
    --border-color: #CBD5E1;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
    
    --login-gradient: linear-gradient(135deg, #0EA5E9 0%, #1D4ED8 100%);
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    /* Dynamic variables are handled by theme-palettes.js */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

/* ============================================
   GLOBAL STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

/* ============================================
   LOGIN SCREEN
   ============================================ */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--login-gradient);
    padding: 10px; /* Reduced from 20px */
}

.login-box {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 20px; /* Reduced from 30px to fit better in viewport */
    width: 100%;
    max-width: 420px;
    animation: fadeInUp 0.5s ease;
}

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

.login-header {
    text-align: center;
    margin-bottom: 12px; /* Reduced from 16px */
}

.login-header i {
    font-size: 32px; /* Reduced from 48px */
    color: var(--primary-color);
    margin-bottom: 8px; /* Reduced from 16px */
}

.login-header h1 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group {
    margin-bottom: 8px; /* Reduced from 12px */
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
    background: var(--bg-card);
    color: var(--text-primary);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(19, 181, 234, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
    opacity: 0.85;
    cursor: wait;
    transform: none;
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: var(--bg-main);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.error-message {
    color: var(--danger-color);
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
}

#loginError:not(:empty) {
    margin-bottom: 10px;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
}

.site-main-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    width: 100%;
}

.site-sub-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    padding: 0 0 10px 24px;
    background: rgba(0, 0, 0, 0.02);
}

.site-item.active .site-sub-nav {
    display: flex;
}

.sub-nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    text-align: left;
    padding: 8px 10px;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.sub-nav-btn i {
    width: 16px;
    text-align: center;
    font-size: 0.8rem;
}

.sub-nav-btn:hover {
    color: var(--primary-color);
    background: rgba(19, 181, 234, 0.05);
}

.sub-nav-btn.active {
    color: white;
    background: var(--primary-color);
    font-weight: 600;
}

/* Active building uses primary as row background — sub-nav must stay readable */
.site-item.active .sub-nav-btn {
    color: rgba(255, 255, 255, 0.92);
}

.site-item.active .sub-nav-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.14);
}

.site-item.active .sub-nav-btn.active {
    color: #ffffff;
    background: rgba(0, 0, 0, 0.28);
    font-weight: 600;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-link:hover {
    text-decoration: underline;
}

/* ============================================
   MAIN APPLICATION LAYOUT
   ============================================ */

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Header */
.top-header {
    background: var(--bg-header);
    border-bottom: 2px solid var(--border-color);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.company-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.company-logo i {
    color: var(--primary-color);
    font-size: 28px;
}

.header-center h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-palette-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-palette-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.header-palette-select {
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 118px;
    max-width: 170px;
}

.header-palette-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-icon {
    background: var(--bg-main);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-primary);
    font-size: 16px;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* Main Content Area */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    padding: 24px;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.sidebar-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid rgba(255,255,255,0.1);
}

.sidebar-header h3 {
    color: var(--text-sidebar);
    font-size: 16px;
    font-weight: 600;
}

.sidebar-top-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.sidebar-btn {
    flex: 1;
    padding: 10px 12px;
    border-radius: 8px;
    border: none;
    background: rgba(255,255,255,0.08);
    color: var(--text-sidebar);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    font-size: 14px;
    font-weight: 500;
}

.sidebar-btn:hover {
    background: var(--primary-color);
    color: #FFFFFF;
    transform: translateY(-2px);
}

.sidebar-btn i {
    font-size: 16px;
}

.sidebar-btn span {
    white-space: nowrap;
}

.btn-add-site {
    width: 100%;
    background: var(--primary-color);
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    font-weight: 600;
    font-size: 14px;
    margin-top: 16px;
}

.btn-add-site:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.sites-list {
    list-style: none;
}

.site-item {
    background: rgba(255,255,255,0.05);
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column; /* Keep sub-nav below the main header row */
    align-items: stretch;
    gap: 12px;
    color: var(--text-sidebar);
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.site-item i {
    font-size: 18px;
}

.site-item:hover {
    background: rgba(255,255,255,0.1);
}

.site-item.active {
    background: var(--primary-color);
    box-shadow: var(--shadow-sm);
    color: #FFFFFF;
}

.site-item .btn-delete {
    margin-left: auto;
    opacity: 0;
    transition: var(--transition);
}

.site-item:hover .btn-delete {
    opacity: 1;
}

.site-name-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-sidebar);
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
    min-width: 0;
}

.site-name-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.site-name-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Center Content */
.center-content {
    flex: 1;
    min-width: 0;
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-main);
}

/* Company Info Section */
.company-info-section {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    align-items: center;
    flex-wrap: wrap;
}

.company-logo-upload {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.company-logo-upload img {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: var(--shadow-sm);
}

.btn-upload {
    position: absolute;
    bottom: -8px;
    right: -8px;
    background: var(--primary-color);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.btn-upload:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.info-card-inline {
    flex: 1 1 320px;
    min-width: 0;
    background: var(--bg-card);
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

/* Company toolbar: 2-row grid, labels above controls */
.company-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, 1.2fr);
    grid-template-rows: auto auto;
    gap: 14px 20px;
    align-items: end;
}

.company-toolbar .toolbar-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.company-toolbar .toolbar-stack label {
    display: block;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
}

.company-toolbar .toolbar-control {
    box-sizing: border-box;
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-main);
    color: var(--text-primary);
}

.company-toolbar .toolbar-factors-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
}

.company-toolbar .toolbar-factors-row .toolbar-select {
    flex: 1;
    min-width: 0;
}

.company-toolbar .factors-actions {
    display: flex;
    flex-shrink: 0;
    gap: 6px;
    align-items: stretch;
}

.company-toolbar .factors-action-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 52px;
    min-height: 38px;
    padding: 4px 8px;
    white-space: nowrap;
}

.company-toolbar .factors-action-label {
    font-size: 10px;
    line-height: 1;
    font-weight: 500;
}

@media (max-width: 1024px) {
    .company-toolbar {
        grid-template-columns: 1fr 1fr;
    }

    .company-toolbar .toolbar-stack-factors {
        grid-column: 1 / -1;
    }
}

.form-inline-group {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-inline-group label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
    min-width: 120px;
}

.form-inline-group input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-main);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-inline-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-inline-group select {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-main);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-inline-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-inline-group.full-width {
    flex: 1 1 100%;
    align-items: flex-start;
}

.form-inline-group.full-width label {
    padding-top: 8px;
}

.form-inline-group textarea {
    flex: 1;
    min-height: 72px;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-main);
    color: var(--text-primary);
    resize: vertical;
}

.form-inline-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* General Info (onboarding spreadsheet layout) */
.general-info-page .card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.general-info-page-desc {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 720px;
}

.general-info-reporting-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    align-items: flex-end;
}

.general-info-reporting-row > .form-inline-group {
    flex: 1 1 200px;
    min-width: 180px;
}

.general-info-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin: -4px 0 16px;
    line-height: 1.45;
}

.general-info-meta-title {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.general-info-section {
    margin-top: 8px;
    padding-top: 4px;
}

.general-info-section h3 {
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 10px 14px;
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 6px;
}

.general-info-intro {
    margin: 0 0 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.general-info-two-col-headers {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) 1fr 1fr;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.gi-paired-row .gi-paired-inputs {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.general-info-split-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 28px;
}

.general-info-split-col h4 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

#section-general-info .form-inline-group.full-width label {
    min-width: 220px;
    max-width: 42%;
    white-space: normal;
    line-height: 1.35;
}

@media (max-width: 960px) {
    .general-info-split-cols,
    .general-info-two-col-headers,
    .gi-paired-row .gi-paired-inputs {
        grid-template-columns: 1fr;
    }

    .general-info-two-col-headers span:not(:first-child) {
        display: none;
    }
}

/* Data input — per-tab additional questions */
.tab-questions-card {
    width: 100%;
    margin-top: 12px;
    margin-bottom: 16px;
}

.tab-questions-card .tab-question-guidance-label,
.tab-questions-card .tab-question-notes-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 6px;
}

.tab-questions-card .tab-question-notes-label {
    margin-top: 12px;
}

.tab-questions-card .tab-question-prompt {
    margin: 6px 0 12px;
    color: var(--text-secondary);
    max-width: none;
}

.tab-questions-card .tab-question-notes {
    display: block;
    width: 100%;
    min-height: 120px;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    font-family: inherit;
    background: var(--bg-main);
    color: var(--text-primary);
    resize: vertical;
    box-sizing: border-box;
}

.tab-questions-card .tab-question-notes:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Tabs Navigation */
.tabs-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg-card);
    padding: 12px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

/* Conversion Factors UI */
.conversion-factor-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 8px;
}

.conversion-factor-group {
    flex: 1 1 220px;
    min-width: 220px;
    max-width: 440px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 12px 14px;
}

.conversion-factor-group-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 10px;
}

.conversion-factor-group-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: 0;
}

.conversion-factor-group-toggle {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px 6px;
    flex-shrink: 0;
}

.conversion-factor-group-select-all {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.conversion-factor-group-unit-row {
    width: 100%;
}

.conversion-factor-group-body {
    margin-top: 4px;
}

.conversion-factor-subgroup {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.conversion-factor-subgroup-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 6px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.35;
}

.chart-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-granularity-select,
.chart-period-select {
    min-width: 110px;
    font-size: 12px;
}

.chart-period-select {
    min-width: 88px;
}

.data-save-status-banner {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 10000;
    padding: 10px 16px;
    border-radius: 8px;
    background: #0f766e;
    color: #fff;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.data-save-status-banner--visible {
    opacity: 1;
    pointer-events: auto;
}

.data-save-status-banner--error {
    background: #b91c1c;
}

.org-picker-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    background: rgba(15, 23, 42, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.org-picker-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.org-picker-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.org-picker-btn {
    width: 100%;
    text-align: left;
}

.conversion-factor-group-heading {
    display: block;
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    padding: 8px 12px;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 6px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: visible;
    line-height: 1.35;
}

.conversion-factor-group-unit-row .conversion-factor-group-unit {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
}

.conversion-factor-group-unit-row .conversion-factor-group-unit:focus {
    outline: none;
    border-color: var(--primary-color);
}

.conversion-factor-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.conversion-factor-row:last-child {
    border-bottom: none;
}

.conversion-factor-label-wrap {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.conversion-factor-label-wrap input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}

.conversion-factor-label {
    flex: 1;
    min-width: 0;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.35;
}

.conversion-factor-unit {
    width: auto;
    min-width: 88px;
    max-width: 120px;
    margin-top: 2px;
    padding: 4px 6px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    box-sizing: border-box;
}

.assessment-scope-extras,
.assessment-scope-factors-card {
    margin-top: 16px;
}

.assessment-scope-extras-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px;
}

.assessment-scope-factors-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 12px;
    line-height: 1.45;
}

.assessment-scope-scope-toggles {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.assessment-scope-scope-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}

.assessment-scope-scope-label input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--bg-main);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.tab-btn i {
    font-size: 16px;
}

/* Tab Content */
.tabs-content {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.tab-header h2 {
    font-size: 22px;
    color: var(--text-primary);
}

/* Data Table */
.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: auto;
}

/* Keep dropdown columns wide enough to use across all data-input tabs */
.data-table th:nth-child(1),
.data-table td:nth-child(1) {
    min-width: 200px;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
    min-width: 150px;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) {
    min-width: 100px;
}

.data-table th:nth-child(4),
.data-table td:nth-child(4) {
    min-width: 72px;
}

.data-table thead {
    background: var(--bg-main);
    position: sticky;
    top: 0;
}

.data-table th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
}

.data-table input,
.data-table select {
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: var(--transition);
}

.data-table input {
    width: 100%;
}

.data-table select.emission-select {
    width: 100%;
    min-width: 180px;
    max-width: 280px;
    cursor: pointer;
    appearance: auto;
}

.data-table select.row-unit-select {
    width: 100%;
    min-width: 88px;
    max-width: 130px;
    cursor: pointer;
    appearance: auto;
}

.data-table input[type="text"] {
    min-width: 150px;
}

.data-table input[type="number"]:not(.month-input) {
    min-width: 80px;
    font-weight: 600;
    color: var(--primary-color);
}

.data-table input:focus,
.data-table select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-main);
}

.data-table .month-input {
    min-width: 70px;
}

.data-table .total-cell,
.data-table .co2-cell {
    font-weight: 600;
    color: var(--primary-color);
    background: var(--bg-main);
}

.btn-delete {
    background: transparent;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.btn-delete:hover {
    background: var(--danger-color);
    color: white;
}

.category-summary {
    text-align: right;
    font-size: 18px;
    padding: 16px;
    background: var(--bg-main);
    border-radius: 8px;
    margin-top: 16px;
}

.month-input.fy-period-month {
    background: rgba(250, 204, 21, 0.12);
    border-color: rgba(250, 204, 21, 0.45);
}

.month-input.fy-period-month--out {
    opacity: 0.45;
}

.category-summary strong {
    color: var(--primary-color);
    font-size: 24px;
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.dashboard-header h2 {
    font-size: 24px;
    color: var(--text-primary);
}

.export-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-export-pdf {
    background: #DC3545;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: white;
    font-size: 18px;
    box-shadow: var(--shadow-sm);
}

.btn-export-pdf:hover {
    background: #C82333;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-export-excel {
    background: #28A745;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: white;
    font-size: 18px;
    box-shadow: var(--shadow-sm);
}

.btn-export-excel:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 16px;
    color: white;
    position: relative;
}

.kpi-card.kpi-financial {
    background: linear-gradient(135deg, #6C757D, #495057);
}

.kpi-icon {
    font-size: 48px;
    opacity: 0.8;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
}

.kpi-content {
    flex: 1;
}

.kpi-content h3 {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.9;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.kpi-change {
    font-size: 14px;
    font-weight: 600;
    opacity: 0.8;
}

.kpi-edit {
    width: 100%;
    margin-top: 8px;
    padding: 6px 10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 14px;
}

.kpi-edit:focus {
    outline: none;
    border-color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.15);
}

.kpi-edit::placeholder {
    color: rgba(255,255,255,0.5);
}

.kpi-readonly {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    font-style: italic;
}

.widget-hide {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-card:hover .widget-hide {
    opacity: 1;
}

.widget-hide:hover {
    background: rgba(0,0,0,0.4);
}

.widget-card.hidden {
    display: none !important;
}

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

.chart-card {
    min-height: 300px;
    max-height: 450px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.chart-card canvas {
    flex: 1;
    max-height: 350px;
    min-height: 250px;
    position: relative;
    width: 100% !important;
    height: auto !important;
}

/* Make the Invoices and Bills graphs slightly shorter so they don't feel too tall */
.chart-card[data-widget="invoices-chart"],
.chart-card[data-widget="bills-chart"] {
    /* Extra height because these cards include a summary section above the chart */
    min-height: 420px;
    max-height: 480px;
}

.chart-card[data-widget="invoices-chart"] canvas,
.chart-card[data-widget="bills-chart"] canvas {
    max-height: 280px;
}

.chart-card > h3 {
    flex-shrink: 0;
    margin-bottom: 15px;
}

.chart-header {
    flex-shrink: 0;
}

.chart-card h3 {
    margin-bottom: 15px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.chart-header h3 {
    margin: 0;
    flex: 1;
}

.chart-style-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-main);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.chart-style-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: var(--bg-card);
}

.source-trend-charts-grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 900px) {
    .source-trend-charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-style-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--text-secondary);
}

.chart-style-form label input[type="text"],
.chart-style-form label input[type="number"],
.chart-style-form label select {
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 14px;
}

.chart-style-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.chart-style-color-row span {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
}

.chart-style-color-row input[type="color"] {
    width: 48px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
}

.chart-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.watchlist-content {
    padding: 20px 0;
}

.watchlist-item {
    padding: 16px;
    background: var(--bg-main);
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 64px;
        height: calc(100vh - 64px);
        z-index: 99;
        transition: var(--transition);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .company-info-section {
        flex-direction: column;
    }

    .info-card-inline {
        flex-basis: 100%;
    }

    .company-toolbar {
        grid-template-columns: 1fr;
        grid-template-rows: none;
    }

    .company-toolbar .toolbar-stack-factors .toolbar-factors-row {
        flex-wrap: wrap;
    }
    
    .tabs-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    
    .kpi-cards {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* App notification dialog (replaces browser alert/confirm/prompt) */
.app-dialog-overlay {
    z-index: 10050;
}

.app-dialog-content {
    max-width: 420px;
    width: 90%;
}

.app-dialog-message {
    margin: 0;
    white-space: pre-wrap;
    color: var(--text-primary);
    line-height: 1.5;
}

.app-dialog-input {
    width: 100%;
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-main);
    color: var(--text-primary);
}

.app-dialog-input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
}

.app-dialog-content .widget-modal-footer {
    justify-content: stretch;
}

.app-dialog-content .widget-modal-footer .btn-primary,
.app-dialog-content .widget-modal-footer .btn-secondary {
    flex: 1;
    width: auto;
    min-width: 0;
    justify-content: center;
    padding: 12px 20px;
    font-size: 14px;
}

/* Widget Customization Modal */
.widget-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.widget-modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

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

.widget-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 2px solid var(--border-color);
}

.widget-modal-header h3 {
    font-size: 20px;
    color: var(--text-primary);
}

.widget-modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: var(--transition);
}

.widget-modal-close:hover {
    background: var(--bg-main);
    color: var(--text-primary);
}

.widget-modal-body {
    padding: 24px;
}

.widget-modal-body p {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.widget-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.widget-checkbox-item {
    padding: 12px;
    background: var(--bg-main);
    border-radius: 8px;
    border: 2px solid var(--border-color);
    transition: var(--transition);
}

.widget-checkbox-item:hover {
    border-color: var(--primary-color);
}

.widget-checkbox-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}

.widget-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.widget-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 24px;
    border-top: 2px solid var(--border-color);
}

/* Invoice Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 2px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-main);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 2px solid var(--border-color);
}

/* Assessment Scope spreadsheet layout */
.assessment-scope-form-host {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.assessment-scope-section {
    margin-bottom: 0;
}

.assessment-scope-section-title {
    margin: 0 0 12px;
    font-size: 1rem;
    font-weight: 700;
    padding: 8px 12px;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #fff;
    border-radius: 6px;
}

.assessment-scope-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.assessment-scope-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--primary-color);
    color: #fff;
    font-weight: 600;
    border: 1px solid var(--primary-dark);
}

.assessment-scope-table th:nth-child(2) {
    width: 180px;
}

.assessment-scope-table th:nth-child(3) {
    width: 200px;
}

.assessment-scope-table--no-unit th:nth-child(2) {
    width: 280px;
}

.assessment-scope-table--no-unit .assessment-scope-value-cell {
    min-width: 200px;
}

.assessment-scope-table td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    vertical-align: top;
    background: var(--bg-card);
}

.assessment-scope-label {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 220px;
}

.assessment-scope-unit-cell,
.assessment-scope-value-cell {
    min-width: 140px;
}

.assessment-scope-na {
    color: var(--text-secondary);
    text-align: center;
}

.assessment-scope-input,
.assessment-scope-unit,
.assessment-scope-yn {
    width: 100%;
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 13px;
}

.assessment-scope-input {
    resize: vertical;
    min-height: 36px;
}

@media (max-width: 900px) {
    .assessment-scope-table thead {
        display: none;
    }
    .assessment-scope-table tr {
        display: block;
        margin-bottom: 12px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
    }
    .assessment-scope-table td {
        display: block;
        border: none;
        width: 100%;
    }
    .assessment-scope-label {
        font-weight: 700;
        background: var(--bg-main);
    }
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(19, 181, 234, 0.1);
}

/* Invoice Summary */
.invoices-summary {
    margin-bottom: 20px;
}

.invoices-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.invoice-stat {
    padding: 16px;
    background: var(--bg-main);
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

.invoice-stat.overdue {
    border-color: var(--danger-color);
    background: rgba(220, 53, 69, 0.1);
}

.invoice-stat span {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.invoice-stat strong {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Chart Header */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-header h3 {
    margin: 0;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-sm span {
    font-size: 12px;
    white-space: nowrap;
}

/* Print Styles */
@media print {
    .sidebar,
    .tabs-nav,
    .btn-primary,
    .btn-secondary,
    .btn-delete,
    .export-actions {
        display: none !important;
    }
    
    .center-content {
        padding: 0;
    }
    
    .tab-content {
        display: block !important;
        page-break-after: always;
    }
}


