:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --primary: #9a6b45;
  --primary-hover: #82603a;
  --danger: #b85c50;
  --danger-hover: #9e4e44;
  --shadow: 0 1px 2px rgba(58, 50, 40, 0.06);
  --radius: 8px;
  --status-not_started: #6b6560;
  --status-not_started-bg: #f3f4f6;
  --status-waiting: #b8860b;
  --status-waiting-bg: #fffbeb;
  --status-in_progress: #2f7a8a;
  --status-in_progress-bg: #ecfeff;
  --status-done: #2d6a45;
  --status-done-bg: #ecfdf5;
  --overdue: #b85c50;
  --soon: #b8860b;
  --dl-overdue: #a83832;
  --dl-overdue-bg: #fef2f2;
  --dl-today: #c45f10;
  --dl-today-bg: #fff7ed;
  --dl-soon: #9a7209;
  --dl-soon-bg: #fffbeb;
  --dl-normal: #3d6b5c;
  --dl-normal-bg: #f0fdf4;
  --dl-none: #9ca3af;
  --font: "Sarabun", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.banner {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.banner--info {
  background: #f9fafb;
  color: #4b5563;
  border: 1px solid var(--border);
}

.banner--error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.header__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.header__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  margin-bottom: 1rem;
}

.summary__item {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--surface);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.summary__item strong {
  color: var(--text);
  font-weight: 600;
}

.summary__item--warn {
  background: var(--dl-soon-bg);
  border: 1.5px solid #d4b45a;
}

.summary__item--warn strong {
  color: var(--dl-soon);
}

.summary__item--danger {
  background: var(--dl-overdue-bg);
  border: 1.5px solid #d4726a;
}

.summary__item--danger strong {
  color: var(--dl-overdue);
}

.status-chart {
  margin-bottom: 0.5rem;
}

.status-chart__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.status-chart__card--empty {
  text-align: center;
  padding: 1.25rem;
}

