:root {
  --bg: #f4f5f7; --card: #ffffff; --ink: #1a2230; --muted: #6b7585;
  --line: #e4e7ec; --line-2: #eef0f3;
  --accent: #2b4a8b; --accent-2: #35528c; --accent-soft: #eef2f9;
  --green: #1f7a4d; --green-soft: #e8f3ec; --amber: #9a6b00; --amber-soft: #fbf2e0;
  --red: #b23b3b; --red-soft: #f8eaea; --blue: #2b4a8b; --blue-soft: #eef2f9;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); display: flex; min-height: 100vh; font-size: 14px; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }

/* Sidebar */
.sidebar { width: 232px; background: #0d1526; color: #aeb6c4; display: flex; flex-direction: column; padding: 22px 0; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 20px 26px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, #2b4a8b, #3a63b8); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; letter-spacing: .5px; }
.brand-txt { font-weight: 600; font-size: 15px; color: #fff; }
#nav { display: flex; flex-direction: column; gap: 1px; padding: 0 12px; }
#nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 7px; cursor: pointer; font-size: 13.5px; color: #aeb6c4; transition: .12s; }
#nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
#nav a:hover { background: #161f33; color: #fff; }
#nav a.active { background: #2b4a8b; color: #fff; }
.sidebar-foot { margin-top: auto; padding: 16px 16px 0; font-size: 12px; color: #94a3b8; }
.user-box { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.user-info { display: flex; flex-direction: column; line-height: 1.25; }
.user-info strong { color: #e2e8f0; font-size: 13px; }
.user-info span { color: #64748b; font-size: 11px; }
.sidebar-foot #logout { cursor: pointer; color: #cbd5e1; text-decoration: none; display: inline-block; padding: 6px 10px; border: 1px solid #2a3650; border-radius: 7px; }
.sidebar-foot #logout:hover { background: #1e293b; color: #fff; }

/* Main */
main { flex: 1; padding: 30px 38px; max-width: 1320px; min-width: 0; }
.page-title { font-size: 22px; font-weight: 650; letter-spacing: -.01em; margin-bottom: 3px; }
.page-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

/* Cards & grids */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 26px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 23px; font-weight: 650; margin-top: 6px; letter-spacing: -.01em; }
.kpi .value.sm { font-size: 17px; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); }
th, td { text-align: left; padding: 12px 15px; font-size: 13.5px; border-bottom: 1px solid var(--line-2); }
th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #fafbfc; }

/* Badges — sóbrios */
.badge { display: inline-block; padding: 2px 9px; border-radius: 5px; font-size: 11.5px; font-weight: 600; border: 1px solid transparent; }
.b-blue { background: var(--blue-soft); color: var(--blue); }
.b-green { background: var(--green-soft); color: var(--green); }
.b-amber { background: #fbf2e0; color: #9a6b00; }
.b-red { background: var(--red-soft); color: var(--red); }
.b-gray { background: #f0f2f5; color: #5a6472; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }

/* Buttons */
.btn { background: var(--accent); color: #fff; border: none; padding: 9px 15px; border-radius: 7px; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: .12s; }
.btn:hover { background: #243f78; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #fafbfc; border-color: #d3d8e0; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #eccaca; }
.btn.danger:hover { background: var(--red-soft); }

/* Sections */
.section { margin-bottom: 26px; }
.section h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 9px 16px; font-size: 13.5px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Dashboard layout */
.dash-top { display: grid; grid-template-columns: minmax(320px, 1fr) 1.2fr; gap: 18px; margin-bottom: 26px; }
@media (max-width: 920px) { .dash-top { grid-template-columns: 1fr; } }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 14.5px; font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 10.5px; color: var(--muted); font-weight: 600; padding-bottom: 4px; text-transform: uppercase; }
.cal-cell { aspect-ratio: 1; border: 1px solid var(--line-2); border-radius: 7px; padding: 4px 6px; position: relative; cursor: pointer; font-size: 12.5px; transition: .1s; }
.cal-cell:hover { background: var(--accent-soft); border-color: #cdd6e6; }
.cal-cell.empty { border: none; cursor: default; background: none; }
.cal-cell.today { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.cal-count { position: absolute; bottom: 5px; right: 5px; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700; min-width: 17px; height: 17px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* Inbox de tarefas / dia */
.inbox-list { display: flex; flex-direction: column; }
.inbox-item { display: flex; align-items: center; gap: 12px; padding: 11px 6px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.inbox-item:last-child { border-bottom: none; }
.inbox-item:hover { background: #fafbfc; }
.inbox-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.inbox-main { flex: 1; min-width: 0; }
.inbox-title { font-size: 13.5px; font-weight: 600; }
.inbox-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.inbox-date { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Kanban */
.kanban-scroll { overflow-x: auto; padding-bottom: 10px; }
.kanban-board { display: grid; grid-auto-flow: column; grid-auto-columns: 268px; gap: 14px; align-items: start; }
.kcol { background: #eef0f4; border-radius: 10px; padding: 12px; min-height: 120px; }
.kcol.drop-hover { background: #dfe6f3; outline: 2px dashed var(--accent); }
.kcol-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; margin-bottom: 10px; padding: 0 2px; }
.kcount { background: #fff; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; padding: 1px 8px; font-weight: 700; color: var(--ink); }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 9px; cursor: grab; box-shadow: var(--shadow); }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .4; }
.kcard-title { font-weight: 600; font-size: 13.5px; margin-bottom: 8px; }
.kcard .meta { font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.kcard .meta span { display: flex; align-items: center; gap: 5px; }

/* Página do projeto: 3/4 + 1/4 */
.proj-grid { display: grid; grid-template-columns: 3fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 1000px) { .proj-grid { grid-template-columns: 1fr; } }
.side-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.side-card h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 13px 15px; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; }
.side-card h4 button { font-size: 11px; }
.side-row { padding: 11px 15px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.side-row:last-child { border-bottom: none; }
.side-row .r-top { display: flex; justify-content: space-between; gap: 8px; }
.side-row .r-sub { color: var(--muted); font-size: 11.5px; margin-top: 3px; }

/* Histórico de tarefas (central) */
.hist-item { display: flex; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px; margin-bottom: 9px; background: #fff; box-shadow: var(--shadow); }
.hist-item.done { border-left-color: var(--green); background: #fcfdfc; }
.hist-item.pending { border-left-color: var(--amber); }
.hist-item.event { border-left-color: var(--accent); }
.hist-check { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line); flex-shrink: 0; margin-top: 1px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; cursor: pointer; }
.hist-check.on { background: var(--green); border-color: var(--green); }
.hist-main { flex: 1; min-width: 0; }
.hist-title { font-weight: 600; font-size: 14px; }
.hist-title.struck { text-decoration: line-through; color: var(--muted); }
.hist-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 6px; font-size: 12px; color: var(--muted); align-items: center; }
.hist-tags { margin-top: 7px; display: flex; gap: 5px; flex-wrap: wrap; }
.hist-date { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }
.link-chip { font-size: 11px; background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 5px; font-weight: 600; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(13,21,38,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 12px; width: 480px; max-width: 96vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-head h3 { font-size: 16px; font-weight: 650; }
#modal-close { background: none; border: none; font-size: 17px; cursor: pointer; color: var(--muted); }
#modal-form { padding: 22px; display: flex; flex-direction: column; gap: 15px; }
label { font-size: 12.5px; font-weight: 600; color: #404a5a; display: block; margin-bottom: 6px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px; font-family: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 64px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* Form rico de tarefa */
.tf-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.tf-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tf-checks { display: flex; flex-wrap: wrap; gap: 14px 22px; }
.tf-check { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; }
.tf-check input { width: auto; }
.tf-flags { display: flex; flex-wrap: wrap; gap: 12px 20px; padding-top: 6px; border-top: 1px solid var(--line-2); }
.field-label { font-size: 12.5px; font-weight: 600; color: #404a5a; margin-bottom: 6px; }
.anexo-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.anexo-chip { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; background: #f6f7f9; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.anexo-chip a { font-weight: 600; }
.anexo-chip button { background: none; border: none; color: var(--red); cursor: pointer; font-size: 13px; }

/* Misc */
.back { color: var(--accent); cursor: pointer; font-size: 13.5px; margin-bottom: 14px; display: inline-block; font-weight: 500; }
.empty { color: var(--muted); font-size: 13.5px; padding: 16px; text-align: center; }
.etapa-pick { width: auto; padding: 8px 11px; font-weight: 600; }

/* Bars produtividade */
.bar-row { display: flex; align-items: center; gap: 14px; padding: 9px 0; }
.bar-label { width: 170px; font-size: 13.5px; flex-shrink: 0; }
.bar-track { flex: 1; background: #eef0f4; border-radius: 6px; height: 24px; }
.bar-fill { height: 100%; border-radius: 6px; color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; padding: 0 9px; min-width: 24px; box-sizing: border-box; }

/* Timeline (relatório/cliente) */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; margin-bottom: 18px; }
.tl-item::before { content: ''; position: absolute; left: -23px; top: 4px; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.tl-date { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.tl-title { font-weight: 600; margin: 2px 0; }
.tl-desc { font-size: 13px; }

/* Avatares e sinais */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; flex-shrink: 0; line-height: 1; }
.sinal { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.sinal-red { background: #dc2626; box-shadow: 0 0 0 3px #fde2e2; }
.sinal-green { background: #16a34a; box-shadow: 0 0 0 3px #dcf3e3; }
.sinal-yellow { background: #eab308; box-shadow: 0 0 0 3px #fbf2cf; }

/* Tendências / KPI */
.trend { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 5px; vertical-align: middle; margin-left: 6px; }
.trend.up { background: var(--green-soft); color: var(--green); }
.trend.down { background: var(--red-soft); color: var(--red); }
.trend.flat { background: #f0f2f5; color: #5a6472; }
.kpi-foot { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.kpi-alert { border-color: #f0b4b4; background: #fdf5f5; }
.inbox-item.alert { background: #fdf6f6; }
.alert-date { color: var(--red); font-weight: 700; }

/* Kanban full + cards */
#app.full { max-width: none; }
.full-kanban { min-height: calc(100vh - 160px); }
.kcard-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.kcard-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--muted); }
.kcard .meta { flex-direction: row; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #cbd2dc; border-radius: 22px; transition: .2s; cursor: pointer; }
.slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.inline-sel { width: auto; padding: 5px 8px; font-size: 13px; }

/* Configurações */
.set-layout { display: grid; grid-template-columns: 220px 1fr; gap: 22px; align-items: start; }
@media (max-width: 860px) { .set-layout { grid-template-columns: 1fr; } }
.set-menu { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.set-menu a { display: block; padding: 11px 16px; font-size: 13.5px; cursor: pointer; border-bottom: 1px solid var(--line-2); color: var(--ink); }
.set-menu a:last-child { border-bottom: none; }
.set-menu a:hover { background: #fafbfc; }
.set-menu a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; border-left: 3px solid var(--accent); }
.set-panel h3 { font-size: 16px; margin-bottom: 6px; }

/* Integrações */
.integ-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.integ-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.integ-card.on { border-color: #aacbb6; }
.integ-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.integ-desc { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; min-height: 50px; }
code { background: #eef0f4; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* Filtros de relatórios */
.rel-filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.rel-filtros label { font-size: 12px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }
.rel-filtros select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }

/* Lista de seleção do relatório PDF */
.rel-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.rel-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-bottom: 1px solid var(--line-2); cursor: pointer; font-size: 13.5px; }
.rel-row:last-child { border-bottom: none; }
.rel-row:hover { background: #f8fafc; }
.rel-row input { width: 16px; height: 16px; }

/* Print do relatório */
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; padding: 24px; }
  #print-area h1 { font-size: 22px; margin-bottom: 4px; }
  #print-area .sub { color: #555; font-size: 13px; }
  #print-area hr { margin: 16px 0; border: none; border-top: 1px solid #ccc; }
  #print-area .timeline { padding-left: 24px; }
  #print-area .footer { margin-top: 30px; font-size: 11px; color: #888; }
  #print-area .timbrado { max-width: 100%; max-height: 140px; display: block; margin-bottom: 14px; }
}
