:root {
    --primary-dark: #14532D; 
    --primary-light: #22C55E;
    --primary-hover: #166534;
    --bg-color: #F8FAFC;
    --card-bg: #FFFFFF;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border-color: #E2E8F0;
    --danger: #EF4444;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Category Colors (Pastel borders/dots) */
    --cat-default: #CBD5E1;
    --cat-red: #FCA5A5;
    --cat-yellow: #FCD34D;
    --cat-green: #6EE7B7;
    --cat-blue: #93C5FD;
    --cat-purple: #D8B4FE;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }
body { background-color: var(--bg-color); color: var(--text-main); line-height: 1.5; padding-bottom: 3rem; }

header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: var(--shadow-sm);
}

.logo { font-size: 1.25rem; font-weight: 700; color: var(--primary-dark); display: flex; align-items: center; gap: 0.5rem; }
.logo-dot { width: 12px; height: 12px; background-color: var(--primary-light); border-radius: 50%; }
.header-actions { display: flex; gap: 0.75rem; align-items: center; }

/* --- Export Dropdown / Modals --- */
.dropdown { position: relative; display: inline-block; }
.dropdown-content {
    display: none; position: absolute; right: 0; top: 110%;
    background-color: var(--card-bg); min-width: 180px; box-shadow: var(--shadow-md);
    border-radius: var(--radius-md); border: 1px solid var(--border-color); overflow: hidden; z-index: 50;
}
.dropdown-content button { width: 100%; text-align: left; padding: 0.85rem 1rem; border-radius: 0; background: none; color: var(--text-main); border: none; font-size: 0.875rem; }
.dropdown-content button:hover { background-color: var(--bg-color); }
.show { display: block; }

/* Overlays */
.mobile-overlay, .modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(2px);
}

.mobile-overlay { z-index: 45; }
.mobile-overlay.show { display: block; }

