:root {
  color-scheme: light;
  --bg-solid: #eef3f8;
  --bg: radial-gradient(circle at top left, rgba(126, 91, 239, 0.18), transparent 35%),
        radial-gradient(circle at top right, rgba(54, 195, 255, 0.16), transparent 28%),
        linear-gradient(180deg, #f8fbff 0%, #eef3f8 100%);
  --panel: rgba(255, 255, 255, 0.64);
  --panel-strong: rgba(255, 255, 255, 0.82);
  --border: rgba(255, 255, 255, 0.45);
  --text: #151922;
  --muted: #637083;
  --shadow: 0 20px 50px rgba(20, 29, 45, 0.10);
  --soft: rgba(91, 108, 134, 0.1);
  --soft-strong: rgba(255, 255, 255, 0.56);
  --success: #25a168;
  --danger: #e44b4b;
  --warning: #efae3a;
  --blue: #3a8cff;
  --blue-soft: rgba(58, 140, 255, 0.14);
  --red-soft: rgba(228, 75, 75, 0.12);
  --done-bg: rgba(38, 162, 105, 0.08);
  --done-text: #728091;
  --input-bg: rgba(255, 255, 255, 0.64);
  --action-bg: rgba(255, 255, 255, 0.55);
  --action-border: rgba(255, 255, 255, 0.35);
  --tab-active: rgba(255, 255, 255, 0.78);
  --badge-red: #ff3b30;
  --badge-red-text: #ffffff;
}

body.dark,
.login-body.dark,
.app-body.dark {
  color-scheme: dark;
  --bg-solid: #0b1017;
  --bg: radial-gradient(circle at top left, rgba(121, 88, 255, 0.18), transparent 32%),
        radial-gradient(circle at top right, rgba(61, 198, 255, 0.12), transparent 24%),
        linear-gradient(180deg, #0b1017 0%, #101722 100%);
  --panel: rgba(16, 23, 34, 0.62);
  --panel-strong: rgba(14, 20, 31, 0.78);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f5f7fb;
  --muted: #93a0b3;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
  --soft: rgba(255, 255, 255, 0.06);
  --soft-strong: rgba(255, 255, 255, 0.05);
  --success: #33c37d;
  --danger: #ff7474;
  --warning: #ffc15a;
  --blue: #6bb9ff;
  --blue-soft: rgba(107, 185, 255, 0.12);
  --red-soft: rgba(255, 116, 116, 0.10);
  --done-bg: rgba(51, 195, 125, 0.08);
  --done-text: #8c98ab;
  --input-bg: rgba(255, 255, 255, 0.04);
  --action-bg: rgba(255, 255, 255, 0.04);
  --action-border: rgba(255, 255, 255, 0.08);
  --tab-active: rgba(255, 255, 255, 0.07);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-solid);
  color: var(--text);
}
body {
  padding: 0;
  background-image: var(--bg);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
textarea { resize: vertical; }

.glass-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.app-shell {
  width: min(1240px, calc(100% - 24px));
  margin: 0 auto 20px;
  display: grid;
  gap: 14px;
  padding-top: 0;
}

.app-topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-top: 0;
  margin-top: 0;
}

.composer-panel,
.tabs-panel,
.filters-panel,
.board-panel,
.team-panel {
  padding: 18px 20px;
}

.summary-row,
.top-actions,
.tabs-header {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  background: var(--soft-strong);
  color: var(--muted);
  font-size: 0.92rem;
}

.active-chip {
  color: var(--text);
  background: var(--blue-soft);
}

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

.composer-grid,
.filters-grid,
.team-form-grid {
  display: grid;
  gap: 12px;
  align-items: end;
}

.composer-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr) 220px auto;
}

.filters-grid {
  grid-template-columns: minmax(0, 1.2fr) 200px 180px auto;
  margin-bottom: 14px;
}

.team-form-grid {
  grid-template-columns: minmax(0, 1fr) 220px 220px minmax(0, 1fr) auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 0.9rem;
  color: var(--muted);
}

.field input,
.field select,
.field textarea,
.login-form input,
.edit-client-input,
.edit-title-input,
.edit-note-input,
.edit-assignee-select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s ease, transform 0.15s ease, background 0.2s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.login-form input:focus,
.edit-client-input:focus,
.edit-title-input:focus,
.edit-note-input:focus,
.edit-assignee-select:focus {
  border-color: rgba(58, 140, 255, 0.42);
}

.primary-btn,
.secondary-btn,
.icon-btn,
.tab-btn {
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.2s ease, background 0.2s ease, filter 0.2s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.icon-btn:hover,
.tab-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  padding: 14px 18px;
  border-radius: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #7a5cff, #36c3ff);
  box-shadow: 0 12px 24px rgba(80, 115, 255, 0.22);
}

.primary-btn.full { width: 100%; }

.secondary-btn,
.link-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 12px 16px;
  border-radius: 16px;
  font-weight: 600;
  background: var(--soft-strong);
  border-color: var(--border);
  color: var(--text);
}

