:root {
  color-scheme: dark;
  --bg: #050507;
  --panel: #121214;
  --panel-strong: #1a1a1d;
  --sidebar: #0d0d0f;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --ink: #ededeb;
  --muted: rgba(237, 237, 235, 0.58);
  --faint: rgba(237, 237, 235, 0.34);
  --gold: #c9a24f;
  --gold-strong: #dfb66a;
  --gold-soft: rgba(201, 162, 79, 0.14);
  --green: #6fc784;
  --blue: #6fb1ff;
  --red: #d97c7c;
  --amber: #f5b450;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.task-shell {
  display: grid;
  grid-template-columns: minmax(292px, 356px) minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0 4px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(201, 162, 79, 0.28);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(201, 162, 79, 0.16), rgba(198, 95, 37, 0.12)), var(--panel);
  color: var(--gold);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.28rem, 1rem + 1vw, 1.85rem);
  line-height: 1.05;
}

h2 {
  font-size: clamp(1.45rem, 1.2rem + 1vw, 2.05rem);
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1.05rem;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel,
.view-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel {
  padding: 16px;
}

.section-head,
.list-head,
.workspace-head,
.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-head {
  margin-bottom: 14px;
}

.sync-status,
.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.sync-status.error {
  border-color: rgba(217, 124, 124, 0.35);
  color: var(--red);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151518;
}

.stat span {
  display: block;
  font-size: 1.55rem;
  font-weight: 850;
  line-height: 1;
}

.stat small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.stat.danger span {
  color: var(--red);
}

.scope-toggle {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f0f11;
}

.scope-button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.scope-button.active {
  background: var(--gold);
  color: #121214;
}

.field-label {
  display: block;
  margin: 13px 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 7px;
  background: #101012;
  color: var(--ink);
  outline: none;
}

input,
select {
  padding: 0 11px;
}

textarea {
  padding: 10px 11px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 79, 0.14);
}

.primary-button,
.text-button,
.danger-button,
.icon-button,
.status-button,
.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 7px;
  font-weight: 850;
  letter-spacing: 0;
}

.primary-button {
  width: 100%;
  margin-top: 16px;
  border: 1px solid var(--gold-strong);
  background: var(--gold);
  color: #121214;
}

.primary-button:hover {
  background: var(--gold-strong);
}

.text-button {
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  background: #121214;
  color: var(--ink);
}

.text-button.ghost {
  background: transparent;
  color: var(--muted);
}

.danger-button {
  padding: 0 13px;
  border: 1px solid rgba(217, 124, 124, 0.35);
  background: rgba(217, 124, 124, 0.10);
  color: #f0aaaa;
}

.icon-button,
.icon-action {
  width: 40px;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: #121214;
  color: var(--muted);
}

.main-area {
  min-width: 0;
  padding: 24px;
}

.workspace-head {
  margin-bottom: 18px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  min-height: 42px;
  padding: 0 15px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.tab-button.active {
  border-bottom-color: var(--gold);
  color: var(--ink);
}

.view-panel {
  padding: 18px;
}

.list-head {
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.list-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.88rem;
}

.week-head-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.week-nav-button,
.week-current-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #121214;
  color: var(--muted);
  font-weight: 850;
}

.week-nav-button {
  width: 36px;
  padding: 0;
  font-size: 1rem;
}

.week-current-button {
  padding: 0 11px;
  font-size: 0.76rem;
}

.week-current-button.active,
.week-current-button:disabled {
  border-color: rgba(201, 162, 79, 0.45);
  background: var(--gold-soft);
  color: var(--gold-strong);
  cursor: default;
}

.week-nav-button:hover,
.week-current-button:not(:disabled):hover {
  border-color: rgba(201, 162, 79, 0.45);
  color: var(--gold-strong);
}

.task-list {
  display: grid;
  gap: 10px;
}

.overdue-list {
  margin-bottom: 14px;
}

.subsection-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.subsection-title small {
  color: var(--muted);
}

.task-item {
  display: grid;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.018), rgba(255,255,255,0.005)), #141416;
}

.task-item.is-overdue {
  border-left-color: var(--red);
}

.task-item.compact {
  padding: 10px;
  gap: 8px;
}

.task-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.task-item h4 {
  font-size: 0.98rem;
  line-height: 1.25;
}

.task-item.compact h4 {
  font-size: 0.86rem;
}

.task-item-head p,
.task-desc {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 850;
}

.status-pill.in_progress {
  background: rgba(111, 177, 255, 0.13);
  color: var(--blue);
}

.status-pill.done {
  background: rgba(111, 199, 132, 0.13);
  color: var(--green);
}

.task-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.tag.priority-Alta {
  color: #f0aaaa;
  border-color: rgba(217, 124, 124, 0.35);
}