/* Custom Modals */
.modal-overlay { z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.custom-modal {
    background: var(--card-bg); padding: 2rem; border-radius: var(--radius-lg);
    max-width: 400px; width: 90%; box-shadow: var(--shadow-md); text-align: center;
}
.custom-modal h3 { margin-bottom: 0.5rem; color: var(--text-main); }
.custom-modal p { margin-bottom: 1.5rem; color: var(--text-muted); font-size: 0.875rem; }
.custom-modal-actions { display: flex; gap: 1rem; justify-content: center; }
.modal-input { width: 100%; padding: 0.625rem; border: 1px solid var(--border-color); border-radius: var(--radius-md); margin-bottom: 1.5rem; font-size: 0.875rem; outline: none; }
.modal-input:focus { border-color: var(--primary-dark); }

/* --- Buttons --- */
button { cursor: pointer; border: none; border-radius: var(--radius-md); font-weight: 500; font-size: 0.875rem; padding: 0.5rem 1rem; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; }
.btn-primary { background-color: var(--primary-dark); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-outline { background-color: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background-color: var(--bg-color); }
.btn-danger { background-color: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background-color: var(--danger); color: white; }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.75rem; background-color: var(--border-color); color: var(--text-main); }
.btn-small:hover { background-color: #CBD5E1; }

/* --- Layout & Forms --- */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem; }
.controls-section { background: var(--card-bg); padding: 1.5rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); margin-bottom: 2rem; display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.input-group { display: flex; flex-direction: column; gap: 0.5rem; flex: 1; min-width: 180px; }
.input-group label { font-size: 0.875rem; font-weight: 500; color: var(--text-muted); display: flex; justify-content: space-between; }
.input-group input, .input-group select { padding: 0.625rem; border: 1px solid var(--border-color); border-radius: var(--radius-md); font-size: 0.875rem; outline: none; transition: border-color 0.2s; background: white; width: 100%; }
.input-group input:focus, .input-group select:focus { border-color: var(--primary-dark); box-shadow: 0 0 0 3px rgba(20, 83, 45, 0.1); }
.edit-link { font-size: 0.75rem; color: var(--primary-light); cursor: pointer; }
.edit-link:hover { text-decoration: underline; }

/* --- Dashboard Grid --- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1.5rem; }
.kpi-card { background: var(--card-bg); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow-md); border: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 1.25rem; transition: transform 0.2s, box-shadow 0.2s; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1); }

/* Categories UI & Trend Arrows */
.cat-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.edit-icon { cursor: pointer; color: var(--text-muted); width: 14px; height: 14px; margin-left: 0.35rem; opacity: 0.6; }
.edit-icon:hover { color: var(--primary-dark); opacity: 1; }
.trend-arrow { font-size: 1rem; font-weight: 700; color: var(--text-muted); margin-left: 0.25rem; }

/* Sparkline Chart */
.sparkline-wrapper { width: 100%; height: 30px; opacity: 0.6; pointer-events: none; margin-top: 0.25rem; }
.sparkline-canvas { width: 100%; height: 100%; display: block; }

/* Due Date Badges */
.due-date-badge { font-size: 0.7rem; padding: 0.25rem 0.6rem; border-radius: 999px; background: #F1F5F9; color: var(--text-muted); display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 600; margin-top: 0.25rem; width: fit-content; }
.due-date-badge.urgent { background: #FEF3C7; color: #B45309; }
.due-date-badge.overdue { background: #FEE2E2; color: #B91C1C; }
.due-date-badge.good { background: #ECFCCB; color: #3F6212; }

/* Global Dashboard Summary */
.dashboard-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; background: var(--card-bg); padding: 2rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border: 1px solid var(--border-color); }
.summary-stat { display: flex; flex-direction: column; gap: 0.25rem; text-align: center; }
.summary-stat-value { font-size: 2rem; font-weight: 700; color: var(--primary-dark); }
.summary-stat-label { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }

/* Drag & Drop Styles */
.kpi-card.dragging { opacity: 0.4; transform: scale(0.98); }
.kpi-card.drag-over { border-style: dashed !important; border-width: 2px !important; background-color: #F0FDF4; }
.drag-handle { color: var(--text-muted); cursor: grab; padding: 0.2rem; margin-left: -0.5rem; opacity: 0.5; transition: opacity 0.2s; display: flex; align-items: center; }
.drag-handle:hover { opacity: 1; color: var(--text-main); }
.drag-handle:active { cursor: grabbing; }

.kpi-header { display: flex; justify-content: space-between; align-items: flex-start; }
.kpi-title-wrapper { display: flex; gap: 0.5rem; align-items: flex-start; }
.kpi-checkbox { margin-top: 0.3rem; cursor: pointer; accent-color: var(--primary-dark); width: 14px; height: 14px; }
.kpi-title { font-size: 1.125rem; font-weight: 600; color: var(--text-main); line-height: 1.2; word-break: break-word; display: flex; align-items: center; gap: 0.4rem;}
.kpi-type-badge { display: inline-block; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; background: #F1F5F9; color: var(--text-muted); padding: 0.15rem 0.5rem; border-radius: 999px; margin-top: 0.25rem; font-weight: 600; }
.kpi-delete { color: var(--text-muted); background: none; border: none; font-size: 1.25rem; padding: 0; line-height: 1; opacity: 0.5; }
.kpi-delete:hover { opacity: 1; color: var(--danger); }

.kpi-stats { display: flex; align-items: baseline; gap: 0.5rem; }
.kpi-current { font-size: 2rem; font-weight: 700; color: var(--primary-dark); }
.kpi-target { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }

.progress-wrapper { width: 100%; height: 8px; background-color: var(--border-color); border-radius: 999px; overflow: hidden; margin-top: 0.5rem; }
.progress-bar { height: 100%; background-color: var(--primary-dark); border-radius: 999px; transition: width 0.5s ease-out; }

.kpi-actions { display: flex; gap: 0.5rem; margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border-color); width: 100%; }
.inline-edit { display: none; width: 100%; gap: 0.5rem; }
.inline-edit input { flex: 1; padding: 0.35rem 0.5rem; border: 1px solid var(--border-color); border-radius: var(--radius-md); font-size: 0.875rem; width: 100%; }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 4rem 2rem; color: var(--text-muted); background: var(--card-bg); border-radius: var(--radius-lg); border: 1px dashed var(--border-color); }

/* Multi-Select Action Bar */
.multi-action-bar {
    position: fixed; bottom: -100px; left: 50%; transform: translateX(-50%);
    background: #1E293B; color: white; padding: 0.75rem 1.5rem;
    border-radius: 999px; display: flex; gap: 1rem; align-items: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2); transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 60;
}
.multi-action-bar.show { bottom: 2rem; }
.multi-action-bar select { background: white; color: var(--text-main); border: none; padding: 0.4rem; border-radius: 6px; font-size: 0.8rem; outline: none; }

/* --- Mobile Responsive Rules --- */
@media (max-width: 768px) {
    header { flex-direction: column; gap: 1rem; align-items: stretch; padding: 1rem; }
    .header-actions { justify-content: space-between; }
    .container { padding: 1rem; }
    .controls-section { flex-direction: column; align-items: stretch; }
    .input-group { min-width: 100%; }
    .multi-action-bar { width: 90%; flex-wrap: wrap; justify-content: center; border-radius: var(--radius-lg); }
    
    .dropdown-content {
        position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
        width: 90%; max-width: 320px; border-radius: var(--radius-lg); border: none;
        box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
        z-index: 55;
    }
    .dropdown-content button { padding: 1.25rem; font-size: 1rem; text-align: center; border-bottom: 1px solid var(--border-color); }
    .dropdown-content button:last-child { border-bottom: none; }
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 2rem 1rem 1rem 1rem;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border-color);
}