.status-chart__title {
  margin: 0 0 0.15rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-chart__subtitle {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status-chart__empty {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.status-chart__stack {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: #f3f4f6;
  margin-bottom: 1rem;
}

.status-chart__stack-seg {
  display: block;
  height: 100%;
  min-width: 2px;
  transition: width 0.3s ease;
}

.status-chart__body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
}

.status-chart__donut {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-chart__donut-hole {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.status-chart__donut-total {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text);
}

.status-chart__donut-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-chart__legend {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 200px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.status-chart__legend-item {
  display: grid;
  grid-template-columns: 8px 1fr minmax(64px, 26%) auto;
  align-items: center;
  gap: 0.45rem 0.6rem;
  font-size: 0.875rem;
}

.status-chart__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(58, 50, 40, 0.08);
}

.status-chart__legend-label {
  color: var(--text);
  font-weight: 500;
}

.status-chart__legend-item:nth-child(1) .status-chart__legend-label { color: var(--status-not_started); }
.status-chart__legend-item:nth-child(2) .status-chart__legend-label { color: var(--status-waiting); }
.status-chart__legend-item:nth-child(3) .status-chart__legend-label { color: var(--status-in_progress); }
.status-chart__legend-item:nth-child(4) .status-chart__legend-label { color: var(--status-done); }

.status-chart__legend-bar {
  height: 4px;
  background: #f3f4f6;
  border-radius: 2px;
  overflow: hidden;
}

.status-chart__legend-bar-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.status-chart__legend-meta {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.3rem;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.status-chart__legend-meta strong {
  color: var(--text);
  font-weight: 600;
}

.status-chart__legend-pct {
  min-width: 2rem;
  text-align: right;
}

@media (max-width: 480px) {
  .status-chart__legend-item {
    grid-template-columns: 8px 1fr auto;
    grid-template-rows: auto auto;
  }

  .status-chart__legend-bar {
    grid-column: 2 / -1;
  }

  .status-chart__legend-meta {
    grid-column: 3;
    grid-row: 1;
  }
}

.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.toolbar__search {
  margin-bottom: 0.75rem;
}

.toolbar__filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 0.85rem;
}

.view-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.view-tab {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  margin-bottom: -1px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.view-tab:hover {
  color: var(--text);
}

.view-tab--active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--primary);
}

.input,
.select {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s;
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
}

.input--textarea {
  resize: vertical;
  min-height: 4.5rem;
}

.select {
  width: auto;
  min-width: 10rem;
}

.select--full {
  width: 100%;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-label input {
  accent-color: var(--primary);
}

.btn {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn--primary {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.btn--primary:hover {
  background: var(--primary-hover);
}

.btn--ghost {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: #d1d5db;
  background: #f9fafb;
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}

.btn--danger:hover {
  background: var(--danger-hover);
}

.btn--sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

.btn-link {
  font-family: inherit;
  font-size: 0.8rem;
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0.2rem 0;
  margin-top: 0.2rem;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-icon {
  font-size: 1.35rem;
  line-height: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
}

.btn-icon:hover {
  color: var(--text);
}

.btn:disabled,
.status-quick:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.list-section {
  margin-bottom: 1.5rem;
}

.list-section__title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.6rem;
}

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
  align-items: start;
  border-left: 4px solid var(--status-not_started);
}

.task-card[data-status="not_started"] {
  border-left-color: var(--status-not_started);
}

.task-card[data-status="waiting"] {
  border-left-color: var(--status-waiting);
}

.task-card[data-status="in_progress"] {
  border-left-color: var(--status-in_progress);
}

.task-card[data-status="done"] {
  border-left-color: var(--status-done);
  opacity: 0.9;
}

.task-card__title {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  font-weight: 600;
}

.task-card__title--done {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-card__detail {
  margin: 0 0 0.4rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.task-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge--status {
  font-weight: 600;
  border: 1px solid transparent;
}

.task-card[data-status="not_started"] .badge--status {
  background: var(--status-not_started-bg);
  color: #4b5563;
  border-color: var(--status-not_started);
}

.task-card[data-status="waiting"] .badge--status {
  background: var(--status-waiting-bg);
  color: #7a5a08;
  border-color: var(--status-waiting);
}

.task-card[data-status="in_progress"] .badge--status {
  background: var(--status-in_progress-bg);
  color: #1e5563;
  border-color: var(--status-in_progress);
}

.task-card[data-status="done"] .badge--status {
  background: var(--status-done-bg);
  color: #1e4a30;
  border-color: var(--status-done);
}

.badge--deadline {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge--deadline-overdue {
  background: var(--dl-overdue-bg);
  color: var(--dl-overdue);
  border: 1.5px solid #d4726a;
  box-shadow: 0 0 0 2px rgba(168, 56, 50, 0.12);
}

.badge--deadline-today {
  background: var(--dl-today-bg);
  color: var(--dl-today);
  border: 1.5px solid #e8943a;
  box-shadow: 0 0 0 2px rgba(196, 95, 16, 0.15);
}

.badge--deadline-soon {
  background: var(--dl-soon-bg);
  color: var(--dl-soon);
  border: 1.5px solid #d4b45a;
}

.badge--deadline-normal {
  background: var(--dl-normal-bg);
  color: var(--dl-normal);
  border: 1px solid #9fc4b0;
}

.badge--deadline-none {
  color: var(--dl-none);
  font-style: italic;
  font-weight: 500;
  background: transparent;
  border: 1px dashed #d1d5db;
}

.task-card__actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-end;
}

.status-quick {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  max-width: 11rem;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  align-items: start;
}

@media (max-width: 900px) {
  .board {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .board {
    grid-template-columns: 1fr;
  }
}

.board-column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 100px;
}

.board-column__header {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.board-column[data-status="not_started"] .board-column__header {
  border-bottom: 2px solid var(--status-not_started);
  background: var(--status-not_started-bg);
}

.board-column[data-status="waiting"] .board-column__header {
  border-bottom: 2px solid var(--status-waiting);
  background: var(--status-waiting-bg);
}

.board-column[data-status="in_progress"] .board-column__header {
  border-bottom: 2px solid var(--status-in_progress);
  background: var(--status-in_progress-bg);
}

.board-column[data-status="done"] .board-column__header {
  border-bottom: 2px solid var(--status-done);
  background: var(--status-done-bg);
}

.board-column__title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.board-column[data-status="not_started"] .board-column__title {
  color: var(--status-not_started);
}

.board-column[data-status="waiting"] .board-column__title {
  color: var(--status-waiting);
}

.board-column[data-status="in_progress"] .board-column__title {
  color: var(--status-in_progress);
}

.board-column[data-status="done"] .board-column__title {
  color: var(--status-done);
}

.board-column__count {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.board-column[data-status="not_started"] .board-column__count {
  color: #4b5563;
  background: var(--status-not_started-bg);
}

.board-column[data-status="waiting"] .board-column__count {
  color: #7a5a08;
  background: var(--status-waiting-bg);
}

.board-column[data-status="in_progress"] .board-column__count {
  color: #1e5563;
  background: var(--status-in_progress-bg);
}

.board-column[data-status="done"] .board-column__count {
  color: #1e4a30;
  background: var(--status-done-bg);
}

.board-column__list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.board-card {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem;
}

.board-card__title {
  margin: 0 0 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
  word-break: break-word;
}

.board-card__title--done {
  text-decoration: line-through;
  color: var(--text-muted);
}

.board-card__deadline {
  font-size: 0.75rem;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.board-card__actions {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.25rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state p {
  margin: 0 0 1rem;
}

.field {
  margin-bottom: 0.9rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  color: var(--text);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 520px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.required {
  color: var(--danger);
}

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 28rem;
  width: calc(100% - 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  margin: auto;
  color: var(--text);
}

.modal:not([open]) {
  display: none !important;
  pointer-events: none;
}

.modal[open] {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.2);
}

.modal--confirm {
  max-width: 22rem;
}

.modal__form {
  display: flex;
  flex-direction: column;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.modal__body {
  padding: 1rem;
}

.modal__message {
  margin: 0;
  padding: 0 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.modal__hint {
  margin: 0 0 0.9rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.modal__hint code {
  font-size: 0.85em;
  background: #f3f4f6;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  border-top: 1px solid var(--border);
}

.modal--confirm .modal__footer {
  padding-top: 0;
  padding-bottom: 1rem;
}
