:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-2: #b45309;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

a {
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
}

button,
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  min-height: 42px;
  padding: 10px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

textarea {
  resize: vertical;
}

input,
select,
textarea {
  min-width: 0;
}

select {
  appearance: none;
  cursor: pointer;
  padding-right: 42px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%),
    linear-gradient(to right, #edf1f5, #edf1f5);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%,
    calc(100% - 36px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px, 1px 22px;
}

select:hover,
input:hover,
textarea:hover {
  border-color: #b8c1cc;
  background-color: #fbfcfd;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
  outline: none;
}

select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  background-color: #f0f3f6;
  color: var(--muted);
}

option {
  background: #fff;
  color: var(--text);
}

button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:active,
.small-button:active,
.item:active,
.task-card:active,
.calendar-item:active {
  transform: translateY(1px);
}

.danger-button {
  background: var(--danger);
  border-color: var(--danger);
}

.small-danger-button {
  width: auto;
  min-height: 30px;
  padding: 5px 9px;
  background: #fff;
  border-color: #f3b4ae;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}

input[type="checkbox"] {
  width: auto;
  margin: 0;
}

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

h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  margin-bottom: 8px;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
}

.brand {
  font-weight: 800;
}

.nav {
  display: flex;
  gap: 16px;
  align-items: center;
  min-width: 0;
  color: var(--muted);
}

.nav a,
.nav span,
.topbar-menu summary {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.topbar-menu {
  position: relative;
}

.topbar-menu summary {
  gap: 7px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
  font-weight: 700;
}

.topbar-menu summary::-webkit-details-marker {
  display: none;
}

.topbar-menu summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.15s ease;
}

.topbar-menu[open] summary::after {
  transform: translateY(2px) rotate(225deg);
}

.topbar-menu-panel {
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  z-index: 5;
  display: grid;
  gap: 12px;
  width: min(360px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(31, 41, 51, 0.14);
}

.topbar-menu-link {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--text);
  font-weight: 700;
}

.topbar-menu-link:hover {
  border-color: var(--accent);
}

