:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #e3e8ef;
  --line-2: #cfd7e3;
  --text: #1c2433;
  --muted: #667085;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #059669;
  --info: #0891b2;
  --st-por_planear: #94a3b8;
  --st-planeada: #2563eb;
  --st-em_curso: #d97706;
  --st-concluida: #059669;
  --hatch: repeating-linear-gradient(135deg, #eef1f6 0 6px, #e4e9f1 6px 12px);
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); display: flex; flex-direction: column; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.hidden, [hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 54px;
  background: #0f172a; color: #e2e8f0; position: sticky; top: 0; z-index: 50; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: .2px; white-space: nowrap; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, #3b82f6, #22d3ee); display: inline-block; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs a {
  color: #94a3b8; text-decoration: none; padding: 7px 11px; border-radius: 7px; white-space: nowrap; font-weight: 500;
}
.tabs a:hover { color: #fff; background: rgba(255,255,255,.07); }
.tabs a.active { color: #fff; background: rgba(59,130,246,.35); }
.tabs-sep { width: 1px; background: #334155; margin: 8px 6px; flex-shrink: 0; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.top-actions .btn:not(.primary) { background: #1e293b; color: #e2e8f0; border-color: #334155; }
.top-actions .btn:not(.primary):hover { background: #273449; }
.bell { position: relative; background: none; border: 0; color: #cbd5e1; cursor: pointer; padding: 6px; border-radius: 8px; }
.bell:hover { background: rgba(255,255,255,.08); color: #fff; }
.bell.ring { animation: ring 1s ease-in-out 3; color: #fbbf24; }
@keyframes ring { 0%,100% { transform: rotate(0) } 20% { transform: rotate(15deg) } 40% { transform: rotate(-12deg) } 60% { transform: rotate(8deg) } 80% { transform: rotate(-4deg) } }
.badge {
  position: absolute; top: 0; right: 0; background: var(--danger); color: #fff; border-radius: 10px;
  font-size: 11px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 4px; font-weight: 700;
}

/* ---------- alerts panel ---------- */
.alerts-panel {
  position: fixed; right: 12px; top: 60px; width: 420px; max-height: 70vh; overflow: auto; z-index: 60;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.alerts-panel header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.alert-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.alert-item:hover { background: var(--panel-2); }
.alert-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.alert-item .t { font-weight: 600; }
.sev-danger .dot { background: var(--danger); }
.sev-warn .dot { background: var(--warn); }
.sev-info .dot { background: var(--info); }
.sev-alarm .dot { background: #7c3aed; }

/* ---------- layout ---------- */
main { flex: 1; min-height: 0; padding: 16px; overflow: auto; }
main.full { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px;
}
main.full .toolbar { padding: 10px 16px; margin: 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.toolbar .title { font-size: 18px; font-weight: 600; margin-right: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.card > .bd { padding: 12px 14px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); cursor: default; }
.kpi[data-go] { cursor: pointer; }
.kpi[data-go]:hover { border-color: var(--line-2); }
.kpi .v { font-size: 26px; font-weight: 700; line-height: 1.2; }
.kpi .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.kpi.danger .v { color: var(--danger); }
.kpi.warn .v { color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--panel);
  color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); border-color: #b8c2d1; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fef2f2; border-color: #fca5a5; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn.sm { padding: 5px 9px; font-size: 13px; }
.btn.icon { padding: 5px 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 6px 11px; cursor: pointer; font: inherit; color: var(--muted); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: #e8efff; color: var(--primary); font-weight: 600; }
input, select, textarea {
  font: inherit; color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 9px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.25); border-color: var(--primary); }
input[readonly] { background: var(--panel-2); color: var(--muted); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
input[type=color] { padding: 2px; height: 34px; width: 48px; }
label.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.form { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px 14px; }
.form .f { display: flex; flex-direction: column; gap: 5px; grid-column: span 6; position: relative; }
.form .f.c12 { grid-column: span 12; } .form .f.c4 { grid-column: span 4; } .form .f.c3 { grid-column: span 3; } .form .f.c8 { grid-column: span 8; }
.form .f > label { font-size: 12px; font-weight: 600; color: #475467; }
.form .hint { font-size: 12px; color: var(--muted); }
.form .hint b { color: var(--text); }
.form hr { grid-column: span 12; border: 0; border-top: 1px dashed var(--line-2); margin: 2px 0; }
.big-ro { font-size: 18px; font-weight: 700; color: var(--text) !important; }
.days { display: flex; gap: 4px; }
.days label { border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 8px; cursor: pointer; user-select: none; }
.days input { display: none; }
.days label:has(input:checked) { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- autocomplete ---------- */
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30; margin-top: 2px; background: #fff; border: 1px solid var(--line-2);
  border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 280px; overflow: auto;
}
.ac-item { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ac-item:last-child { border-bottom: 0; }
.ac-item.on, .ac-item:hover { background: #eef3ff; }
.ac-item .c { font-weight: 600; }
.ac-item .d { color: var(--muted); font-size: 12px; }
.ac-new { color: var(--primary); font-style: italic; }

/* ---------- tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; background: var(--panel); }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); background: var(--panel-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.tbl tbody tr:hover { background: #fafbfd; }
.tbl tr.clickable { cursor: pointer; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-por_planear { background: #f1f5f9; color: #475569; }
.st-planeada { background: #dbeafe; color: #1e40af; }
.st-em_curso { background: #fef3c7; color: #92400e; }
.st-concluida { background: #d1fae5; color: #065f46; }
.flag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; margin-left: 4px; white-space: nowrap; }
.flag.late { background: #fee2e2; color: #b91c1c; }
.flag.push { background: #e0f2fe; color: #075985; }
.flag.over { background: #ede9fe; color: #5b21b6; }
.flag.ext { background: #ffedd5; color: #9a3412; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow: auto; }
.modal { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow-lg); width: 640px; max-width: 100%; }
.modal.wide { width: 860px; }
.modal.narrow { width: 420px; }
.modal > header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 10px; }
.modal > header h3 { flex: 1; }
.modal > .body { padding: 16px 18px; }
.modal > footer { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 12px 12px; }
.modal .err { color: var(--danger); font-weight: 500; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 560px; animation: tin .2s ease-out; }
.toast.err { background: #b91c1c; }
.toast.warn { background: #b45309; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- context menu ---------- */
.ctx { position: fixed; z-index: 150; background: #fff; border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 4px; min-width: 220px; }
.ctx button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
.ctx button:hover { background: #eef3ff; }
.ctx .sep { height: 1px; background: var(--line); margin: 4px 0; }
.ctx .hd { font-size: 12px; color: var(--muted); padding: 6px 10px 2px; }

/* ---------- Kanban ---------- */
.kb-wrap { flex: 1; overflow: auto; }
.kb { display: grid; min-width: max-content; }
.kb-colhead {
  position: sticky; top: 0; z-index: 4; background: var(--panel); border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line);
  padding: 8px 10px; font-weight: 600; min-height: 50px;
}
.kb-colhead .sub { font-size: 11px; color: var(--muted); font-weight: 500; }
.kb-colhead.today { background: #eff6ff; box-shadow: inset 0 -3px 0 var(--primary); }
.kb-colhead.weekend { background: #f8fafc; }
.kb-colhead.holiday { background: #fef2f2; }
.kb-colhead.holiday .sub { color: var(--danger); }
.kb-colhead.special { background: #f1f5f9; }
.kb-corner { position: sticky; left: 0; top: 0; z-index: 6; background: var(--panel); border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); }
.kb-lane {
  position: sticky; left: 0; z-index: 3; background: var(--panel); border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line);
  padding: 10px; font-weight: 600; writing-mode: horizontal-tb;
}
.kb-lane .sub { font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.kb-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; min-height: 90px; display: flex; flex-direction: column; gap: 6px; transition: background .1s; }
.kb-cell.weekend { background: #fafbfc; }
.kb-cell.holiday { background: repeating-linear-gradient(135deg, #fff5f5 0 8px, #fdecec 8px 16px); }
.kb-cell.down { background: repeating-linear-gradient(135deg, #fafafa 0 8px, #f0f0f0 8px 16px); }
.kb-cell.special { background: #f6f8fb; }
.kb-cell.drop { background: #dbeafe !important; outline: 2px dashed var(--primary); outline-offset: -3px; }
.kb-cell .load { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kb-cell .load .bar { flex: 1; height: 4px; background: #e5e7eb; border-radius: 2px; overflow: hidden; }
.kb-cell .load .bar i { display: block; height: 100%; background: var(--ok); }
.kb-cell .load.over .bar i { background: var(--danger); }
.kb-card {
  background: #fff; border: 1px solid var(--line-2); border-left: 4px solid var(--st-planeada); border-radius: 8px; padding: 7px 8px;
  box-shadow: var(--shadow); cursor: grab; font-size: 13px; position: relative;
}
.kb-card:hover { border-color: #9fb0c8; }
.kb-card.dragging { opacity: .4; }
.kb-card .l1 { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.kb-card .l1 .eq { margin-left: auto; font-weight: 500; font-size: 11px; color: var(--muted); }
.kb-card .l2 { color: #344054; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px; }
.kb-card .l3 { display: flex; gap: 8px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.kb-card .menu { position: absolute; top: 3px; right: 3px; opacity: 0; }
.kb-card:hover .menu { opacity: 1; }
.kb-card.task { border-left-color: #7c3aed; background: #fbfaff; }
.kb-card.task.done { opacity: .6; text-decoration: line-through; }
.kb-card.cont { cursor: default; background: repeating-linear-gradient(135deg, #fff 0 6px, #f6f7f9 6px 12px); box-shadow: none; padding: 4px 8px; font-size: 12px; color: var(--muted); }
.kb-card.is-late { box-shadow: 0 0 0 2px #fecaca; }
.kb-card.st-em_curso { border-left-color: var(--st-em_curso); }
.kb-card.st-concluida { border-left-color: var(--st-concluida); opacity: .7; }
.kb-card.st-por_planear { border-left-color: var(--st-por_planear); }

/* ---------- Gantt ---------- */
.gt-wrap { flex: 1; overflow: auto; position: relative; background: var(--panel); }
.gt { position: relative; }
.gt-head { position: sticky; top: 0; z-index: 8; display: flex; background: var(--panel); border-bottom: 1px solid var(--line-2); }
.gt-corner { position: sticky; left: 0; z-index: 9; background: var(--panel); border-right: 1px solid var(--line-2); flex-shrink: 0; display: flex; align-items: flex-end; padding: 6px 10px; font-size: 12px; color: var(--muted); }
.gt-scale { position: relative; flex-shrink: 0; }
.gt-day { position: absolute; top: 0; height: 26px; border-right: 1px solid var(--line-2); padding: 4px 6px; font-weight: 600; font-size: 12px; overflow: hidden; white-space: nowrap; cursor: pointer; }
.gt-day:hover { background: #f1f5f9; }
.gt-day span { position: sticky; left: 206px; }
.gt-day.today { color: var(--primary); background: #eff6ff; }
.gt-day.weekend { color: var(--muted); }
.gt-day.holiday { color: var(--danger); background: #fef2f2; }
.gt-hour { position: absolute; top: 26px; height: 20px; border-left: 1px solid var(--line); font-size: 10px; color: var(--muted); padding: 3px 3px; white-space: nowrap; }
.gt-row { display: flex; border-bottom: 1px solid var(--line); position: relative; }
.gt-row:hover .gt-label { background: #f8fafc; }
.gt-label {
  position: sticky; left: 0; z-index: 6; background: var(--panel); border-right: 1px solid var(--line-2); flex-shrink: 0; padding: 6px 10px;
  display: flex; flex-direction: column; justify-content: center; overflow: hidden;
}
.gt-label .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gt-label .s { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gt-track { position: relative; flex-shrink: 0; background: var(--hatch); overflow: hidden; }
.gt-bg { position: absolute; top: 0; bottom: 0; }
.gt-bg.work { background: #fff; }
.gt-bg.extra { background: #fff4e5; box-shadow: inset 0 2px 0 #fb923c; }
.gt-bg.lunch { background: repeating-linear-gradient(90deg, #fef9c3 0 3px, #fefce8 3px 6px); }
.gt-bg.down { background: repeating-linear-gradient(135deg, #fee2e2 0 5px, #fecaca 5px 10px); opacity: .85; }
.gt-bg.down.ferias { background: repeating-linear-gradient(135deg, #e0e7ff 0 5px, #c7d2fe 5px 10px); }
.gt-bg.down.paragem { background: repeating-linear-gradient(135deg, #e5e7eb 0 5px, #d1d5db 5px 10px); }
.gt-vline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line-2); pointer-events: none; }
.gt-vline.h { background: #eef1f5; }
.gt-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 5; pointer-events: none; }
.gt-now::before { content: ''; position: absolute; top: -1px; left: -4px; border: 5px solid transparent; border-top-color: var(--danger); }
.gt-bar {
  position: absolute; height: 26px; border-radius: 6px; cursor: grab; z-index: 3; touch-action: none;
  background: color-mix(in srgb, var(--c) 18%, transparent); border: 1px dashed color-mix(in srgb, var(--c) 55%, transparent);
}
.gt-bar .seg { position: absolute; top: 0; bottom: 0; background: var(--c); border-radius: 4px; }
.gt-bar .seg.extra { background: repeating-linear-gradient(135deg, var(--c) 0 5px, #f97316 5px 9px); }
.gt-bar .lbl {
  position: absolute; left: 6px; top: 0; bottom: 0; right: 0; display: flex; align-items: center; color: #fff; font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-shadow: 0 1px 2px rgba(0,0,0,.45); pointer-events: none; gap: 6px;
}
.gt-bar.narrow .lbl { color: var(--text); text-shadow: none; left: calc(100% + 4px); overflow: visible; }
.gt-bar.dragging { opacity: .85; cursor: grabbing; z-index: 20; box-shadow: var(--shadow-lg); }
.gt-bar.sel { outline: 2px solid #0f172a; outline-offset: 1px; }
.gt-bar.st-concluida { opacity: .55; cursor: default; }
.gt-bar.st-em_curso .seg { box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.gt-bar.is-late { box-shadow: 0 0 0 2px var(--danger); }
.gt-bar.task { height: 14px; border-radius: 7px; background: #7c3aed; border: 0; }
.gt-bar.task .lbl { left: calc(100% + 4px); color: #5b21b6; text-shadow: none; font-size: 11px; overflow: visible; }
.gt-bar.task.done { background: #a78bfa; opacity: .6; }
.gt-due { position: absolute; width: 0; height: 0; z-index: 4; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid var(--danger); pointer-events: none; }
.gt-ghost { position: fixed; z-index: 300; background: #0f172a; color: #fff; padding: 5px 9px; border-radius: 6px; font-size: 12px; pointer-events: none; white-space: nowrap; }
.gt-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); align-items: center; }
.gt-legend i { display: inline-block; width: 16px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 4px; border: 1px solid var(--line-2); }

/* ---------- Calendário ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.cal > div { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-height: 96px; padding: 4px 6px; background: #fff; }
.cal .dh { min-height: 0; background: var(--panel-2); font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; padding: 6px; }
.cal .out { background: #fafbfc; color: #b0b8c4; }
.cal .today .dn { background: var(--primary); color: #fff; border-radius: 10px; padding: 0 6px; }
.cal .dn { font-weight: 600; font-size: 12px; display: inline-block; margin-bottom: 3px; }
.cal .ev { font-size: 11px; border-radius: 4px; padding: 2px 5px; margin-bottom: 2px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.feriado { background: #fee2e2; color: #991b1b; }
.ev.ferias { background: #e0e7ff; color: #3730a3; }
.ev.paragem { background: #e5e7eb; color: #374151; }
.ev.extra { background: #ffedd5; color: #9a3412; }

/* ---------- Painel ---------- */
.occ { display: flex; flex-direction: column; gap: 10px; }
.occ-row { display: grid; grid-template-columns: 160px 1fr 110px; gap: 10px; align-items: center; }
.occ-bar { height: 12px; background: #eef2f7; border-radius: 6px; overflow: hidden; position: relative; }
.occ-bar i { display: block; height: 100%; border-radius: 6px; }
.day-list { display: flex; flex-direction: column; gap: 6px; }
.day-item { display: flex; gap: 10px; align-items: center; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff; }
.day-item:hover { border-color: var(--line-2); background: var(--panel-2); }
.day-item .tm { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 92px; font-size: 13px; }
.day-item .bar { width: 4px; align-self: stretch; border-radius: 2px; }
.eq-block { margin-bottom: 12px; }
.eq-block > .h { font-weight: 600; font-size: 13px; margin-bottom: 6px; display: flex; align-items: center; }

/* ---------- tarefas ---------- */
.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fff; }
.task-row:hover { background: #fafbfd; }
.task-row .tx { flex: 1; cursor: pointer; }
.task-row .tx .m { font-size: 12px; color: var(--muted); margin-top: 2px; }
.task-row.done .tx > div:first-child { text-decoration: line-through; color: var(--muted); }
.group-h { padding: 8px 12px; background: var(--panel-2); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); border-bottom: 1px solid var(--line); }
.group-h.danger { color: var(--danger); }
.prio-1 { color: var(--danger); font-weight: 700; }

.eq-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.eq-card { border-top: 4px solid var(--c, #3b82f6); }
.eq-card.inactive { opacity: .6; }
.shift-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 12px; font-size: 12px; background: #f1f5f9; margin: 2px 4px 2px 0; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .form .f { grid-column: span 12 !important; }
  .g2 { grid-template-columns: 1fr; }
  .alerts-panel { width: calc(100% - 24px); }
}

@media print {
  .topbar, .toolbar, #toasts { display: none !important; }
  main { overflow: visible; }
}

/* ---------- login ---------- */
.login-page { align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a, #1e3a8a); min-height: 100%; padding: 16px; }
.login-card { width: 400px; max-width: 100%; padding: 28px; }
.login-card h2 { margin: 18px 0 6px; }
.login-brand { color: var(--text); font-size: 20px; }
.login-card .form { margin-top: 14px; }
.login-card .btn.primary { width: 100%; padding: 10px; }
.err { color: var(--danger); font-weight: 500; }

/* ---------- utilizador ---------- */
.user-chip { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: #e2e8f0; cursor: pointer; padding: 4px 8px; border-radius: 8px; font: inherit; }
.user-chip:hover { background: rgba(255,255,255,.08); }
.user-chip .un { display: flex; flex-direction: column; line-height: 1.1; text-align: left; font-size: 13px; font-weight: 600; }
.user-chip .un small { color: #94a3b8; font-weight: 400; font-size: 11px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #06b6d4); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.avatar.sm { width: 22px; height: 22px; font-size: 11px; vertical-align: middle; }
.role-pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.role-admin { background: #fee2e2; color: #991b1b; }
.role-editor { background: #dbeafe; color: #1e40af; }
.role-viewer { background: #f1f5f9; color: #475569; }
.perm-tbl td.c, .perm-tbl th.c { text-align: center; width: 90px; }
.perm-tbl .group-h { padding: 6px 10px; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 22px; transition: .15s; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid rgba(37,99,235,.4); }

/* ---------- categorias de tarefas ---------- */
.cat-chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; color: var(--cc); background: color-mix(in srgb, var(--cc) 14%, white); border: 1px solid color-mix(in srgb, var(--cc) 30%, white); vertical-align: middle; }
.cat-filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.cat-btn { border: 1px solid var(--line-2); background: #fff; border-radius: 16px; padding: 4px 11px; cursor: pointer; font: inherit; font-size: 13px; color: var(--text); box-shadow: inset 3px 0 0 var(--cc); }
.cat-btn span { color: var(--muted); font-size: 11px; margin-left: 2px; }
.cat-btn.on { background: color-mix(in srgb, var(--cc) 14%, white); border-color: var(--cc); font-weight: 600; }
.task-row .tx .d { font-size: 12px; color: #475467; margin-top: 2px; }

/* ---------- setup ---------- */
.gt-bar .seg.setup { background: repeating-linear-gradient(135deg, #475569 0 4px, #94a3b8 4px 8px); border-radius: 4px 0 0 4px; }
.gt-legend i.lg-setup { background: repeating-linear-gradient(135deg, #475569 0 3px, #94a3b8 3px 6px); }

/* ---------- prioridade (reordenar) ---------- */
.kb-card.drop-before { box-shadow: 0 -4px 0 var(--primary); }
.kb-card.drop-after { box-shadow: 0 4px 0 var(--primary); }
.gt-row.drop-before { box-shadow: inset 0 3px 0 var(--primary); }
.gt-row.drop-after { box-shadow: inset 0 -3px 0 var(--primary); }
.gt-row.dragging-row { opacity: .45; }
.gt-grip { cursor: grab; color: var(--muted); margin-right: 6px; letter-spacing: -2px; user-select: none; }
.gt-grip:hover { color: var(--primary); }
