:root {
  --bg: #e9f1fb;
  --bg-grad-top: #f2f7ff;
  --bg-alt: #dde8f8;
  --surface: #f6f9ff;
  --surface-soft: #eaf1ff;
  --ink: #152033;
  --ink-soft: #4f5f7d;
  --border: #c8d8f6;
  --blue: #2c78d7;
  --green: #1f9f67;
  --teal: #11b6a5;
  --danger: #df4366;
  --ok: #1f9f67;
  --shadow: 0 14px 26px rgba(66, 99, 148, 0.12);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-sm: 11px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", "Avenir Next", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at -10% -20%, rgba(48, 120, 255, 0.14), transparent 60%),
    radial-gradient(700px 420px at 110% 0%, rgba(31, 159, 103, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-top) 0%, var(--bg) 100%);
  min-height: 100vh;
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 360px;
  height: 360px;
  border-radius: 50%;
  top: -120px;
  right: -90px;
  background: radial-gradient(circle, rgba(31, 159, 103, 0.2), transparent 70%);
}

body::after {
  width: 420px;
  height: 420px;
  border-radius: 50%;
  left: -140px;
  bottom: -160px;
  background: radial-gradient(circle, rgba(44, 120, 215, 0.2), transparent 68%);
}

body[data-theme="dark"] {
  --bg: #0d1422;
  --bg-grad-top: #0f1829;
  --surface: #162239;
  --surface-soft: #111a2b;
  --ink: #e8f0ff;
  --ink-soft: #9fb3d6;
  --border: #2b3f60;
  --blue: #4a84ff;
  --green: #33bf83;
  --teal: #2bc5ac;
  --danger: #ff769b;
  --ok: #66d79c;
}

body.app-page {
  min-height: 100dvh;
  overflow: auto;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1480px, calc(100% - 44px));
  margin: 22px auto 16px;
  min-height: calc(100dvh - 38px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
}

.topbar,
.workspace-frame {
  background: rgba(241, 247, 255, 0.86);
  border: 1px solid rgba(184, 206, 244, 0.95);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.topbar {
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.app-title {
  margin: 0;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
}

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

button,
input,
select,
textarea,
.hub-link {
  font-family: inherit;
}

button,
.hub-link {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  min-height: 38px;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  color: #1f3f67;
  background: var(--surface);
}

.primary-btn {
  border: 0;
  color: #fff;
  background: linear-gradient(95deg, var(--blue), var(--green));
  box-shadow: 0 8px 18px rgba(42, 134, 103, 0.2);
}

.ghost-btn {
  background: var(--surface);
  color: #1f3f67;
}

.sync-status {
  margin: 0;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 800;
}

.sync-status.ok {
  border-color: #9ee0bf;
  color: var(--ok);
}

.sync-status.warn {
  border-color: #ffcd98;
  color: #ac5e07;
}

.sync-status.error {
  border-color: #f8b8cb;
  color: var(--danger);
}

.theme-switch {
  display: inline-flex;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.theme-btn {
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 8px 10px;
  font-size: 0.82rem;
  background: var(--surface);
}

.theme-btn:last-child {
  border-right: 0;
}

.theme-btn.active {
  color: #fff;
  background: linear-gradient(95deg, var(--blue), var(--green));
}

.version-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--ink-soft);
}

.project-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.project-tab {
  border: 1px solid rgba(184, 206, 244, 0.95);
  border-radius: 12px;
  padding: 9px 14px;
  background: rgba(238, 245, 255, 0.86);
  color: #234364;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
}

.project-tab.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(100deg, var(--blue), var(--green));
}

.project-tab strong {
  font-size: 0.96rem;
}

.workspace-frame {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 18px;
  background: rgba(240, 247, 255, 0.74);
}

.workspace-frame-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.workspace-frame-main {
  display: grid;
  gap: 4px;
}

.workspace-frame-title {
  margin: 0;
  font-size: clamp(1.5rem, 2vw, 2rem);
  font-family: "Space Grotesk", "Manrope", sans-serif;
  line-height: 1.15;
}

.workspace-frame-subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 700;
}

.workspace-frame-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.workspace {
  display: grid;
  grid-template-rows: minmax(320px, auto) minmax(720px, auto);
  gap: 14px;
}

.bugs-panel {
  min-height: 320px;
}

.roadmap-panel {
  min-height: 720px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.panel h2 {
  margin: 0;
  font-size: 1.28rem;
  font-family: "Space Grotesk", "Manrope", sans-serif;
}

.panel-subtitle {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  gap: 10px;
}

.bugs-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.bugs-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

.bugs-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 11px 12px;
  font-size: 0.86rem;
  font-weight: 800;
  color: #325076;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}

.bugs-table tbody td {
  padding: 12px;
  border-top: 1px solid #d6e4fb;
  font-size: 0.93rem;
  vertical-align: top;
}

.bug-empty td {
  color: var(--ink-soft);
  text-align: center;
  font-weight: 700;
  padding: 22px 10px;
}

.bug-title-input,
.bug-text-input,
.bug-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 11px;
  font-size: 0.9rem;
}

