:root {
  /* Paleta CS Marketing: azul royal (primária), branco (base), laranja clarinho (destaque) */
  --bg: #F5F6FC;
  --card: #FFFFFF;
  --border: #E1E4F5;
  --text: #1B2140;
  --text-muted: #6B7099;

  --primary: #2A3FDB;       /* azul royal */
  --primary-dark: #1E2FB0;  /* azul royal, tom escuro (hover) */
  --primary-tint: #E9EBFB;  /* azul royal bem claro, pra fundos suaves */

  --accent: #FFB870;        /* laranja clarinho, uso pontual de destaque */
  --accent-dark: #C97A1E;   /* laranja mais escuro, pra texto sobre fundo claro */
  --accent-tint: #FFF1E1;   /* laranja quase branco, pra fundos suaves */

  --green: #16A085;
  --orange: #E67E22;
  --red: #E74C3C;
  --yellow: #F4B400;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- LOGIN ---------- */
.login-body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
}
.login-card {
  background: var(--card);
  padding: 40px;
  border-radius: 16px;
  width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-logo { width: 88px; height: auto; margin-bottom: 18px; }
.login-title { margin: 0 0 4px; font-size: 22px; text-align: center; }
.login-subtitle { margin: 0 0 24px; color: var(--text-muted); font-size: 13px; text-align: center; }
.login-error {
  background: #FDECEA; color: var(--red); padding: 10px 12px;
  border-radius: 8px; font-size: 13px; margin-bottom: 16px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.login-error { width: 100%; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.login-form input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.login-form button {
  margin-top: 8px; background: var(--primary); color: #fff; border: none;
  padding: 11px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.login-form button:hover { background: var(--primary-dark); }

/* ---------- TOPBAR / TOOLBAR ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-logo { height: 32px; width: auto; }
.brand { font-weight: 700; font-size: 16px; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-muted); }
.btn-link { color: var(--primary); text-decoration: none; font-weight: 600; }

.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--border);
}
.btn-primary {
  background: var(--primary); color: #fff; border: none; padding: 9px 16px;
  border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-dark); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.filters select, .filters input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: #fff;
}
#filterSearch { min-width: 180px; flex: 1; }

/* ---------- TASK LIST ---------- */
.task-list-root { padding: 16px 20px 60px; max-width: 1400px; margin: 0 auto; }
.loading, .empty { color: var(--text-muted); padding: 40px; text-align: center; }

.group { margin-bottom: 20px; }
.group-header {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px; cursor: pointer;
  user-select: none;
}
.group-header .chev { transition: transform .15s; font-size: 11px; color: var(--text-muted); }
.group.collapsed .chev { transform: rotate(-90deg); }
.group-title { font-weight: 700; font-size: 13px; }
.group-count { color: var(--text-muted); font-size: 12px; }
.group-overdue .group-title { color: var(--red); }

.group-table { display: block; }
.group.collapsed .group-table { display: none; }

.task-row {
  display: grid;
  grid-template-columns: 34px 160px 1.6fr 130px 120px 90px 90px 110px 90px 34px;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 13px;
}
.task-row.is-overdue { border-left: 3px solid var(--red); }
.task-row.is-done { opacity: 0.6; }

.col-play button {
  width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 11px;
  background: var(--border); color: var(--text);
}
.col-play button.running { background: var(--green); color: #fff; }
.col-play button.done { background: var(--primary); color: #fff; }

.col-client { display: flex; align-items: center; gap: 6px; overflow: hidden; }
.client-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.client-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: var(--text-muted); }

.col-title { min-width: 0; }
.task-title {
  border: none; background: transparent; font-size: 13px; font-weight: 500; width: 100%;
  padding: 2px 4px; border-radius: 4px; color: var(--text); cursor: text;
}
.task-title:hover, .task-title:focus { background: #F0F1FB; outline: none; }
.task-title.done { text-decoration: line-through; color: var(--text-muted); }

.col-stage select, .col-assignee select {
  width: 100%; border: 1px solid transparent; background: transparent; font-size: 12px; padding: 4px;
  border-radius: 6px; color: var(--text-muted);
}
.col-stage select:hover, .col-assignee select:hover { border-color: var(--border); background: #fff; }

.col-date input {
  width: 100%; border: 1px solid transparent; background: transparent; font-size: 12px; padding: 3px;
  border-radius: 6px; color: var(--text-muted);
}
.col-date input:hover { border-color: var(--border); background: #fff; }
.col-date.overdue input { color: var(--red); font-weight: 600; }

.col-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.col-time.running { color: var(--green); font-weight: 600; }

.priority-tag {
  font-size: 11px; font-weight: 700; padding: 3px 6px; border-radius: 12px; text-align: center;
  white-space: nowrap; border: none; width: 100%; cursor: pointer; appearance: none;
  -webkit-appearance: none;
}
.priority-tag:disabled { cursor: default; opacity: .8; }
.priority-baixa { background: #EAF6EF; color: var(--green); }
.priority-media { background: #FFF6E0; color: #B98900; }
.priority-alta { background: var(--accent-tint); color: var(--accent-dark); }
.priority-urgente { background: #FDECEA; color: var(--red); }

.col-open { color: var(--text-muted); cursor: pointer; text-align: center; }
.col-open:hover { color: var(--primary); }

.task-row-head {
  display: grid;
  grid-template-columns: 34px 160px 1.6fr 130px 120px 90px 90px 110px 90px 34px;
  gap: 8px; padding: 0 10px 6px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .03em; color: var(--text-muted); font-weight: 700;
}

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,20,30,0.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  z-index: 1000; overflow-y: auto;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 640px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 16px; }
.btn-icon { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px 22px; max-height: 75vh; overflow-y: auto; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.form-field input, .form-field select, .form-field textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit;
}
.form-field textarea { resize: vertical; min-height: 70px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.btn-secondary {
  background: #fff; border: 1px solid var(--border); padding: 9px 16px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text);
}
.btn-danger { color: var(--red); border-color: #F5C6C2; }

.detail-section { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 16px; }
.detail-section h3 { font-size: 13px; margin: 0 0 10px; }
.comment-item, .log-item, .attachment-item {
  padding: 8px 0; border-bottom: 1px solid #F0F1F4; font-size: 12.5px;
}
.comment-item:last-child, .log-item:last-child, .attachment-item:last-child { border-bottom: none; }
.comment-meta { color: var(--text-muted); font-size: 11px; margin-bottom: 2px; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.attachment-item a { color: var(--primary); text-decoration: none; }
.attachment-item a:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .task-row, .task-row-head { grid-template-columns: 30px 1fr 90px 34px; }
  .col-stage, .col-assignee, .col-date, .col-time { display: none; }
}
