:root {
  color-scheme: dark;
  --bg: #0a0a0c;
  --bg-soft: #111116;
  --panel: rgb(20 20 24 / 0.86);
  --panel-solid: #16161c;
  --column: #10131a;
  --task: #1b1d25;
  --line: rgb(255 255 255 / 0.1);
  --line-strong: rgb(255 255 255 / 0.18);
  --text: #f8fafc;
  --muted: #a1a1aa;
  --accent: #e11d48;
  --accent-hover: #be123c;
  --accent-soft: rgb(225 29 72 / 0.16);
  --danger: #fb7185;
  --ok: #34d399;
  --shadow: 0 18px 50px rgb(0 0 0 / 0.32);
  --radius: 8px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-soft: #eef2f7;
  --panel: rgb(255 255 255 / 0.92);
  --panel-solid: #ffffff;
  --column: #edf1f7;
  --task: #ffffff;
  --line: #d9e1ec;
  --line-strong: #c7d2df;
  --text: #141722;
  --muted: #647084;
  --accent: #d71945;
  --accent-hover: #b91037;
  --accent-soft: rgb(215 25 69 / 0.11);
  --danger: #b42318;
  --ok: #137333;
  --shadow: 0 18px 45px rgb(24 35 58 / 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: linear-gradient(180deg, var(--bg), var(--bg-soft));
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 10px 14px;
  transition: background 140ms ease, opacity 140ms ease, transform 140ms ease, border-color 140ms ease;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

button.secondary,
.icon-button {
  min-width: 46px;
  border: 1px solid var(--line);
  background: var(--panel-solid);
  color: var(--text);
}

button.secondary:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--accent-soft);
}

.link-button {
  width: 100%;
  min-height: 34px;
  background: transparent;
  color: var(--accent);
  padding: 4px 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  color: var(--text);
  outline: none;
  padding: 11px 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.auth-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 28px;
  backdrop-filter: blur(14px);
}

.auth-panel h1,
.topbar h1 {
  margin: 0;
  line-height: 1;
}

.auth-panel h1 {
  font-size: 32px;
}

.auth-panel p,
.topbar p {
  color: var(--muted);
}

.auth-panel form,
.dialog-form {
  display: grid;
  gap: 12px;
}

.captcha-box {
  min-height: 78px;
}

.feedback {
  color: var(--danger);
  min-height: 20px;
}

.feedback.success {
  color: var(--ok);
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 30;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  border: 1px solid rgb(52 211 153 / 0.36);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel-solid), var(--ok) 10%);
  color: var(--ok);
  box-shadow: var(--shadow);
  font-weight: 800;
  padding: 12px 16px;
  text-align: center;
}

.board-view {
  min-height: 100vh;
  padding: 20px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg), transparent 14%);
  margin: -20px -20px 18px;
  padding: 18px 20px;
  backdrop-filter: blur(16px);
}

.topbar p {
  margin: 8px 0 0;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.topbar-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.menu-toggle {
  display: none;
}

.language-select {
  width: 58px;
  min-width: 58px;
  min-height: 42px;
  font-weight: 800;
  padding: 8px;
  text-align: center;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: cover;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 140px 220px;
  gap: 10px;
}

.composer textarea,
.composer button,
.form-feedback {
  grid-column: 1 / -1;
}

.form-feedback {
  margin: 0;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding-bottom: 12px;
}

.column {
  min-height: calc(100vh - 142px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--column), transparent 8%);
  padding: 12px;
  transition: background 140ms ease, border-color 140ms ease;
}

.column h2 {
  margin: 2px 0 12px;
  color: var(--text);
  font-size: 15px;
}

.column.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.empty-column {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  padding: 14px;
}

.task-card {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--task);
  color: var(--text);
  margin-bottom: 10px;
  padding: 12px;
  text-align: left;
  box-shadow: 0 10px 24px rgb(0 0 0 / 0.12);
  transition: opacity 140ms ease, transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.task-card:hover {
  border-color: var(--accent);
  box-shadow: 0 14px 28px rgb(0 0 0 / 0.18);
}

.task-card.dragging {
  opacity: 0.46;
  transform: rotate(1deg);
}

.task-card h3 {
  margin: 0;
  font-size: 15px;
}

.task-description {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  margin: 0;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.badge.urgente {
  background: rgb(251 113 133 / 0.17);
  color: var(--danger);
}

.badge.alta {
  background: rgb(251 191 36 / 0.16);
  color: #f59e0b;
}

.task-actions {
  display: flex;
  justify-content: flex-end;
}

.delete-task {
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
  text-decoration: underline;
}

dialog {
  width: min(760px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 0;
  overflow: hidden;
}

#taskDialog {
  width: min(1120px, calc(100% - 28px));
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.62);
}

