:root {
    --base-font-size: 14px;
    --bg: #f0f3f7;
    --surface: #ffffff;
    --surface2: #f8fafc;
    --text: #1a2332;
    --text2: #4a5568;
    --text3: #718096;
    --border: #e2e8f0;
    --border2: #edf2f7;
    --accent: #2c7da0;
    --accent2: #3b8db5;
    --green: #2d9d5a;
    --greenBg: #e6f7ed;
    --amber: #e69b00;
    --amberBg: #fff8e6;
    --red: #c53030;
    --redBg: #fef2f2;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadowHover: 0 8px 24px rgba(0, 0, 0, 0.10);
    --radius: 18px;
    --radiusSm: 10px;
    --radiusLg: 28px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebarW: 280px;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Inter', Roboto, system-ui, sans-serif;
}
html { font-size: var(--base-font-size); }
body {
    background: var(--bg);
    min-height: 100vh;
    color: var(--text);
    display: flex;
    font-size: 1rem;
    overflow-x: hidden;
}

/* ─── SIDEBAR ─────────────────────── */
.sidebar {
    width: var(--sidebarW);
    background: #0f1922;
    color: #e2e8f0;
    height: 100vh;
    position: fixed;
    top: 0;
    inset-inline-start: 0; /* RTL: right, LTR: left */
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.18);
}
[dir="rtl"] .sidebar { box-shadow: -4px 0 20px rgba(0, 0, 0, 0.18); }

