:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --panel: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --success: #10b981;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 12px;
  background: var(--primary);
  color: #fff;
  transition: opacity .12s;
}
button:hover { opacity: .9; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
button.danger { background: var(--danger); }
button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 4px 8px;
}
button.ghost:hover { background: #e2e8f0; color: var(--text); }

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  background: #fff;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }

/* Layout */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar .logo { font-weight: 700; color: var(--primary); font-size: 17px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}
.topbar nav a.active, .topbar nav a:hover { background: #f1f5f9; color: var(--text); }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.topbar-user:hover { background: #f1f5f9; }

.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 12px;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.lg { width: 48px; height: 48px; font-size: 18px; }
.foto-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  width: 360px;
  box-shadow: 0 10px 25px rgba(0,0,0,.15);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.login-card .field { margin-bottom: 14px; }
.login-card button { width: 100%; padding: 10px; }
.login-card .err {
  background: #fee2e2; color: var(--danger);
  padding: 8px 10px; border-radius: 6px;
  font-size: 13px; margin-bottom: 12px;
}

/* Kanban */
.kanban-wrap {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px;
}
.kanban {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: calc(100vh - 88px);
}
.col {
  background: #e2e8f0;
  border-radius: 8px;
  padding: 8px;
  width: 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 88px);
}
.col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 8px;
  font-weight: 600;
  font-size: 13px;
}
.col-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.col-count {
  background: rgba(0,0,0,.08);
  color: var(--muted);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}
.col-title { flex: 1; }
.col-title.editable { cursor: text; border-radius: 4px; padding: 2px 4px; margin: -2px -4px; }
.col-title.editable:hover { background: rgba(0,0,0,.06); }
.col-title-input {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
  padding: 2px 4px;
  margin: -2px -4px;
  height: auto;
  border-color: var(--primary);
}
.col-del {
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  color: var(--muted);
  opacity: 0;
}
.col:hover .col-del { opacity: 1; }
.col-del:hover { color: var(--danger); background: rgba(220,38,38,.1); }
.col.col-add {
  background: rgba(0,0,0,.04);
  border: 2px dashed var(--border);
}
.col.col-add:hover { background: rgba(37,99,235,.06); border-color: var(--primary); }
.col-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 2px 4px;
  min-height: 30px;
}
.col-body.dragover { background: rgba(37,99,235,.12); border-radius: 6px; }
.add-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  text-align: left;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
}
.add-btn:hover { background: rgba(0,0,0,.05); color: var(--text); }

