/* ===== Gestor Byte — design tokens ===== */
:root {
    --bg: #F4F7FC;
    --surface: #FFFFFF;
    --ink: #10192E;
    --ink-soft: #5B6B8C;
    --border: #E3E9F5;

    --primary: #2451D9;
    --primary-dark: #1B3EAD;
    --primary-soft: #E9EFFD;
    --accent-sky: #5BA9FF;

    --success: #1FAE7A;
    --success-soft: #E4F7EF;
    --danger: #E5484D;
    --danger-soft: #FCEAEA;
    --warning: #F5A524;
    --warning-soft: #FDF1DD;
    --low: #2C6BFF;
    --low-soft: #EAF0FF;

    --shadow-sm: 0 1px 2px rgba(16, 25, 46, .06);
    --shadow-md: 0 8px 24px rgba(36, 81, 217, .08);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;

    --font-display: 'Poppins', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ===== App shell ===== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 20;
    transition: transform .25s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 28px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--accent-sky));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 14px;
}

.brand-name {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -.01em;
}

.nav { display: flex; flex-direction: column; gap: 2px; position: relative; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-weight: 500;
    font-size: 14px;
    transition: color .15s ease, background .15s ease;
    position: relative;
}

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

.nav-item:hover { background: var(--primary-soft); color: var(--primary); }

.nav-item.active {
    color: var(--primary);
    background: var(--primary-soft);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 3px;
    background: var(--primary);
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px 8px 0;
    border-top: 1px solid var(--border);
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink-soft);
    font-size: 13px;
    padding: 10px 4px 0;
}
.logout-link:hover { color: var(--danger); }

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    padding: 28px 36px 60px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
}

.topbar h1 {
    font-size: 22px;
    margin: 0;
    letter-spacing: -.01em;
}

.topbar .subtitle { color: var(--ink-soft); font-size: 13.5px; margin-top: 2px; }

.menu-toggle {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
}

/* ===== Cards / KPIs ===== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}

.kpi-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 500; }
.kpi-value { font-family: var(--font-mono); font-size: 24px; font-weight: 700; margin-top: 6px; }
.kpi-value.positive { color: var(--success); }
.kpi-value.negative { color: var(--danger); }
.kpi-sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-weight: 600;
    font-size: 15px;
    margin: 0 0 16px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
    align-items: stretch;
}

/* ===== Kanban ===== */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: start;
}

.kanban-column {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    min-height: 200px;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px 12px;
}

.kanban-column-title { font-weight: 600; font-size: 14px; }
.kanban-count {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--ink-soft);
    background: var(--bg);
    border-radius: 20px;
    padding: 2px 8px;
}

.kanban-cards { display: flex; flex-direction: column; gap: 10px; min-height: 40px; }

.task-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--low);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    cursor: grab;
    transition: box-shadow .15s ease, transform .15s ease;
}

.task-card:hover { box-shadow: var(--shadow-md); }
.task-card.sortable-ghost { opacity: .4; }
.task-card.sortable-drag { box-shadow: var(--shadow-md); }

.task-card[data-priority="urgente"] { border-left-color: var(--danger); }
.task-card[data-priority="medio"] { border-left-color: var(--warning); }
.task-card[data-priority="baixo"] { border-left-color: var(--low); }

.task-title { font-weight: 500; font-size: 13.5px; line-height: 1.4; margin-bottom: 8px; }

.task-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.priority-tag {
    font-size: 10.5px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: none;
}
.priority-tag.urgente { background: var(--danger-soft); color: var(--danger); }
.priority-tag.medio { background: var(--warning-soft); color: #9A6B0C; }
.priority-tag.baixo { background: var(--low-soft); color: var(--low); }

.task-due {
    font-size: 11px;
    color: var(--ink-soft);
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 4px;
}
.task-due.overdue { color: var(--danger); font-weight: 600; }

.add-task-btn {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--ink-soft);
    font-size: 13px;
    margin-top: 10px;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}
.add-task-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ===== Buttons / forms ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    transition: transform .1s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger-ghost { background: var(--danger-soft); color: var(--danger); }

.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--ink-soft);
}
.field input, .field select, .field textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 14px;
    background: var(--surface);
    color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(16, 25, 46, .45);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    opacity: 0; pointer-events: none;
    transition: opacity .15s ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 26px;
    width: 420px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 20px 60px rgba(16, 25, 46, .25);
    transform: translateY(10px) scale(.98);
    transition: transform .15s ease;
}
.modal-backdrop.open .modal { transform: translateY(0) scale(1); }

.modal h2 { margin: 0 0 18px; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ===== Tables ===== */
table.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    font-size: 12px;
    color: var(--ink-soft);
    font-weight: 600;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 8px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.data-table tr:last-child td { border-bottom: none; }
.cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ===== Charts (finance) ===== */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 80px; align-items: center; gap: 10px; }
.bar-row .label { font-size: 12.5px; }
.bar-track { background: var(--bg); border-radius: 6px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width .5s ease; }
.bar-row .value { font-family: var(--font-mono); font-size: 12px; text-align: right; }

.insight-list { display: flex; flex-direction: column; gap: 10px; }
.insight-item {
    display: flex; gap: 10px; align-items: flex-start;
    font-size: 13px; line-height: 1.5;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg);
}
.insight-item svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.insight-item.up { color: #9A3B3E; }
.insight-item.down { color: #146B4C; }

/* ===== Login ===== */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, #E9EFFD 0%, var(--bg) 55%);
    padding: 20px;
}
.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 40px 36px;
    width: 380px;
    max-width: 100%;
}
.auth-card .brand { padding: 0 0 24px; justify-content: center; }
.auth-card h1 { font-size: 18px; text-align: center; margin: 0 0 4px; }
.auth-card .subtitle { text-align: center; color: var(--ink-soft); font-size: 13px; margin-bottom: 26px; }
.auth-error {
    background: var(--danger-soft);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

/* ===== Entrance animation (single orchestrated moment) ===== */
@media (prefers-reduced-motion: no-preference) {
    .sidebar, .topbar, .kpi-card, .card, .kanban-column {
        animation: rise-in .5s cubic-bezier(.16,1,.3,1) both;
    }
    .sidebar { animation-delay: 0ms; }
    .topbar { animation-delay: 40ms; }
    .kpi-card:nth-child(1) { animation-delay: 80ms; }
    .kpi-card:nth-child(2) { animation-delay: 130ms; }
    .kpi-card:nth-child(3) { animation-delay: 180ms; }
    .grid-2 .card:nth-child(1), .kanban-column:nth-child(1) { animation-delay: 120ms; }
    .grid-2 .card:nth-child(2), .kanban-column:nth-child(2) { animation-delay: 170ms; }
    .kanban-column:nth-child(3) { animation-delay: 220ms; }
}

@keyframes rise-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--ink);
    color: white;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    box-shadow: var(--shadow-md);
    transform: translateY(20px);
    opacity: 0;
    transition: transform .2s ease, opacity .2s ease;
    z-index: 200;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .kpi-row { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .kanban-board { grid-template-columns: 1fr; }
    .field-row { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
    .sidebar {
        transform: translateX(-100%);
        width: 220px;
    }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
    .main { margin-left: 0; padding: 20px 16px 50px; }
    .menu-toggle { display: flex; }
}