.tag.priority-Media {
  color: var(--amber);
  border-color: rgba(245, 180, 80, 0.30);
}

.task-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.status-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #101012;
  color: var(--muted);
  font-size: 0.76rem;
}

.status-button.active {
  border-color: var(--gold);
  color: var(--gold-strong);
}

.status-button.done.active {
  border-color: rgba(111, 199, 132, 0.55);
  color: var(--green);
}

/* Avatares do responsavel no card (mesmo padrao do hub-planejamento).
   .task-assignees usa margin-left:auto pra empurrar pro canto direito do
   .task-actions, mesmo com os botoes de status fluindo a esquerda. */
.task-assignees {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}
.card-assignee {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--bg, #050507);
}
.card-assignee.single {
  width: 26px;
  height: 26px;
  object-fit: cover;
  background: #121214;
}
.card-assignee.initials {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, var(--gold, #c9a24f), #b58a3f);
  color: #121214;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.01em;
}
.card-assignee.multi {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: none;
}
.card-assignee.multi img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: #121214;
  box-shadow: 0 0 0 1px var(--bg, #050507);
}
.card-assignee.multi .initials {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold, #c9a24f), #b58a3f);
  color: #121214;
  font-weight: 800;
  font-size: 10px;
  box-shadow: 0 0 0 1px var(--bg, #050507);
}

/* Avatar do membro nos cards do tab Atribuicoes (header).
   .avatar.multi = pilha pra grupos; .avatar-mini = miniatura interna. */
.avatar.multi {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: transparent;
  width: auto;
  border-radius: 0;
}
.avatar.multi img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--gold);
}
.avatar.multi .avatar-mini {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #b58a3f);
  color: #121214;
  font-weight: 900;
  font-size: 10px;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(160px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.week-day {
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101012;
}

.week-day.today {
  border-color: rgba(201, 162, 79, 0.42);
}

.week-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.week-day-head strong {
  color: var(--ink);
  font-size: 1rem;
}

.week-day-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(138px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.month-weekday {
  min-width: 138px;
  padding: 0 8px 4px;
  color: var(--faint);
  font-size: 0.7rem;
  font-weight: 850;
  text-transform: uppercase;
}

.month-day {
  display: flex;
  flex-direction: column;
  min-width: 138px;
  min-height: 136px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101012;
}

.month-day.today {
  border-color: rgba(201, 162, 79, 0.50);
  box-shadow: inset 0 0 0 1px rgba(201, 162, 79, 0.12);
}

.month-day.outside-month {
  opacity: 0.45;
  background: #0b0b0d;
}

.month-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 9px 7px;
  color: var(--muted);
  font-weight: 850;
}

.month-day-number {
  color: var(--ink);
  font-size: 0.92rem;
}

.month-day-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  min-height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-strong);
  font-size: 0.68rem;
}

.month-day-body {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 0 8px 8px;
  overflow: auto;
}

.month-task {
  display: grid;
  width: 100%;
  min-height: 40px;
  gap: 2px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 7px;
  background: #141416;
  color: var(--ink);
  text-align: left;
}

.month-task.status-in_progress {
  border-left-color: var(--blue);
}

.month-task.status-done {
  border-left-color: var(--green);
}

.month-task.is-overdue {
  border-left-color: var(--red);
}

.month-task span {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 850;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-task small {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 750;
}

.month-task:hover {
  border-color: rgba(201, 162, 79, 0.38);
}

.assignments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.assignment-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141416;
}

.assignment-card header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  min-width: 0;
}

.assignment-card header > div {
  min-width: 0;
}

.assignment-card h4 {
  font-size: 0.96rem;
}

.assignment-card p {
  color: var(--faint);
  font-size: 0.72rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--gold);
}

.avatar.initials {
  display: inline-grid;
  place-items: center;
  color: #121214;
  font-weight: 900;
}

.assignment-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: 6px;
}

.assignment-stats span {
  display: grid;
  min-width: 0;
  gap: 4px;
  min-height: 62px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101012;
}

.assignment-stats strong {
  font-size: 1rem;
}

.assignment-stats small {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 750;
  line-height: 1.15;
  overflow-wrap: anywhere;
  white-space: normal;
}

.assignment-stats .danger strong {
  color: var(--red);
}

.empty-state,
.empty-mini {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-mini {
  padding: 12px;
  font-size: 0.78rem;
}

.task-dialog {
  width: min(680px, calc(100vw - 28px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
}

.task-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-card {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(201, 162, 79, 0.05), transparent 55%),
    var(--panel);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

/* ── Cabecalho do modal ─────────────────────────────────────────── */
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head-meta {
  min-width: 0;
}

.modal-eyebrow {
  display: block;
  margin: 0 0 4px;
  color: var(--gold, #c9a24f);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.modal-close {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.modal-close:hover {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
}

/* ── Corpo do modal: lista vertical de secoes ───────────────────── */
.modal-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 22px;
  overflow-y: auto;
}

.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.14);
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-section-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold, #c9a24f);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.modal-section .field-label {
  margin: 0 0 4px;
}

/* Form-row dentro de modal-section */
.modal-section .form-row {
  margin-top: 0;
}

/* ── Acoes do modal ─────────────────────────────────────────────── */
.modal-actions {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line);
}