.card {
  background: #fff;
  border-radius: 6px;
  padding: 8px 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  cursor: pointer;
  border: 1px solid transparent;
}
.card:hover { border-color: var(--primary); }
.card.dragging { opacity: .4; }
.card.concluido { opacity: .65; }
.card.concluido .card-title { text-decoration: line-through; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}
.card-title { font-size: 13px; font-weight: 500; line-height: 1.35; word-break: break-word; }
.card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}
.card-prazo {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #f1f5f9;
}
.card-prazo.atrasado { background: #fee2e2; color: var(--danger); font-weight: 600; }
.card-prazo.hoje { background: #fef3c7; color: #92400e; font-weight: 600; }
.card-comments { margin-left: auto; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-header h2 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-picker .tag {
  cursor: pointer;
  padding: 3px 9px;
  font-size: 11px;
  opacity: .45;
  border: 1px solid transparent;
}
.tag-picker .tag.on { opacity: 1; }

.anexos-list { margin-bottom: 8px; }
.anexo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 4px;
  background: #fafbfc;
}
.anexo-icon { font-size: 15px; flex-shrink: 0; }
.anexo-nome {
  flex: 1;
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
  font-size: 13px;
}
.anexo-nome:hover { text-decoration: underline; }
.anexo-meta { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.anexo-del {
  font-size: 16px;
  padding: 0 6px;
  line-height: 1;
  color: var(--muted);
}
.anexo-del:hover { color: var(--danger); background: rgba(220,38,38,.1); }
.anexos-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.anexo-link-form {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: #f8fafc;
  padding: 8px;
  border-radius: 6px;
}
.anexo-link-form input { flex: 1; min-width: 180px; }

.timeline {
  border-left: 2px solid var(--border);
  padding-left: 12px;
  margin-left: 4px;
}
.timeline-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 0;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -19px;
  top: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-text { font-size: 13px; line-height: 1.4; word-break: break-word; }
.timeline-text strong { font-weight: 600; }
.timeline-time { font-size: 11px; color: var(--muted); margin-top: 1px; }

.comment {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.comment-bubble {
  background: #f1f5f9;
  border-radius: 8px;
  padding: 6px 10px;
  flex: 1;
  font-size: 13px;
}
.comment-meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; display: flex; gap: 6px; align-items: center; }
.comment-meta strong { color: var(--text); font-weight: 600; }
.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}
.date-chip:hover { background: #fde68a; }

.mention-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  margin: 0 1px;
}

.mention-popover {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 60px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
}
.mention-item.active, .mention-item:hover { background: #eff6ff; }

/* Admin */
.admin-wrap { padding: 24px; max-width: 900px; margin: 0 auto; }
.admin-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.admin-tabs button {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  border-radius: 0;
  font-weight: 500;
}
.admin-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.admin-panel h3 { margin: 0 0 14px; font-size: 15px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #f8fafc; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.form-inline { display: flex; gap: 8px; align-items: end; margin-bottom: 16px; flex-wrap: wrap; }
.form-inline .field { margin: 0; flex: 1; min-width: 120px; }
.color-input { width: 38px; height: 36px; padding: 2px; cursor: pointer; }
.ical-row { display: flex; gap: 6px; align-items: center; }
.ical-row input { font-family: ui-monospace, monospace; font-size: 12px; }
.ical-row button { white-space: nowrap; flex-shrink: 0; }

.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: 6px;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  font-size: 13px;
}
.toast.error { background: var(--danger); }

.empty { color: var(--muted); padding: 24px; text-align: center; font-size: 13px; }

/* Dashboard */
.dash-wrap { padding: 16px; max-width: 1280px; margin: 0 auto; }
.dash-header { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.dash-tabs { display: flex; gap: 4px; }
.dash-tabs button { font-size: 13px; }
.dash-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.dash-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dash-card-head { display: flex; align-items: center; gap: 10px; }
.dash-section { border-top: 1px solid var(--border); padding-top: 10px; }
.dash-section:first-of-type { border-top: 0; padding-top: 0; }
.dash-section-title { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .05em; }
.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.dash-stat {
  background: #f8fafc;
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
}
.dash-stat.accent-green { background: #ecfdf5; }
.dash-stat.accent-green .dash-stat-num { color: #059669; }
.dash-stat.accent-red { background: #fef2f2; }
.dash-stat.accent-red .dash-stat-num { color: #dc2626; }
.dash-stat-num { font-size: 16px; font-weight: 700; color: var(--text); }
.dash-stat-lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 2px; }
.progress-wrap { font-size: 11px; color: var(--muted); }
.progress-bar { background: #e2e8f0; border-radius: 999px; height: 6px; overflow: hidden; margin-bottom: 3px; }
.progress-fill { background: var(--primary); height: 100%; transition: width .3s; }
.progress-label { text-align: right; font-size: 11px; }

/* Calendário */
.cal-wrap { padding: 16px; }
.cal-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.cal-header h2 { font-size: 18px; }
.cal-header h2:hover { color: var(--primary); }
.cal-picker {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
  border: none;
  padding: 0;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.cal-dow {
  background: #f8fafc;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 6px;
}
.cal-day {
  background: #fff;
  min-height: 110px;
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: default;
  position: relative;
}
.cal-day.fora { background: #f8fafc; color: #cbd5e1; }
.cal-day.fora .cal-day-num { color: #cbd5e1; }
.cal-day.hoje { background: #eff6ff; }
.cal-day.hoje .cal-day-num { color: var(--primary); font-weight: 700; }
.cal-day-num {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.cal-day .cal-add {
  font-size: 14px;
  padding: 0 5px;
  line-height: 1;
  opacity: 0;
  transition: opacity .12s;
}
.cal-day:hover .cal-add { opacity: 1; }
.cal-day-tasks {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.cal-task {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  font-weight: 500;
}
.cal-task:hover { filter: brightness(1.1); }
.cal-task.concluido { opacity: .55; text-decoration: line-through; }
.cal-more {
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
  padding: 1px 4px;
}
.cal-more:hover { color: var(--primary); }
