:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d2430;
  --muted: #647184;
  --line: #d8dee8;
  --primary: #246b5f;
  --primary-dark: #1b5148;
  --danger: #af2f2f;
  --warning: #b86412;
  --info: #2c5f9e;
  --low: #5f6f3e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 160ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar {
  background: #18212d;
  color: #fff;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

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

.brand-block {
  min-width: 0;
}

.sidebar-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid #344256;
  border-radius: 6px;
  background: #223044;
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0;
  flex: 0 0 auto;
}

.sidebar-toggle:hover {
  background: #2c3c52;
}

.app-shell.sidebar-collapsed .sidebar {
  padding: 22px 14px;
  align-items: center;
}

.app-shell.sidebar-collapsed .brand-block,
.app-shell.sidebar-collapsed .nav-label {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-head {
  justify-content: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: #9fb3c8;
  font-size: 0.78rem;
  text-transform: uppercase;
}

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

h1 {
  font-size: 1.45rem;
  font-weight: 700;
}

h2 {
  font-size: 1.4rem;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #dbe6f1;
  padding: 11px 12px;
  text-align: left;
}

.nav-short {
  display: none;
}

.app-shell.sidebar-collapsed .nav-tabs {
  width: 100%;
}

.app-shell.sidebar-collapsed .nav-tab {
  text-align: center;
  padding: 11px 0;
}

.app-shell.sidebar-collapsed .nav-short {
  display: inline;
  font-weight: 700;
}

.nav-tab.active,
.nav-tab:hover {
  background: #263447;
}

main {
  padding: 18px;
  min-width: 0;
}

.section {
  display: none;
}

.section.active {
  display: grid;
  gap: 10px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.toolbar h2 {
  font-size: 1.25rem;
  line-height: 1.15;
}

.toolbar p {
  margin-top: 2px;
  color: var(--muted);
}

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

.filters {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(160px, 1.3fr) minmax(120px, 0.9fr) auto auto;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 7px 9px;
}

textarea {
  resize: vertical;
}

.task-list-wrap,
.project-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

.task-group {
  display: grid;
  gap: 8px;
}

.task-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 4px 2px 8px;
}

.task-group-header h3 {
  font-size: 0.92rem;
  color: var(--text);
}

.task-group-header span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.task-group-list {
  display: grid;
  gap: 8px;
  min-height: 56px;
  padding: 4px 0;
}

.task-group-list.saving-order {
  opacity: 0.72;
}

.drop-placeholder {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  padding: 10px 11px;
  background: #fbfcfd;
}

.task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.task-card.dragging {
  opacity: 0.28;
  border-style: dashed;
  background: #f9fafc;
  cursor: grabbing;
}

.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 14px 34px rgb(16 23 33 / 22%);
  transform-origin: top left;
}

body.is-dragging-task {
  cursor: grabbing;
}

.task-line {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) 34px auto;
  align-items: center;
  gap: 10px;
}

.task-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}

.priority-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: 0 0 0 3px rgb(0 0 0 / 4%);
}

.priority-dot.priority-urgent {
  background: #d23b3b;
}

.priority-dot.priority-high {
  background: #f0b429;
}

.priority-dot.priority-medium {
  background: #2f80d8;
}

.priority-dot.priority-low {
  background: #3f9b5f;
}

.task-size {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.priority-urgent {
  background: #fde8e8;
  color: var(--danger);
}

.priority-high {
  background: #fff0dc;
  color: var(--warning);
}

.priority-medium {
  background: #e7f0fb;
  color: var(--info);
}

.priority-low {
  background: #edf2dd;
  color: var(--low);
}

.status-pending {
  background: #eef0f4;
  color: #4a5566;
}

.status-in_progress {
  background: #e3f5f1;
  color: #1f6a5c;
}

.status-completed {
  background: #e7f5e9;
  color: #2f713b;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.task-actions {
  gap: 6px;
}

.primary-button,
.secondary-button,
.text-button,
.danger-button,
.icon-button {
  border-radius: 6px;
  min-height: 38px;
  border: 1px solid transparent;
  padding: 9px 12px;
}

.primary-button {
  background: var(--primary);
  color: white;
}

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

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

.text-button {
  border-color: transparent;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
}

.danger-button {
  border-color: #f0c8c8;
  background: #fff7f7;
  color: var(--danger);
  font-weight: 700;
}

.danger-button:hover {
  background: #fde8e8;
}

.icon-button {
  width: 38px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  color: var(--text);
  font-size: 1.3rem;
}

.icon-action {
  width: 30px;
  height: 30px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.icon-action:hover {
  background: #f4f7f9;
}

.complete-action {
  color: var(--primary);
}

.info-action {
  color: var(--info);
  font-family: Georgia, serif;
  font-style: italic;
}

.danger-action {
  color: var(--danger);
  border-color: #f0c8c8;
}

.danger-action:hover {
  background: #fde8e8;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(640px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  overflow: auto;
  box-shadow: 0 24px 70px rgb(20 26 36 / 28%);
}

dialog::backdrop {
  background: rgb(16 23 33 / 45%);
}

.form-panel {
  display: grid;
  gap: 15px;
  padding: 20px;
  min-width: 0;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.dialog-header h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-panel {
  gap: 18px;
}

.detail-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.detail-list div {
  min-width: 0;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-list dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

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

.form-grid,
.project-picker,
.quick-project {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  min-width: 0;
}

.project-picker {
  grid-template-columns: minmax(0, 1fr) auto;
}

.quick-project {
  grid-template-columns: minmax(0, 1fr) auto;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.checkbox-row input {
  width: auto;
}

.filter-check {
  align-self: end;
  min-height: 34px;
  padding: 0 6px;
  color: var(--text);
}

.type-filters {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, 34px);
  gap: 5px;
  align-items: end;
}

.type-filters legend {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.type-filters label {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1rem;
}

.type-filters input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-filters label:has(input:checked) {
  border-color: var(--primary);
  background: #eef8f5;
  box-shadow: inset 0 0 0 1px var(--primary);
}

.confirm-message {
  color: var(--text);
  line-height: 1.45;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 6px;
}

.project-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.project-item:last-child {
  border-bottom: 0;
}

.project-item p {
  color: var(--muted);
  margin-top: 3px;
  font-size: 0.86rem;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: #18212d;
  color: white;
  padding: 12px 14px;
  box-shadow: 0 12px 36px rgb(16 23 33 / 24%);
}

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

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 18px;
  }

  .app-shell.sidebar-collapsed .sidebar {
    padding: 18px;
    align-items: stretch;
  }

  .app-shell.sidebar-collapsed .brand-block,
  .app-shell.sidebar-collapsed .nav-label {
    display: block;
  }

  .app-shell.sidebar-collapsed .nav-short {
    display: none;
  }

  .app-shell.sidebar-collapsed .nav-tab {
    text-align: left;
    padding: 11px 12px;
  }

  .nav-tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  main {
    padding: 18px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters,
  .form-grid,
  .project-picker,
  .quick-project {
    grid-template-columns: 1fr;
  }

  dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .form-panel {
    padding: 14px;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions button {
    flex: 1;
  }

  .task-line {
    grid-template-columns: 14px minmax(0, 1fr) 32px auto;
    gap: 8px;
  }

  .icon-action {
    width: 28px;
    height: 28px;
    min-height: 28px;
  }
}