.sidebar-logo {
    padding: 20px 22px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-logo h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo h2 i { color: #4db8e8; font-size: 1.4rem; }
.sidebar-section {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-section h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #8899aa;
    margin-bottom: 10px;
    font-weight: 600;
}
.sidebar-section select,
.sidebar-section input {
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    font-size: 0.82rem;
    margin-bottom: 10px;
    transition: var(--transition);
}
.sidebar-section select option { background: #1a2c3e; color: #e2e8f0; }
.filter-chip {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 30px;
    font-size: 0.7rem;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e0;
    transition: var(--transition);
    white-space: nowrap;
}
.filter-chip.active,
.filter-chip:hover {
    background: #4db8e8;
    color: #fff;
    border-color: #4db8e8;
}
.sidebar-actions {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.btn-sidebar {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-sidebar.primary { background: #4db8e8; border-color: #4db8e8; color: #fff; }
.btn-sidebar.warning { background: #e69b00; border-color: #e69b00; color: #fff; }
.mode-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    padding: 3px;
    margin-bottom: 8px;
}
.mode-toggle button {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.75rem;
    background: transparent;
    color: #bcc8d4;
}
.mode-toggle button.active {
    background: #fff;
    color: #0f1922;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.font-control {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 0.7rem;
    color: #8899aa;
}
.font-control input[type=range] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}
.font-control input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #4db8e8;
    border-radius: 50%;
    cursor: pointer;
}

/* ─── MAIN CONTENT ───────────────── */
.main-content {
    margin-inline-start: var(--sidebarW); /* Push content by sidebar width */
    flex: 1;
    padding: 20px 24px 30px;
    min-height: 100vh;
    transition: margin-inline-start var(--transition);
    width: calc(100% - var(--sidebarW));
}
.top-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    background: var(--surface);
    border-radius: var(--radiusLg);
    padding: 12px 20px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 12px;
    z-index: 50;
}
.search-wrap {
    position: relative;
    flex: 1;
}
.search-wrap i {
    position: absolute;
    inset-inline-end: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text3);
}
.search-wrap input {
    width: 100%;
    padding: 10px 16px;
    padding-inline-end: 32px;
    border-radius: 30px;
    border: 2px solid var(--border);
    font-size: 0.85rem;
    background: var(--surface2);
}
.btn-top {
    padding: 9px 16px;
    border-radius: 30px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-top.accent {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text);
}

/* ─── STATS ROW ──────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radiusLg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
    border-inline-start: 5px solid transparent;
}
.stat-card.blue { border-inline-start-color: var(--accent); }
.stat-card.green { border-inline-start-color: var(--green); }
.stat-card.amber { border-inline-start-color: var(--amber); }
.stat-card.red { border-inline-start-color: var(--red); }
.stat-icon {
    font-size: 1.8rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-icon.blue { background: #e6f0f7; color: var(--accent); }
.stat-icon.green { background: var(--greenBg); color: var(--green); }
.stat-icon.amber { background: var(--amberBg); color: var(--amber); }
.stat-icon.red { background: var(--redBg); color: var(--red); }
.stat-info h3 { font-size: 1.5rem; font-weight: 700; }
.stat-info p { font-size: 0.72rem; color: var(--text3); }

/* ─── CHART PANEL ────────────────── */
.chart-panel {
    background: var(--surface);
    border-radius: var(--radiusLg);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.chart-panel canvas { max-height: 200px !important; height: 200px !important; }
.chart-toolbar input, .chart-toolbar select {
    padding: 6px 12px;
    border-radius: 30px;
    border: 2px solid var(--border);
    font-weight: 500;
    font-size: 0.8rem;
    background: var(--surface2);
}

/* ─── SCORECARD ──────────────────── */
.scorecard-section {
    background: var(--surface);
    border-radius: var(--radiusLg);
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.scorecard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.scorecard-table td, .scorecard-table th {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border2);
    text-align: start;
}
.scorecard-table th {
    background: var(--surface2);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text3);
}
.scorecard-table tr:last-child td { border-bottom: none; }
.reward-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 30px;
    font-size: 0.68rem;
    font-weight: 700;
}
.reward-high { background: var(--greenBg); color: #1a6b35; }
.reward-medium { background: var(--amberBg); color: #8b5e00; }
.reward-low { background: var(--redBg); color: #9b1c1c; }

/* ─── INITIATIVES GRID ───── */
.initiatives-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
}
.init-card {
    background: var(--surface);
    border-radius: var(--radiusLg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border2);
    transition: var(--transition);
    overflow: visible;
    width: 100%;
}
.init-card.rag-green { border-inline-start: 6px solid var(--green); background: #d4eedd; }
.init-card.rag-amber { border-inline-start: 6px solid var(--amber); background: #fcebbb; }
.init-card.rag-red { border-inline-start: 6px solid var(--red); background: #fad9d9; }
.card-header { padding: 14px 18px 6px; cursor: pointer; }
.init-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}
.init-title input {
    font-weight: 700;
    text-align: center;
    background: #fffef9;
    border: 1px solid #e0dcc8;
    border-radius: 22px;
    padding: 6px 10px;
    font-size: 0.85rem;
    min-width: 0;
}
.owner-multi { margin-top: 8px; position: relative; }
.owner-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.owner-chip {
    background: #e6f0f7;
    border: 1px solid #b8d4e5;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 5px;
}
.owner-chip .remove-owner { cursor: pointer; color: #8899aa; }
.owner-chip .remove-owner:hover { color: #b00020; }
.owner-input-row { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.owner-custom-input {
    flex: 1;
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid #d4dfe8;
    background: #f7fafd;
    font-size: 0.72rem;
}
.owner-dropdown-btn {
    background: #eef2f5;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
}
.owner-dropdown-menu {
    position: absolute;
    top: 100%;
    inset-inline-end: 0;
    background: #fff;
    border: 1px solid #d4dfe8;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    z-index: 20;
    max-height: 200px;
    overflow-y: auto;
    padding: 6px;
    display: none;
}
.dropdown-item {
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.75rem;
}
.dropdown-item:hover { background: #f0f4fa; }
.dropdown-item.selected { font-weight: 600; color: var(--accent); }
.progress-fill.green { background: linear-gradient(90deg, #2d9d5a, #3cb970); }
.progress-fill.amber { background: linear-gradient(90deg, #e69b00, #f0b830); }
.progress-fill.red { background: linear-gradient(90deg, #c53030, #e04848); }
.deliverables-wrapper.collapsed .deliverables-area,
.deliverables-wrapper.collapsed .add-deliverable { display: none; }
.btn-icon.danger { background: #ffe8e8; color: #b00020; }

.del-row-1 {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}
.del-text {
    flex: 3;
    min-width: 0;
    width: 100%;
    background: #fff;
    border: 1px solid #d5e2ec;
    border-radius: 22px;
    padding: 6px 10px;
    font-size: 0.76rem;
}
.del-due-date, .del-done-date {
    background: #fff;
    border: 1px solid #d5e2ec;
    border-radius: 22px;
    padding: 5px 8px;
    font-size: 0.7rem;
    width: 170px;
}
.justify-field {
    width: 100%;
    border-radius: 14px;
    border: 1px solid #e0eef5;
    padding: 5px 10px;
    font-size: 0.68rem;
    resize: vertical;
    background: #fffefc;
}

body.view-mode .owner-custom-input,
body.view-mode .owner-dropdown-btn,
body.view-mode .remove-owner,
body.view-mode .add-deliverable,
body.view-mode .btn-icon.danger,
body.view-mode .delete-initiative,
body.view-mode #addInitiativeBtn,
body.view-mode #addInitiativeBtn2,
body.view-mode #importConfigBtn,
body.view-mode #resetDefaultBtn,
body.view-mode #resetDefaultBtn2 {
    display: none;
}

body.view-mode input, body.view-mode textarea, body.view-mode select {
    pointer-events: none;
    border-color: transparent !important;
    background: transparent !important;
}
body.view-mode input[type="checkbox"] { pointer-events: auto; } /* Allow checking done maybe? Based on role */

.reminder-badge {
    display: inline-block;
    background: #fff3e0;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    margin-inline-start: 4px;
    border: 1px solid #f0d8b0;
}
.badge-id {
    font-size: 0.65rem;
    color: var(--text3);
    background: var(--surface2);
    padding: 2px 10px;
    border-radius: 20px;
    margin-inline-end: 6px;
}
.weight-input {
    width: 44px !important;
    padding: 2px 4px !important;
    border-radius: 12px !important;
    border: 1px solid var(--border) !important;
    font-size: 0.7rem !important;
    background: var(--surface2) !important;
    margin-inline-end: 4px;
}
.rag-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-inline-start: 6px;
}
.rag-dot.green { background: var(--green); }
.rag-dot.amber { background: var(--amber); }
.rag-dot.red { background: var(--red); }
.progress-section {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 18px 8px;
}
.progress-section span { font-weight: 700; font-size: 0.8rem; min-width: 40px; }
.progress-bar-bg {
    flex: 1;
    height: 8px;
    background: #eef2f5;
    border-radius: 20px;
    overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 20px; transition: width 0.3s; }
.init-comment textarea {
    width: 100%;
    border: 1px solid #e0eef5;
    border-radius: 14px;
    padding: 6px 12px;
    font-size: 0.72rem;
    resize: vertical;
    background: #fafcfe;
    margin: 2px 0 6px;
}
.deliverables-wrapper { padding: 0 18px 14px; }
.deliverables-wrapper h4 {
    font-size: 0.8rem;
    color: var(--text2);
    margin: 6px 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.deliverable-item {
    background: var(--surface2);
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid var(--border2);
}
.add-deliverable {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}
.add-deliverable input {
    flex: 1;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 0.72rem;
    background: #fafcfe;
}
.add-deliverable input[type="datetime-local"] { flex: 0 0 170px; }
.btn-icon {
    background: #eef2f5;
    border: none;
    border-radius: 30px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 0.7rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-icon:hover { background: #dce4ec; }
.toggle-icon {
    margin-inline-end: 6px;
    font-size: 0.8rem;
    color: var(--text3);
}
.scorecard-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.global-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Sidebar Overlap Fix */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
    }
    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }
    [dir="ltr"] .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0) !important;
    }
    
    /* When sidebar is closed on mobile, main content takes full width */
    .main-content {
        margin-inline-start: 0;
        width: 100%;
    }

    /* If they want it to push on mobile when open instead of overlap */
    /* Add this class to body via JS */
    body.sidebar-open .main-content {
        margin-inline-start: var(--sidebarW);
        width: calc(100% - var(--sidebarW));
    }
    
    .hamburger { display: block; }
    .del-due-date, .del-done-date { width: 140px; }
    .top-bar .global-actions { order: 3; width: 100%; justify-content: flex-start; }
    .top-bar .hamburger { order: 0; }
    .top-bar .search-wrap { order: 1; flex: 1; }
}
