:root {
  --blue-950: #062a4a;
  --blue-900: #0a3d6b;
  --blue-800: #0c4f8a;
  --blue-700: #0060ae;
  --blue-600: #1a7bc4;
  --blue-100: #e6f3fb;
  --sand-50: #f4f8fb;
  --sand-100: #e8eef4;
  --ink: #15202b;
  --ink-soft: #4a5c6a;
  --line: #c9d6e2;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --ok: #027a48;
  --ok-bg: #ecfdf3;
  --info: #175cd3;
  --info-bg: #eff8ff;
  --shadow: 0 18px 50px rgba(6, 42, 74, 0.14);
  --radius: 14px;
  --sidebar: 260px;
  --font: "Manrope", sans-serif;
  --display: "Instrument Serif", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(0, 96, 174, 0.12), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(26, 123, 196, 0.1), transparent 55%),
    linear-gradient(180deg, var(--sand-50), #eef4f9 40%, var(--sand-100));
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.4rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: linear-gradient(180deg, var(--blue-950), var(--blue-900));
  color: #f2f8fc;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 0.35rem 0.4rem;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(145deg, #3b9dd9, #0060ae);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.brand-name {
  margin: 0;
  font-family: var(--display);
  font-size: 1.45rem;
  line-height: 1;
}

