:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #172026;
  --muted: #66737d;
  --line: #dbe2e6;
  --brand: #145c4a;
  --brand-dark: #0e4236;
  --gold: #b88926;
  --danger: #b42318;
  --warning: #b76e00;
  --ok: #1f7a4d;
  --shadow: 0 12px 28px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card h1 {
  margin: 0 0 24px;
  font-size: 28px;
}

.login-card label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.login-card input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
}

.form-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
}

.user-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(1.55rem, 2.4vw, 2.35rem);
  line-height: 1.08;
}

.header-actions,
menu {
  display: flex;
  gap: 10px;
  align-items: center;
}

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  background: var(--brand);
  color: #fff;
}

.primary-button:hover {
  background: var(--brand-dark);
}

.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  background: transparent;
  border-color: var(--line);
}

main {
  padding: 20px clamp(14px, 2.4vw, 30px) 28px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metrics article {
  min-height: 84px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics span {
  display: block;
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--brand);
}

.metrics p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 220px;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 86px;
  padding: 10px;
  resize: vertical;
}

.board {
  display: grid;
  grid-template-columns: repeat(7, minmax(260px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.column {
  min-height: 540px;
  background: #eef3f4;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.column-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: #eef3f4;
  border-bottom: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
}

.column-header h2 {
  font-size: 0.95rem;
}

.count {
  min-width: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  text-align: center;
  font-weight: 900;
}

.task-list {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 470px;
  padding: 10px;
  border-radius: 0 0 8px 8px;
}

.task-list.drag-over {
  background: rgba(20, 92, 74, 0.1);
  outline: 2px dashed rgba(20, 92, 74, 0.55);
  outline-offset: -8px;
}

.task-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  border-radius: 8px;
  box-shadow: 0 5px 14px rgba(23, 32, 38, 0.06);
}

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

.task-card[data-priority="P1"] {
  border-left-color: var(--danger);
}

.task-card[data-priority="P2"] {
  border-left-color: var(--gold);
}

.task-card[data-priority="P3"] {
  border-left-color: var(--brand);
}

.task-card[data-priority="P4"] {
  border-left-color: var(--muted);
}

.task-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.task-card h3 {
  font-size: 0.98rem;
  line-height: 1.22;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f2f5f6;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.priority {
  color: #fff;
  background: var(--brand);
}

.priority.P1 {
  background: var(--danger);
}

.priority.P2 {
  background: var(--gold);
}

.priority.P4 {
  background: var(--muted);
}

.task-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.28;
}

.task-meta strong {
  color: var(--text);
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.card-actions select {
  min-height: 34px;
}

.delete-button {
  min-height: 34px;
  padding: 0 10px;
  background: #fff;
  border-color: var(--line);
  color: var(--danger);
}

.edit-button {
  min-height: 34px;
  padding: 0 10px;
  background: #fff;
  border-color: var(--line);
  color: var(--brand);
}

.history-panel {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
}

.history-panel h3 {
  margin-bottom: 10px;
  font-size: 0.95rem;
}

#historyList {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

#historyList p {
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

#historyList strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
}

dialog {
  width: min(760px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(23, 32, 38, 0.42);
}

form {
  padding: 18px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

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

.full {
  grid-column: 1 / -1;
}

menu {
  justify-content: flex-end;
  margin: 18px 0 0;
  padding: 0;
}

@media (max-width: 900px) {
  .app-header,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .filters,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .board {
    grid-template-columns: repeat(7, 82vw);
  }
}