.bug-title-input {
  min-width: 280px;
}

.bug-select {
  min-width: 130px;
}

.bug-updated-at {
  white-space: nowrap;
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.bug-delete {
  border: 1px solid #f5bfd1;
  background: #ffeef4;
  color: var(--danger);
  border-radius: 11px;
  font-weight: 800;
  padding: 9px 13px;
}

.board {
  margin: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(304px, 1fr);
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  min-height: 0;
  align-items: stretch;
  padding: 2px 2px 8px;
}

.column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

.column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.column-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.column-title {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  border-radius: 8px;
  padding: 2px 4px;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
}

.column-title:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--surface);
}

.column-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.task-list {
  margin: 0;
  padding: 10px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.task-list.drop-target {
  outline: 2px dashed var(--blue);
  outline-offset: -3px;
  border-radius: 10px;
  background: rgba(44, 120, 215, 0.08);
}

.task {
  display: grid;
  grid-template-columns: 24px 24px 1fr 24px;
  gap: 8px;
  align-items: flex-start;
  padding: 10px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.task.dragging {
  opacity: 0.45;
}

.task-drag-handle,
.column-drag-handle {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1;
  padding: 4px 6px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.task-drag-handle:active,
.column-drag-handle:active {
  cursor: grabbing;
}

.task input[type="checkbox"] {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.task-text {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  width: 100%;
  min-height: 24px;
  resize: none;
  overflow: hidden;
  font: inherit;
  line-height: 1.34;
  border-radius: 7px;
}

.task-text:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--surface);
}

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

.task-delete,
.column-delete,
.column-add-task {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: #1f3f67;
  font-size: 0.86rem;
  font-weight: 800;
  padding: 6px 10px;
}

.column.column-dragging {
  opacity: 0.55;
}

.board.column-drop-active {
  outline: 2px dashed var(--blue);
  outline-offset: -3px;
  border-radius: 12px;
}

.column-foot {
  margin-top: auto;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.column-count {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 700;
}

.empty-board {
  margin: 0;
  padding: 14px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 700;
}

.site-footer {
  margin: 18px 0 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--surface);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: center;
  align-items: center;
}

.site-footer a {
  color: #234364;
  font-size: 0.93rem;
  font-weight: 700;
  text-decoration: none;
  transition: color 150ms ease;
}

.site-footer a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.site-footer-sep {
  color: var(--ink-soft);
  font-weight: 700;
}

body[data-theme="dark"] .topbar,
body[data-theme="dark"] .workspace-frame,
body[data-theme="dark"] .site-footer {
  background: rgba(20, 31, 52, 0.82);
  border-color: rgba(57, 79, 118, 0.95);
}

body[data-theme="dark"] .panel {
  background: #162239;
  border-color: #2b3f60;
}

body[data-theme="dark"] .project-tab {
  color: #c9dbff;
  background: rgba(21, 34, 56, 0.9);
  border-color: rgba(57, 79, 118, 0.95);
}

body[data-theme="dark"] .site-footer a {
  color: #c6dbff;
}

body[data-theme="dark"] .site-footer a:hover {
  color: #e8f0ff;
}

body.auth-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-layout {
  width: min(520px, 100%);
}

.auth-card {
  background: rgba(240, 247, 255, 0.88);
  border: 1px solid rgba(184, 206, 244, 0.95);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 10px;
}

.auth-title {
  margin: 0;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: 1.8rem;
}

.auth-subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 600;
}

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

.auth-label {
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.auth-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 11px;
  font-size: 0.94rem;
}

.auth-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(44, 120, 215, 0.2);
}

.auth-submit {
  margin-top: 6px;
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
}

.auth-back {
  margin: 4px 0 0;
  font-size: 0.9rem;
}

.auth-back a {
  color: #234364;
  text-decoration: none;
  font-weight: 700;
}

.auth-back a:hover {
  text-decoration: underline;
}

body[data-theme="dark"].auth-page .auth-card {
  background: rgba(20, 31, 52, 0.82);
  border-color: rgba(57, 79, 118, 0.95);
}

@media (max-width: 1100px) {
  .app {
    width: min(1480px, calc(100% - 20px));
    margin: 10px auto 8px;
    min-height: calc(100dvh - 18px);
    gap: 10px;
  }

  .workspace {
    grid-template-rows: minmax(300px, auto) minmax(680px, auto);
  }
}

@media (max-width: 900px) {
  .topbar-actions,
  .workspace-frame-actions {
    width: 100%;
  }

  .project-tab {
    width: 100%;
    justify-content: space-between;
  }

  .workspace {
    grid-template-rows: minmax(280px, auto) minmax(620px, auto);
  }

  .board {
    grid-auto-columns: minmax(268px, 1fr);
  }
}