.brand-sub {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  opacity: 0.72;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-btn {
  border: 0;
  text-align: left;
  background: transparent;
  color: rgba(244, 250, 247, 0.78);
  padding: 0.72rem 0.9rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-btn.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 700;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field-label {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}

.hint {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  opacity: 0.65;
}

.sidebar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.main {
  padding: 1.5rem 1.75rem 2.5rem;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.9rem, 2.4vw, 2.5rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.view-root {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: rise 0.35s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.stat {
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(217, 210, 198, 0.8);
  backdrop-filter: blur(8px);
}

.stat-label {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  margin: 0.35rem 0 0;
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.panel {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(217, 210, 198, 0.9);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.1rem 1.15rem;
  backdrop-filter: blur(8px);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.panel-head h2,
.section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 140px;
}

.field.grow {
  flex: 1;
  min-width: 180px;
}

.field span,
.form-grid label span {
  font-size: 0.75rem;
  color: var(--ink-soft);
  letter-spacing: 0.03em;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.58rem 0.7rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sidebar .select {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.sidebar .select option {
  color: var(--ink);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(0, 96, 174, 0.18);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 0.62rem 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--blue-700);
  color: #fff;
}

.btn-primary:hover {
  background: var(--blue-800);
}

.btn-secondary {
  background: var(--sand-100);
  border: 1px solid var(--line);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
}

.icon-btn {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  text-align: left;
  padding: 0.75rem 0.55rem;
  border-bottom: 1px solid rgba(217, 210, 198, 0.8);
  vertical-align: top;
}

th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 700;
}

tr:hover td {
  background: rgba(230, 243, 251, 0.45);
}

.row-click {
  cursor: pointer;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-todo { background: #f2f4f7; color: #344054; }
.badge-progress { background: var(--info-bg); color: var(--info); }
.badge-review { background: #f4ebff; color: #6941c6; }
.badge-done { background: var(--ok-bg); color: var(--ok); }
.badge-blocked { background: var(--danger-bg); color: var(--danger); }
.badge-open { background: var(--warn-bg); color: var(--warn); }
.badge-resolved { background: var(--ok-bg); color: var(--ok); }
.badge-planned { background: #f2f4f7; color: #344054; }
.badge-active { background: var(--info-bg); color: var(--info); }
.badge-completed { background: var(--ok-bg); color: var(--ok); }
.badge-paused { background: var(--warn-bg); color: var(--warn); }

.meta {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(217, 210, 198, 0.85);
  background: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.list-item:hover {
  border-color: var(--blue-600);
  transform: translateY(-1px);
}

.list-item h3 {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.person-card {
  border-radius: calc(var(--radius) + 2px);
  border: 1px solid rgba(217, 210, 198, 0.9);
  background: rgba(255, 255, 255, 0.8);
  padding: 1rem;
  min-height: 220px;
}

.person-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.person-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

.availability {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.availability.free { color: var(--ok); }
.availability.busy { color: var(--warn); }
.availability.blocked { color: var(--danger); }

.task-chip {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  background: var(--sand-50);
  border: 1px solid var(--line);
  margin-bottom: 0.55rem;
  cursor: pointer;
}

.task-chip:hover {
  border-color: var(--blue-600);
}

.empty {
  padding: 1.4rem;
  text-align: center;
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 42, 74, 0.48);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 40;
}

/* Author `display` overrides the UA [hidden] rule — keep closed modals invisible */
.modal-backdrop[hidden] {
  display: none !important;
}

.modal {
  width: min(720px, 100%);
  max-height: min(90vh, 820px);
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: rise 0.25s ease both;
}

.modal-head,
.modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
}

.modal-head {
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.modal-foot.has-danger {
  justify-content: space-between;
}

.modal-foot-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.btn-sm {
  padding: 0.38rem 0.65rem;
  font-size: 0.78rem;
}

.person-row {
  display: grid;
  grid-template-columns: 1fr 160px auto;
  gap: 0.55rem;
  align-items: end;
  margin-bottom: 0.55rem;
}

.person-row .field {
  min-width: 0;
}

@media (max-width: 640px) {
  .person-row {
    grid-template-columns: 1fr;
  }
}

.row-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.row-actions .btn {
  transform: none;
}

.row-actions .btn:hover {
  transform: none;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-body {
  padding: 1.1rem 1.15rem;
}

.detail-block {
  margin-bottom: 1rem;
}

.detail-block h3 {
  margin: 0 0 0.45rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

.issue-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: var(--blue-900);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  z-index: 50;
  box-shadow: var(--shadow);
  animation: rise 0.25s ease both;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(6, 42, 74, 0.55);
  backdrop-filter: blur(4px);
}

.boot-screen[hidden] {
  display: none !important;
}

.boot-card {
  background: #fff;
  padding: 1.5rem 1.75rem;
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: center;
  min-width: min(320px, 90vw);
}

.boot-title {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  font-size: 1.35rem;
}

.boot-meta {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.sync-live {
  color: #86efac !important;
}

.sync-connecting {
  color: #fde68a !important;
}

.sync-offline {
  color: rgba(242, 248, 252, 0.72) !important;
}

.sync-error {
  color: #fecaca !important;
}

.deadline-late {
  color: var(--danger);
  font-weight: 700;
}

.deadline-soon {
  color: var(--warn);
  font-weight: 700;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 0.88rem;
}

.subtasks-block {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.subtasks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.subtasks-head > span {
  font-size: 0.82rem;
  font-weight: 600;
}

.subtasks-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.subtask-row {
  display: grid;
  grid-template-columns: auto 1fr minmax(130px, 150px) auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sand-50);
}

.subtask-row.is-done .subtask-title {
  text-decoration: line-through;
  color: var(--ink-soft);
}

.subtask-done {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--blue-700);
  cursor: pointer;
}

.subtask-title {
  min-width: 0;
}

.subtask-remove {
  padding: 0.28rem 0.55rem;
}

.subtasks-empty {
  margin: 0;
  font-size: 0.85rem;
}

.publish-on-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: end;
}

.publish-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ok-bg);
  white-space: nowrap;
  font-size: 0.88rem;
  cursor: pointer;
}

.publish-check input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--ok);
  cursor: pointer;
}

.subtask-detail {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.subtask-detail:last-child {
  border-bottom: none;
}

.subtask-detail.is-done .subtask-detail-title {
  text-decoration: line-through;
  color: var(--ink-soft);
}

.subtask-detail-title {
  font-weight: 600;
  font-size: 0.92rem;
}

@media (max-width: 640px) {
  .subtask-row {
    grid-template-columns: auto 1fr auto;
  }

  .subtask-row .subtask-deadline {
    grid-column: 2 / 3;
  }

  .publish-on-row {
    grid-template-columns: 1fr;
  }
}

.import-preview {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.import-preview table {
  min-width: 100%;
}

.import-preview th,
.import-preview td {
  font-size: 0.78rem;
  padding: 0.55rem 0.45rem;
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--sand-100);
  overflow: hidden;
  margin-top: 0.55rem;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue-800), var(--blue-600));
  border-radius: inherit;
  transition: width 0.35s ease;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .stats,
  .grid-2,
  .team-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 1rem;
  }
}
