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

:root {
    --bg: #F5F6FA;
    --bg-card: #FFFFFF;
    --bg-sidebar: #1B2A3B;
    --bg-sidebar-hover: #253A4E;
    --bg-sidebar-active: #2D6A4F;

    --text-primary: #1A1D26;
    --text-secondary: #6B7280;
    --text-sidebar: #B0BEC5;
    --text-white: #FFFFFF;

    --accent: #2D6A4F;
    --accent-light: #40916C;
    --accent-bg: rgba(45, 106, 79, 0.08);

    --red: #E74C3C;
    --red-bg: rgba(231, 76, 60, 0.08);
    --orange: #F39C12;
    --orange-bg: rgba(243, 156, 18, 0.08);
    --blue: #3498DB;
    --blue-bg: rgba(52, 152, 219, 0.08);
    --green: #27AE60;
    --green-bg: rgba(39, 174, 96, 0.08);
    --purple: #8E44AD;
    --purple-bg: rgba(142, 68, 173, 0.08);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --sidebar-width: 240px;
    --topbar-height: 64px;

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo-icon {
    font-size: 28px;
    line-height: 1;
}

.logo-text {
    color: var(--text-white);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-sidebar);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-align: left;
    width: 100%;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-white);
}

.nav-item.active {
    background: var(--bg-sidebar-active);
    color: var(--text-white);
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sync-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border: 1px solid rgba(255,255,255,0.12);
    background: transparent;
    color: var(--text-sidebar);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    width: 100%;
}

.sync-btn svg {
    width: 18px;
    height: 18px;
}

.sync-btn:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-white);
}

.sync-btn.syncing svg {
    animation: spin 1s linear infinite;
}

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

/* ── Main Content ───────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: var(--topbar-height);
    background: rgba(245, 246, 250, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

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

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.current-date {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.btn-new-task {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: var(--accent);
    color: var(--text-white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-new-task svg {
    width: 16px;
    height: 16px;
}

.btn-new-task:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ── Views ──────────────────────────────────────────────────────── */
.view {
    display: none;
    padding: 24px 32px;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

/* ── Stats Grid ─────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid rgba(0,0,0,0.04);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    font-size: 32px;
    line-height: 1;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-urgente .stat-value { color: var(--red); }
.stat-atrasadas .stat-value { color: var(--orange); }
.stat-taxa .stat-value { color: var(--green); }

/* ── Dashboard Grid ─────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.04);
    overflow: hidden;
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.card-header h2 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.card-action {
    background: none;
    border: none;
    color: var(--accent);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.card-action:hover {
    color: var(--accent-light);
}

.card-period {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.card-body {
    padding: 16px 24px 24px;
}

/* ── Urgentes List ──────────────────────────────────────────────── */
.urgente-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    transition: var(--transition);
}

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

.urgente-item:hover {
    background: var(--accent-bg);
    margin: 0 -24px;
    padding-left: 24px;
    padding-right: 24px;
    border-radius: var(--radius-sm);
}

.urgente-check {
    width: 20px;
    height: 20px;
    border: 2px solid #D1D5DB;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.urgente-check:hover {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.urgente-info {
    flex: 1;
    min-width: 0;
}

.urgente-titulo {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.urgente-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.urgente-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.badge-prazo { background: var(--orange-bg); color: var(--orange); }
.badge-audiencia { background: var(--blue-bg); color: var(--blue); }
.badge-peticao { background: var(--purple-bg); color: var(--purple); }
.badge-urgente { background: var(--red-bg); color: var(--red); }
.badge-concluida { background: var(--green-bg); color: var(--green); }

.urgente-countdown {
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.countdown-danger { color: var(--red); }
.countdown-warning { color: var(--orange); }
.countdown-ok { color: var(--text-secondary); }

/* ── Donut Chart ────────────────────────────────────────────────── */
.donut-container {
    position: relative;
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-value {
    display: block;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-primary);
}

.donut-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.donut-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ── Data Table ─────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.data-table td {
    padding: 14px 0;
    font-size: 13px;
    border-bottom: 1px solid rgba(0,0,0,0.03);
}

.data-table tr:hover td {
    background: var(--accent-bg);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.status-pendente { background: var(--orange-bg); color: var(--orange); }
.status-concluida { background: var(--green-bg); color: var(--green); }
.status-atrasada { background: var(--red-bg); color: var(--red); }

/* ── Tarefas List View ──────────────────────────────────────────── */
.view-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    gap: 12px;
}

.filter-select {
    padding: 8px 14px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.tarefa-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.04);
    transition: var(--transition);
    cursor: pointer;
}

.tarefa-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.tarefa-card.concluida {
    opacity: 0.6;
}

.tarefa-card.concluida .tarefa-titulo {
    text-decoration: line-through;
}

.tarefa-check {
    width: 22px;
    height: 22px;
    border: 2px solid #D1D5DB;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    font-size: 12px;
}

.tarefa-check:hover {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.tarefa-check.checked {
    background: var(--green);
    border-color: var(--green);
    color: white;
}

.tarefa-body {
    flex: 1;
    min-width: 0;
}

.tarefa-titulo {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.tarefa-desc {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tarefa-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.tarefa-data {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Week View ──────────────────────────────────────────────────── */
.week-nav, .month-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
}

.week-nav-btn, .month-nav-btn {
    padding: 6px 16px;
    background: var(--bg-card);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.week-nav-btn:hover, .month-nav-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.week-label, .month-label {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.week-day {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    min-height: 200px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.04);
}

.week-day-header {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.week-day-date {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.week-day.today {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-bg);
}

.week-day.today .week-day-date {
    color: var(--accent);
}

.week-task {
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid;
}

.week-task:hover {
    transform: scale(1.02);
}

.week-task-prazo { background: var(--orange-bg); border-color: var(--orange); color: var(--orange); }
.week-task-audiencia { background: var(--blue-bg); border-color: var(--blue); color: var(--blue); }
.week-task-peticao { background: var(--purple-bg); border-color: var(--purple); color: var(--purple); }

/* ── Calendar Month View ────────────────────────────────────────── */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: rgba(0,0,0,0.04);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.cal-header {
    background: var(--bg-sidebar);
    color: var(--text-white);
    padding: 12px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cal-day {
    background: var(--bg-card);
    padding: 10px;
    min-height: 90px;
    transition: var(--transition);
}

.cal-day:hover {
    background: var(--accent-bg);
}

.cal-day.other-month {
    opacity: 0.3;
}

.cal-day.today {
    background: var(--accent-bg);
}

.cal-day-number {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
}

.cal-day.today .cal-day-number {
    color: var(--accent);
    font-weight: 800;
}

.cal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 3px;
    margin-bottom: 3px;
}

.cal-dot-prazo { background: var(--orange); }
.cal-dot-audiencia { background: var(--blue); }
.cal-dot-peticao { background: var(--purple); }

.cal-task-mini {
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 4px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 32px;
    width: 500px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--red-bg);
    color: var(--red);
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
    background: var(--bg);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.btn-submit {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.btn-submit:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ── Empty State ────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .week-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .menu-toggle {
        display: block;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .view {
        padding: 16px;
    }
    .top-bar {
        padding: 0 16px;
    }
    .week-grid {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}