.dialog-form {
  position: relative;
  max-height: calc(100dvh - 28px);
  overflow: auto;
  padding: 22px;
}

.dialog-form h2 {
  margin: 0 52px 4px 0;
}

.dialog-form label {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

.close-button {
  position: absolute;
  top: 18px;
  right: 18px;
  justify-self: end;
  background: var(--panel);
  color: var(--text);
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
}

.task-dialog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: start;
}

.task-dialog-main,
.task-dialog-sidebar {
  display: grid;
  gap: 12px;
}

.task-dialog-sidebar {
  position: sticky;
  top: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel-solid), var(--column) 34%);
  padding: 14px;
}

#dialogDescription {
  min-height: 250px;
}

#commentBody {
  min-height: 88px;
}

.comments {
  display: grid;
  gap: 16px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 14px;
}

.comment {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel-solid), transparent 18%);
  padding: 12px 14px;
}

.comment p {
  margin: 4px 0 0;
}

.comment-body {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.comment-body p,
.comment-body ul {
  margin: 0;
}

.comment-body ul {
  padding-left: 20px;
}

.comment-body code {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--column);
  padding: 1px 5px;
}

.comment-body a {
  color: var(--accent);
  font-weight: 700;
}

.admin-section {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.admin-section h3 {
  font-size: 15px;
  margin: 0;
}

.user-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.user-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  margin: 8px 20px 0;
  padding: 16px 0 18px;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .topbar-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }

  .column {
    min-height: 420px;
  }

  .composer,
  .task-dialog-layout,
  .user-row {
    grid-template-columns: 1fr;
  }

  .task-dialog-sidebar {
    position: static;
    order: -1;
  }
}

@media (max-width: 560px) {
  .board-view {
    padding: 14px;
    overflow-x: hidden;
  }

  .topbar {
    margin: -14px -14px 14px;
    padding: 14px;
  }

  .topbar h1 {
    font-size: 28px;
    line-height: 1.05;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 48px 48px 48px;
    width: 100%;
    column-gap: 0;
    row-gap: 8px;
  }

  .new-task-button {
    grid-column: 1;
    grid-row: 1;
    min-width: 48px;
    width: 48px;
    font-size: 0;
    overflow: hidden;
    padding: 10px 0;
    white-space: nowrap;
  }

  .new-task-button::before {
    content: "+";
    display: block;
    font-size: 26px;
    line-height: 1;
  }

  #themeToggleButton {
    grid-column: 3;
    grid-row: 1;
  }

  .language-select {
    grid-column: 4;
    grid-row: 1;
    min-width: 48px;
    width: 48px;
    padding: 8px 0;
  }

  .menu-toggle {
    grid-column: 5;
    grid-row: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
  }

  #themeToggleButton {
    border-radius: var(--radius) 0 0 var(--radius);
  }

  .language-select {
    border-left: 0;
    border-radius: 0;
  }

  .menu-toggle {
    border-left: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
  }

  .topbar-menu {
    display: none;
    grid-column: 3 / 6;
    grid-row: 2;
    grid-template-columns: 1fr;
    justify-self: end;
    width: min(100%, 260px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-solid);
    box-shadow: var(--shadow);
    padding: 8px;
  }

  .topbar-menu.is-open {
    display: grid;
  }

  .topbar-menu button {
    width: 100%;
  }

  .topbar-actions .icon-button,
  .language-select {
    min-width: 0;
    width: 100%;
  }

  .topbar-actions button {
    flex: 1 1 calc(50% - 6px);
  }

  .composer {
    gap: 8px;
  }

  .board {
    grid-template-columns: 1fr;
    gap: 12px;
    padding-bottom: 0;
  }

  .column {
    min-height: 220px;
    padding: 10px;
  }

  .task-card {
    margin-bottom: 8px;
    padding: 11px;
  }

  .task-description {
    -webkit-line-clamp: 2;
  }

  dialog,
  #taskDialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }

  .auth-panel,
  .dialog-form {
    max-height: calc(100dvh - 16px);
    padding: 16px;
  }

  .dialog-form h2 {
    margin-right: 48px;
    font-size: 26px;
    line-height: 1.08;
  }

  .close-button {
    top: 14px;
    right: 14px;
  }

  .task-dialog-layout {
    gap: 12px;
  }

  .task-dialog-sidebar {
    padding: 12px;
  }

  #dialogDescription {
    min-height: 180px;
  }

  .user-list {
    max-height: none;
  }

  .app-footer {
    display: grid;
    margin: 8px 14px 0;
  }
}
