:root {
    --navy: #16243d;
    --navy-2: #1e3050;
    --gold: #c2a05a;
    --bg: #f4f6f9;
    --col-bg: #eaedf2;
    --card: #ffffff;
    --ink: #1f2733;
    --muted: #6b7686;
    --line: #dde2ea;
    --overdue: #d64545;
    --soon: #d99a2b;
    --ok: #2e9e6b;
    --shadow: 0 1px 3px rgba(20, 30, 50, .12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--navy);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo-dot {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 0 4px rgba(194, 160, 90, .25);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.subtitle { font-size: 12px; color: #aeb9cc; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.last-update { font-size: 12px; color: #aeb9cc; margin-right: 4px; }

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    border: none; cursor: pointer; border-radius: 8px;
    font-size: 13px; font-weight: 600; padding: 8px 13px;
    font-family: inherit; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-ghost { background: rgba(255, 255, 255, .12); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, .22); }
.btn-control { background: var(--gold); color: var(--navy); position: relative; }
.btn-control:hover { background: #cdac66; }
.badge {
    position: absolute; top: -7px; right: -7px;
    background: var(--overdue); color: #fff; font-size: 11px; font-weight: 700;
    min-width: 19px; height: 19px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; padding: 0 5px;
    border: 2px solid var(--navy);
}
.hidden { display: none !important; }

.ico-refresh, .ico-bell, .ico-plus { width: 14px; height: 14px; display: inline-block; }
.ico-refresh { background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17.65 6.35A8 8 0 1 0 19.73 14h-2.08A6 6 0 1 1 12 6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17.65 6.35A8 8 0 1 0 19.73 14h-2.08A6 6 0 1 1 12 6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z'/%3E%3C/svg%3E") center/contain no-repeat; }
.ico-bell { background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 22a2 2 0 0 0 2-2h-4a2 2 0 0 0 2 2zm6-6v-5a6 6 0 0 0-5-5.91V4a1 1 0 0 0-2 0v1.09A6 6 0 0 0 6 11v5l-2 2v1h16v-1z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 22a2 2 0 0 0 2-2h-4a2 2 0 0 0 2 2zm6-6v-5a6 6 0 0 0-5-5.91V4a1 1 0 0 0-2 0v1.09A6 6 0 0 0 6 11v5l-2 2v1h16v-1z'/%3E%3C/svg%3E") center/contain no-repeat; }
.ico-plus { background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z'/%3E%3C/svg%3E") center/contain no-repeat; }
.ico-sort { width: 14px; height: 14px; display: inline-block; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z'/%3E%3C/svg%3E") center/contain no-repeat; }
.spinning { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Barra de filtro por departamento ---------- */
.filterbar {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line);
    position: sticky; top: 53px; z-index: 15;
}
.pill {
    border: 1px solid var(--line); background: #fff; color: var(--muted);
    font-size: 12.5px; font-weight: 600; padding: 6px 13px; border-radius: 20px;
    cursor: pointer; font-family: inherit; transition: background .15s, color .15s, border-color .15s;
}
.pill:hover { background: #f3f5f9; color: var(--ink); }
.pill.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.pill-done { margin-left: auto; }
.pill-done.active { background: var(--ok); border-color: var(--ok); }
.pill-projects { border-style: dashed; }

/* ---------- Board ---------- */
.board {
    display: flex;
    gap: 14px;
    padding: 18px 20px 40px;
    overflow-x: auto;
    height: calc(100vh - 103px);
    align-items: flex-start;
}
.board-empty {
    margin: 60px auto; color: var(--muted); font-size: 15px;
}

.column {
    background: var(--col-bg);
    border-radius: 12px;
    width: 290px;
    min-width: 290px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
}
.col-head {
    display: flex; align-items: center; gap: 9px;
    padding: 12px 13px 10px;
    position: sticky; top: 0;
}
.avatar {
    width: 28px; height: 28px; border-radius: 50%;
    color: #fff; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; text-transform: uppercase;
}
.col-name { font-weight: 600; font-size: 14px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-count {
    background: #fff; color: var(--muted); border: 1px solid var(--line);
    font-size: 12px; font-weight: 600; border-radius: 20px; padding: 1px 9px;
}
.col-count.has-overdue { background: #fbe8e8; color: var(--overdue); border-color: #f3cccc; }
.col-icon { font-size: 17px; flex-shrink: 0; }
.col-add {
    width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line);
    background: #fff; color: var(--muted); font-size: 16px; font-weight: 600;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; line-height: 1; transition: background .15s, color .15s;
}
.col-add:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

.col-cards { padding: 0 10px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; }
.col-empty { color: var(--muted); font-size: 12.5px; font-style: italic; padding: 10px 2px; }

.card {
    background: var(--card); border-radius: 9px; padding: 11px 12px;
    box-shadow: var(--shadow); cursor: pointer; border-left: 3px solid transparent;
    transition: box-shadow .15s, transform .05s;
}
.card:hover { box-shadow: 0 4px 12px rgba(20, 30, 50, .16); }
.card:active { transform: translateY(1px); }
.card.is-overdue { border-left-color: var(--overdue); }
.card.is-soon { border-left-color: var(--soon); }
.card.is-done { opacity: .6; }
.card.is-done .card-name { text-decoration: line-through; }
.card-name { font-size: 13.5px; font-weight: 500; line-height: 1.35; margin-bottom: 9px; }
.card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
    font-size: 11px; font-weight: 600; color: var(--navy-2);
    background: #eef1f7; border: 1px solid #e0e5ee; border-radius: 6px;
    padding: 2px 7px; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.due { font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.due.overdue { color: var(--overdue); }
.due.soon { color: var(--soon); }
.due.none { color: #aab2bf; font-weight: 500; }

/* ---------- Modais ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 40, .55);
    display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
    background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
    max-height: 86vh; display: flex; flex-direction: column;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .35); animation: pop .15s ease-out;
}
@keyframes pop { from { transform: scale(.97); opacity: .6; } to { transform: scale(1); opacity: 1; } }
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 16px; margin: 0; }
.modal-close { background: none; border: none; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 18px 20px; overflow-y: auto; }

.alert-group + .alert-group { margin-top: 18px; }
.alert-title { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.alert-title.overdue { color: var(--overdue); }
.alert-title.soon { color: var(--soon); }
.count { background: #eef1f7; color: var(--muted); border-radius: 20px; font-size: 12px; padding: 1px 8px; }
.alert-list { display: flex; flex-direction: column; gap: 7px; }
.alert-item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.alert-item:hover { background: #f7f9fc; }
.alert-item .ai-name { font-size: 13px; font-weight: 500; }
.alert-item .ai-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.alert-item .ai-due { font-size: 12px; font-weight: 700; white-space: nowrap; }
.alert-empty { color: var(--muted); font-size: 13px; font-style: italic; }

/* ---------- Detalhe da tarefa ---------- */
.t-row { display: flex; gap: 10px; margin-bottom: 12px; font-size: 13.5px; }
.t-label { width: 110px; color: var(--muted); flex-shrink: 0; font-weight: 600; }
.t-val { flex: 1; }
.t-pill { display: inline-block; color: #fff; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 20px; }
.t-desc { white-space: pre-wrap; line-height: 1.5; font-size: 13.5px; color: #36404f; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.loading-inline { color: var(--muted); padding: 20px 0; text-align: center; }

/* ---------- Ações na tarefa (editar/excluir) ---------- */
.t-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ---------- Formulário (CRUD) ---------- */
.modal-form .modal-body { display: flex; flex-direction: column; gap: 4px; }
.f-label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 10px 0 5px; }
.f-label:first-of-type { margin-top: 0; }
.f-input {
    width: 100%; border: 1px solid var(--line); border-radius: 8px;
    padding: 9px 11px; font-size: 13.5px; font-family: inherit; color: var(--ink);
    background: #fff;
}
.f-input:focus { outline: none; border-color: var(--navy-2); }
.f-textarea { min-height: 90px; resize: vertical; line-height: 1.45; }

.check-grid {
    display: grid; grid-template-columns: 1fr; gap: 2px;
    max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px;
    padding: 10px 12px; background: #fafbfc;
}
.check-item { display: flex; align-items: center; gap: 9px; font-size: 13.5px; padding: 6px 4px; cursor: pointer; border-radius: 6px; }
.check-item:hover { background: #eef1f7; }
.check-item input { margin: 0; cursor: pointer; width: 16px; height: 16px; flex-shrink: 0; }

.form-hint { font-size: 12px; color: var(--muted); margin: 4px 0 8px; line-height: 1.5; }
.form-hint a { color: var(--navy-2); font-weight: 600; }
.form-msg { font-size: 12.5px; padding: 8px 11px; border-radius: 8px; margin-top: 10px; }
.form-msg.error { background: #fbe8e8; color: var(--overdue); }
.form-msg.ok { background: #e6f4ed; color: var(--ok); }

.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.form-actions .spacer { flex: 1; }
.btn-plain { background: #f0f2f6; color: var(--ink); }
.btn-plain:hover { background: #e5e8ee; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-danger { background: #fbe8e8; color: var(--overdue); }
.btn-danger:hover { background: #f5d2d2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: default; pointer-events: none; }

/* ---------- Status tag no card ---------- */
.status-tag {
    font-size: 10.5px; font-weight: 700; color: #fff; text-transform: uppercase;
    padding: 2px 7px; border-radius: 4px; cursor: pointer; white-space: nowrap;
    letter-spacing: .3px; transition: filter .15s;
}
.status-tag:hover { filter: brightness(1.15); }

/* ---------- Status dropdown ---------- */
.status-dropdown {
    position: fixed; z-index: 100; background: #fff; border: 1px solid var(--line);
    border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 5px 0;
    min-width: 150px; animation: pop .12s ease-out;
}
.sd-item {
    display: flex; align-items: center; gap: 8px; padding: 7px 14px;
    font-size: 13px; font-weight: 500; cursor: pointer; transition: background .1s;
}
.sd-item:hover { background: #f3f5f9; }
.sd-item.sd-active { font-weight: 700; }
.sd-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ---------- Drag & drop de colunas ---------- */
.column { cursor: grab; }
.column.dragging { opacity: .4; cursor: grabbing; }
.column.drag-over { outline: 2px dashed var(--navy); outline-offset: -2px; border-color: transparent; }

/* ---------- Modal de ordenar colunas ---------- */
.modal-sort { max-width: 420px; }
.sort-hint { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.sort-list { display: flex; flex-direction: column; gap: 4px; max-height: 55vh; overflow-y: auto; }
.sort-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    background: #fff; border: 1px solid var(--line); border-radius: 8px;
    font-size: 13.5px; font-weight: 500; cursor: grab; user-select: none;
    transition: box-shadow .1s;
}
.sort-item:active { cursor: grabbing; }
.sort-item.si-dragging { opacity: .4; }
.sort-item.si-over { box-shadow: 0 -2px 0 0 var(--navy); }
.sort-handle { color: var(--muted); font-size: 16px; line-height: 1; flex-shrink: 0; }
.sort-item .avatar { width: 24px; height: 24px; font-size: 10px; }