.topbar-project-form {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.topbar-project-form strong {
  font-size: 13px;
}

.page {
  width: min(1380px, calc(100vw - 32px));
  margin: 28px auto 56px;
}

.auth-panel {
  width: min(420px, 100%);
  margin: 80px auto 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.layout {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.two-columns {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  align-items: start;
}

.two-columns > *,
.side,
.main-column {
  min-width: 0;
}

.section-head {
  display: flex;
  gap: 20px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-head > * {
  min-width: 0;
}

.stack,
.quick-form,
.toolbar-form,
.task-edit {
  display: grid;
  gap: 12px;
}

.toolbar-form {
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.3fr) 140px;
  margin-bottom: 16px;
}

.quick-form {
  grid-template-columns: minmax(180px, 1fr) 130px 120px 190px minmax(140px, 0.7fr) 110px;
  margin-bottom: 20px;
}

.status-form {
  display: grid;
  grid-template-columns: 180px 100px;
  gap: 8px;
}

.task-overview-layout,
.overview-status-grid {
  display: grid;
  gap: 18px;
}

.today-layout {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  align-items: start;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.dashboard-projects {
  position: sticky;
  top: 82px;
}

.dashboard-projects .section-head {
  align-items: center;
}

.dashboard-project-list {
  gap: 8px;
}

.dashboard-project {
  min-height: 62px;
}

.dashboard-project .badge {
  flex: 0 0 auto;
}

.dashboard-main {
  min-width: 0;
}

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

.dashboard-task-section:first-child {
  grid-column: 1 / -1;
}

.dashboard-task-section h2 {
  margin-bottom: 12px;
}

.task-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(170px, 1fr) minmax(160px, 1fr) minmax(160px, 1fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.checkbox-label {
  display: flex;
  min-height: 42px;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  color: var(--text);
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.clear-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
}

.overview-status-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tight-head {
  margin-bottom: 14px;
}

.stats,
.task-actions,
.project-actions,
.calendar-nav {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.overview-task {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
}

.overview-task:hover {
  border-color: var(--accent);
}

.overview-task-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.overview-task-main p {
  margin: 2px 0 0;
  color: var(--muted);
}

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

.task-actions form {
  margin: 0;
}

.project-actions {
  justify-content: flex-end;
}

.project-actions form {
  margin: 0;
}

.calendar-nav {
  justify-content: flex-end;
}

.calendar-stats {
  margin: -8px 0 18px;
}

.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.calendar-day {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 260px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.calendar-day.is-today {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.22);
}

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

.calendar-day-head div,
.calendar-items,
.calendar-item {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.calendar-items {
  gap: 8px;
}

.calendar-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fbfcfd;
}

.calendar-item:hover {
  border-color: var(--accent);
}

.meeting-event {
  border-left-color: var(--accent-2);
}

.event-kind {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.task-drag-error {
  display: none;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #f3b4ae;
  border-radius: 8px;
  background: #fff1f0;
  color: var(--danger);
  font-weight: 700;
}

.task-drag-error.is-visible {
  display: block;
}

[data-task-card] {
  cursor: grab;
}

[data-task-card].is-dragging {
  opacity: 0.45;
  cursor: grabbing;
}

[data-task-dropzone] {
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

[data-task-dropzone].is-drop-target {
  border-color: var(--accent);
  background: #eefaf8;
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.18);
}

.small-button {
  display: inline-flex;
  width: auto;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

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

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

.side {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.main-column {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.side > section,
.panel,
.task-edit {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.list {
  display: grid;
  gap: 10px;
}

.compact {
  gap: 8px;
}

.item,
.task-card {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.item:hover,
.task-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
}

.item > span,
.task-card > span,
.task-card strong,
.item strong,
.item small,
.task-card small {
  min-width: 0;
}

.block {
  display: block;
}

.block p {
  margin: 6px 0;
  overflow-wrap: anywhere;
}

.today-more-link {
  margin: 12px 0 0;
}

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

.badge,
.deadline {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #e6f3f1;
  color: #115e59;
  font-size: 12px;
  font-weight: 700;
}

.deadline {
  background: #fff4e5;
  color: var(--accent-2);
}

.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
  min-width: 0;
}

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

.column {
  min-height: 180px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  min-width: 0;
}

.task-card {
  display: grid;
  align-items: start;
  justify-content: stretch;
  min-height: 92px;
  margin-bottom: 10px;
  border-left: 4px solid var(--accent);
  overflow-wrap: anywhere;
}

.overview-task-card {
  gap: 6px;
}

.overview-task-card p {
  margin: 0;
  color: var(--muted);
}

.priority-high,
.priority-critical {
  border-left-color: var(--danger);
}

.priority-low {
  border-left-color: #475467;
}

.muted-link,
small,
.empty {
  color: var(--muted);
}

.empty {
  margin: 0;
}

.error {
  color: var(--danger);
  font-weight: 700;
}

.checklist {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.checklist-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.checklist-toggle label {
  display: flex;
  grid-template-columns: none;
  flex-direction: row;
  gap: 10px;
  align-items: center;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
}

.checklist-row.is-done span {
  color: var(--muted);
  text-decoration: line-through;
}

.checklist-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

label input,
label select,
label textarea {
  color: var(--text);
  font-weight: 400;
}

@media (max-width: 1220px) {
  .two-columns {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    gap: 18px;
  }

  .quick-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kanban {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 12px;
  }

  .side {
    gap: 16px;
  }

  .side > section,
  .panel,
  .task-edit {
    padding: 16px;
  }
}

@media (max-width: 1120px) {
  .two-columns,
  .today-layout {
    grid-template-columns: 1fr;
  }

  .quick-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1000px) {
  .two-columns,
  .dashboard-layout,
  .today-layout,
  .overview-status-grid,
  .overview-task,
  .calendar-week,
  .grid-2,
  .toolbar-form,
  .task-filters,
  .quick-form,
  .checklist-add {
    grid-template-columns: 1fr;
  }

  .section-head,
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .nav {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .topbar-menu-panel {
    left: 0;
    right: auto;
  }

  .status-form {
    grid-template-columns: 1fr;
  }

  .dashboard-projects {
    position: static;
  }

  .dashboard-task-grid {
    grid-template-columns: 1fr;
  }

  .kanban {
    grid-template-columns: repeat(3, minmax(260px, 1fr));
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .column {
    scroll-snap-align: start;
  }
}

@media (max-width: 700px) {
  body {
    font-size: 14px;
  }

  button,
  input,
  select,
  textarea {
    min-height: 44px;
    padding: 10px 11px;
  }

  h1 {
    font-size: clamp(25px, 9vw, 34px);
  }

  .topbar {
    gap: 10px;
    min-height: auto;
    padding: 10px 14px;
  }

  .brand {
    font-size: 17px;
  }

  .nav {
    width: 100%;
    gap: 8px;
  }

  .nav a,
  .nav span,
  .topbar-menu summary {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-size: 13px;
  }

  .topbar-menu {
    position: static;
    flex: 1 1 100%;
  }

  .topbar-menu-panel {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: 8px;
    overflow: visible;
  }

  .topbar-menu-panel .topbar-menu-link {
    justify-content: flex-start;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 6px;
  }

  .page {
    width: min(100% - 24px, 1380px);
    margin-top: 18px;
    margin-bottom: 34px;
  }

  .auth-panel {
    margin-top: 36px;
    padding: 18px;
  }

  .section-head {
    gap: 12px;
    margin-bottom: 16px;
  }

  .stats,
  .task-actions,
  .project-actions,
  .calendar-nav,
  .filter-actions {
    gap: 7px;
  }

  .task-actions,
  .project-actions,
  .calendar-nav,
  .filter-actions {
    justify-content: flex-start;
  }

  .task-actions form,
  .project-actions form,
  .task-actions .small-button,
  .project-actions .small-button,
  .calendar-nav .small-button,
  .stats .small-button,
  .filter-actions > * {
    flex: 1 1 120px;
  }

  .task-actions .small-button,
  .project-actions .small-button,
  .calendar-nav .small-button,
  .stats .small-button,
  .filter-actions .small-button,
  .small-button,
  .small-danger-button {
    width: 100%;
    min-height: 38px;
  }

  .side > section,
  .panel,
  .task-edit {
    padding: 14px;
  }

  .item,
  .checklist-row {
    align-items: stretch;
    flex-direction: column;
  }

  .item {
    gap: 8px;
  }

  .block .item-head,
  .item-head {
    align-items: stretch;
    flex-direction: column;
  }

  .item .badge,
  .item .deadline {
    align-self: flex-start;
  }

  .item-head,
  .column-head {
    gap: 8px;
  }

  .kanban {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-right: 0;
    padding-right: 0;
    overflow: visible;
    scroll-snap-type: none;
  }

  .column {
    min-height: auto;
    padding: 12px;
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(31, 41, 51, 0.06);
    scroll-snap-align: none;
  }

  .column:empty {
    min-height: 96px;
  }

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

  .overview-task {
    gap: 10px;
    padding: 10px;
  }

  .badge,
  .deadline {
    white-space: normal;
  }

  .checklist-row,
  .checklist-add {
    grid-template-columns: 1fr;
  }

  .checklist-row form {
    width: 100%;
  }

  .calendar-day {
    min-height: auto;
  }

  .calendar-day-head {
    align-items: center;
  }

  .calendar-item {
    padding: 11px;
  }

  [data-task-card] {
    cursor: pointer;
  }
}

@media (max-width: 420px) {
  .page {
    width: min(100% - 18px, 1380px);
  }

  .topbar {
    padding-right: 9px;
    padding-left: 9px;
  }

  .nav a,
  .nav span,
  .topbar-menu summary {
    flex: 1 1 auto;
    justify-content: center;
  }

  .kanban {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