.tabs-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.tab-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--soft-strong);
  border-color: var(--border);
  color: var(--text);
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--tab-active);
  border-color: rgba(58, 140, 255, 0.28);
  box-shadow: inset 0 0 0 1px rgba(58, 140, 255, 0.16);
}

.tab-badge {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--badge-red);
  color: var(--badge-red-text);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.list-head,
.task-row {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) 180px 176px 44px;
  gap: 0;
  align-items: center;
}

.list-head {
  padding: 0 12px 14px;
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.task-row {
  padding: 14px 12px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 22px;
}

.task-row.done {
  background: var(--done-bg);
}

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

.check-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.check-wrap input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--success);
  cursor: pointer;
}

.task-main {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.task-title,
.readonly-line {
  font-size: 1rem;
  line-height: 1.4;
  word-break: break-word;
}

.task-row.done .task-title {
  text-decoration: line-through;
  color: var(--done-text);
}

.task-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.client-pill,
.pin-pill,
.group-pill,
.assignee-pill,
.neutral-pill,
.readonly-chip,
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--soft-strong);
}

.pin-pill,
.role-admin {
  color: var(--blue);
  background: var(--blue-soft);
}

.group-pill {
  color: var(--danger);
  background: var(--red-soft);
}

.task-note-preview {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  padding-top: 2px;
  white-space: normal;
}

.task-date {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.task-date-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

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

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--action-bg);
  border-color: var(--action-border);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg,
.drag-handle svg {
  width: 18px;
  height: 18px;
  display: block;
}

.icon-btn.delete:hover { color: var(--danger); border-color: rgba(228, 75, 75, 0.35); }
.icon-btn.pin.active { color: var(--blue); border-color: rgba(58, 140, 255, 0.32); background: var(--blue-soft); }
.icon-btn.save:hover { color: var(--success); border-color: rgba(37, 161, 104, 0.35); }
.icon-btn.cancel:hover { color: var(--warning); border-color: rgba(239, 174, 58, 0.35); }
.icon-btn.edit:hover { color: var(--blue); border-color: rgba(58, 140, 255, 0.32); }
.icon-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: var(--muted);
  cursor: grab;
  user-select: none;
}

.drag-handle.disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.edit-stack {
  display: grid;
  gap: 8px;
}

.edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 8px;
}

.readonly-chip {
  min-height: 50px;
  border-radius: 16px;
}

.empty-state,
.empty-mini {
  padding: 42px 18px;
  text-align: center;
  color: var(--muted);
}

.flash {
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 0.95rem;
}

.flash-error {
  background: var(--red-soft);
  color: var(--danger);
  border: 1px solid rgba(228, 75, 75, 0.2);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  background: rgba(15, 20, 30, 0.9);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.28);
  transition: transform 0.2s ease, opacity 0.2s ease;
  z-index: 50;
  max-width: min(92vw, 360px);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.team-panel summary {
  cursor: pointer;
  list-style: none;
  font-weight: 700;
}

.team-panel summary::-webkit-details-marker {
  display: none;
}

.team-panel-body {
  margin-top: 16px;
  display: grid;
  gap: 14px;
}

.team-users {
  display: grid;
  gap: 10px;
}

.user-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.user-card-name {
  font-weight: 700;
}

.user-card-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.role-collaborator {
  color: var(--text);
}

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

.login-card {
  width: min(500px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.login-brand h1 {
  margin: 14px 0 10px;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
}

.login-brand p,
.login-hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.login-form label {
  display: grid;
  gap: 8px;
}

.login-form span {
  color: var(--muted);
  font-size: 0.92rem;
}

.login-hint {
  margin-top: 18px;
  font-size: 0.92rem;
}

.desktop-only { display: grid; }

@media (max-width: 1180px) {
  .composer-grid {
    grid-template-columns: 1fr 1fr;
  }

  .composer-grid > .primary-btn {
    grid-column: 1 / -1;
  }

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

  .team-form-grid > .primary-btn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  .composer-grid,
  .filters-grid,
  .team-form-grid,
  .edit-grid {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .app-topbar {
    justify-content: flex-start;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100%, calc(100% - 16px));
    margin: 0 auto 20px;
  }

  .composer-panel,
  .tabs-panel,
  .filters-panel,
  .board-panel,
  .team-panel {
    padding: 16px;
    border-radius: 22px;
  }

  .desktop-only { display: none; }

  .task-row {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    grid-template-areas:
      "check content drag"
      ". date drag"
      ". actions actions";
    row-gap: 10px;
  }

  .task-row > .check-wrap { grid-area: check; }
  .task-row > .task-main { grid-area: content; }
  .task-row > .task-date { grid-area: date; white-space: normal; }
  .task-row > .row-actions { grid-area: actions; justify-content: flex-start; }
  .task-row > .drag-handle { grid-area: drag; justify-self: end; }

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