.modal-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.modal-save {
  width: auto;
  margin-top: 0;
  padding: 0 16px;
  min-height: 40px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* ── Dias da semana: pills com estado ativo bem visivel ─────────── */
.weekday-group {
  margin: 4px 0 0;
  padding: 0;
  border: 0;
}

.weekday-group .field-label {
  margin-bottom: 8px;
}

.weekday-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.weekday-pills label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  min-width: 46px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: rgba(237, 237, 235, 0.55);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  transition: color 140ms, background 140ms, border-color 140ms;
}

.weekday-pills label:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.03);
}

/* Esconde o checkbox real mas mantem acessivel via keyboard. */
.weekday-pills input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.weekday-pills label:has(input:checked) {
  color: var(--gold, #c9a24f);
  background: rgba(201, 162, 79, 0.10);
  border-color: rgba(201, 162, 79, 0.32);
}

.weekday-pills label:has(input:focus-visible) {
  outline: 2px solid var(--gold, #c9a24f);
  outline-offset: 2px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #18181b;
  color: var(--ink);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .task-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .main-area {
    padding: 18px;
  }
}

@media (max-width: 720px) {
  /* Defensiva contra overflow horizontal. */
  /* overflow-x: hidden removido: causa bug com position: fixed no iOS Safari */

  /* Header fixo + body padding-top + truncate vem de /css/topbar.css. */

  /* Inputs 16px previne zoom automatico do Safari iOS. */
  input, select, textarea {
    font-size: 16px;
    min-height: 44px;
  }
  textarea { min-height: 88px; }

  /* Touch targets melhores */
  .icon-button { width: 40px; min-width: 40px; min-height: 40px; }
  .status-button { min-height: 38px; padding: 0 12px; }
  .icon-action { min-width: 38px; min-height: 38px; }

  /* Sidebar mais compacta no topo */
  .sidebar { padding: 16px 14px; gap: 12px; }
  .main-area { padding: 14px; }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-row { grid-template-columns: 1fr; }

  .workspace-head,
  .list-head {
    align-items: stretch;
    flex-direction: column;
  }

  .head-actions,
  .week-head-actions {
    width: 100%;
  }

  .text-button,
  .week-current-button {
    width: 100%;
  }

  .assignment-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Week view: em vez de 7 cols com horizontal scroll, empilha 1 dia
     por linha. Cada dia mostra cabecalho + lista vertical. */
  .week-grid {
    grid-template-columns: 1fr;
    overflow-x: visible;
  }
  .week-day { min-width: 0; }
  .week-day-head { padding: 12px 14px; }
  .week-day-body { padding: 12px 14px; gap: 8px; }
  /* Esconde dias sem tarefas pra reduzir scroll (mantem renderer mas oculta o card) */
  /* Removido: queremos mostrar todos os dias mesmo vazios pra orientacao */

  .month-grid {
    grid-template-columns: 1fr;
    overflow-x: visible;
  }
  .month-weekday { display: none; }
  .month-day {
    min-width: 0;
    min-height: auto;
  }
  .month-day.outside-month { display: none; }
  .month-day-head { padding: 12px 14px; }
  .month-day-body { padding: 0 14px 14px; }
  .month-task span {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  /* Modal full-screen no mobile */
  .task-dialog {
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    margin: 0;
    padding: 0;
    border-radius: 0;
    border: 0;
  }
  .task-dialog .modal-card {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    padding: max(16px, env(safe-area-inset-top)) 16px 16px;
    border-radius: 0;
    border: none;
  }
  .task-dialog dialog::backdrop,
  dialog::backdrop {
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  /* Modal-actions: stack vertical com botoes full-width */
  .modal-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .modal-actions-right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .modal-actions-right .text-button,
  .modal-actions-right .primary-button,
  .modal-save,
  .danger-button {
    width: 100%;
  }

  /* Card de tarefa: header empilha titulo e pill quando aperta */
  .task-item-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Avatares menores no mobile */
  .card-assignee.single,
  .card-assignee.initials,
  .card-assignee.multi img,
  .card-assignee.multi .initials {
    width: 24px;
    height: 24px;
  }
}

/* Phones estreitos */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .assignment-stats { grid-template-columns: 1fr 1fr; }
  .scope-toggle { font-size: 0.8rem; }
  .tab-button { font-size: 0.75rem; padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}
