:root {
  color-scheme: light;
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --ink: #1d2430;
  --muted: #6b7280;
  --border: #d9ded8;
  --accent: #1f7a6d;
  --accent-dark: #155d54;
  --accent-soft: #dff1ed;
  --warning: #a83f39;
  --shadow: 0 16px 38px rgba(34, 39, 47, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 260px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1480px;
  margin: 0 auto 20px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.1;
}

.primary-action,
.secondary-action,
.danger-action,
.icon-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 13px;
  font-weight: 700;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
}

.primary-action:hover {
  background: var(--accent-dark);
}

.secondary-action {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

.secondary-action:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.danger-action {
  background: #fff5f4;
  border-color: #efc8c4;
  color: var(--warning);
}

.icon-button {
  width: 38px;
  padding: 0;
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--muted);
}

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 1fr);
  gap: 16px;
  max-width: 1480px;
  min-height: calc(100vh - 128px);
  margin: 0 auto;
  overflow-x: auto;
  padding-bottom: 16px;
}

.column {
  display: flex;
  min-width: 280px;
  max-height: calc(100vh - 130px);
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.column-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-title h2 {
  margin: 0;
  font-size: 16px;
}

.count-badge {
  display: inline-flex;
  min-width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.card-list {
  display: flex;
  min-height: 180px;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 14px;
}

.card-list.drag-over {
  background: rgba(31, 122, 109, 0.08);
  outline: 2px dashed rgba(31, 122, 109, 0.38);
  outline-offset: -8px;
}

.task-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(34, 39, 47, 0.08);
  text-align: left;
}

.task-card[draggable="true"] {
  cursor: grab;
}

.task-card:active {
  cursor: grabbing;
}

.task-card.dragging {
  opacity: 0.55;
}

.task-card h3 {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.3;
}

.task-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.move-controls {
  display: flex;
  gap: 6px;
}

.move-controls button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 800;
}

.move-controls button:disabled {
  cursor: default;
  opacity: 0.35;
}

.empty-state {
  margin: auto;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.card-dialog {
  width: min(720px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.card-dialog::backdrop,
.admin-dialog::backdrop {
  background: rgba(25, 31, 41, 0.44);
}

.admin-dialog {
  width: min(980px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.dialog-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
}

.dialog-header h2 {
  margin: 0;
  font-size: 24px;
}

.title-input {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--border);
  padding: 3px 0 8px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
  outline: 0;
}

.title-input:focus {
  border-color: var(--accent);
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.section-heading h2 {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px;
  color: var(--ink);
  outline: 0;
}

.text-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--ink);
  outline: 0;
}

textarea:focus,
.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 109, 0.12);
}

.comments-section {
  display: grid;
  gap: 10px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading h2 {
  margin: 0;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.comments-list {
  display: grid;
  max-height: 220px;
  gap: 8px;
  overflow-y: auto;
}

.comment {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px;
  background: var(--surface-soft);
}

.comment p {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.comment time {
  color: var(--muted);
  font-size: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.admin-panel {
  max-height: calc(100vh - 32px);
}

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

.stat-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.stat-box strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.stat-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-tools {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.admin-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.file-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-action input {
  display: none;
}

.admin-list {
  display: grid;
  max-height: 420px;
  gap: 8px;
  overflow: auto;
}

.admin-row {
  display: grid;
  grid-template-columns: 1.4fr 150px 110px auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}

.admin-row-title {
  min-width: 0;
}

.admin-row-title strong,
.admin-row-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row-title span,
.admin-row-meta {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .admin-buttons {
    justify-content: stretch;
  }

  .topbar-actions > *,
  .admin-buttons > * {
    flex: 1;
  }

  .board {
    grid-auto-columns: minmax(260px, 86vw);
    min-height: calc(100vh - 160px);
  }

  .column {
    max-height: calc(100vh - 170px);
  }

  .dialog-panel {
    padding: 16px;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .admin-stats,
  .admin-tools,
  .admin-row {
    grid-template-columns: 1fr;
  }
}
