:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --line: #d9e0ea;
  --line-strong: #c5cedb;
  --text: #172033;
  --muted: #667085;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #059669;
  --yellow: #d97706;
  --red: #dc2626;
  --purple: #7c3aed;
  --shadow: 0 18px 48px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  min-height: 100vh;
}

.app-shell.auth-hidden {
  display: none;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.top-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.sync-status {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1e40af;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.sync-status.warning {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.sync-status.error {
  border-color: #fecaca;
  background: #fff1f2;
  color: #b91c1c;
}

.layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: calc(100vh - 66px);
}

.sidebar {
  padding: 18px 14px;
  background: #eef2f7;
  border-right: 1px solid var(--line);
}

.side-section {
  padding: 0 0 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.side-section h2,
.section-heading h2 {
  margin: 0 0 10px;
  color: #394150;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.project-button {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #344054;
  text-align: left;
}

.project-button.active {
  background: #ffffff;
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(23, 32, 51, 0.05);
}

.project-key {
  display: grid;
  place-items: center;
  width: 34px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 5px;
  background: var(--blue);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.project-key.muted {
  background: #64748b;
}

.user-list {
  display: grid;
  gap: 8px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 6px;
}

.user-row div {
  min-width: 0;
}

.user-row strong,
.user-row span {
  display: block;
}

.user-row strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row div > span {
  color: var(--muted);
  font-size: 12px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--avatar-color, #64748b);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.avatar.small {
  width: 26px;
  height: 26px;
  font-size: 10px;
}

.board-area {
  min-width: 0;
  padding: 24px;
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.board-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 8px;
  min-width: 290px;
}

.board-stats div {
  min-height: 58px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.board-stats strong,
.board-stats span {
  display: block;
}

.board-stats strong {
  font-size: 20px;
}

.board-stats span {
  color: var(--muted);
  font-size: 12px;
}

.board-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 210px) minmax(150px, 190px);
  gap: 10px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: #4b5563;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}

textarea {
  min-height: 116px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.board {
  display: grid;
  grid-auto-columns: minmax(280px, 320px);
  grid-auto-flow: column;
  align-items: start;
  gap: 14px;
  min-height: calc(100vh - 244px);
  overflow-x: auto;
  padding: 0 0 18px;
  scrollbar-color: #aab5c4 transparent;
}

.lane {
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr);
  min-height: calc(100vh - 262px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.lane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 62px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.lane-header h2 {
  margin: 0;
  font-size: 14px;
}

.lane-header span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.ticket-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 220px;
  padding: 10px;
  transition: background 140ms ease, outline-color 140ms ease;
}

.ticket-list.drag-over {
  outline: 2px solid rgba(37, 99, 235, 0.4);
  outline-offset: -5px;
  background: #eef4ff;
}

.ticket-card {
  display: grid;
  gap: 9px;
  position: relative;
  padding: 12px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(23, 32, 51, 0.06);
}

.ticket-card:hover,
.ticket-card:focus {
  border-color: var(--blue);
  box-shadow: 0 6px 18px rgba(23, 32, 51, 0.1);
  outline: none;
}

.ticket-card.dragging {
  opacity: 0.55;
}

.ticket-card-top,
.ticket-footer,
.assignee,
.card-actions {
  display: flex;
  align-items: center;
}

.ticket-card-top,
.ticket-footer {
  justify-content: space-between;
  gap: 10px;
}

.ticket-key {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ticket-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.ticket-card p {
  display: -webkit-box;
  min-height: 38px;
  margin: 0;
  overflow: hidden;
  color: #586174;
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.priority,
.estimate {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.priority-critical {
  background: #fee2e2;
  color: #991b1b;
}

.priority-high {
  background: #ffedd5;
  color: #9a3412;
}

.priority-medium {
  background: #dbeafe;
  color: #1e40af;
}

.priority-low {
  background: #dcfce7;
  color: #166534;
}

.assignee {
  min-width: 0;
  gap: 7px;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.assignee span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.estimate {
  background: #eef2f7;
  color: #475467;
}

.card-actions {
  gap: 6px;
}

.card-actions button,
.icon-button,
.danger-icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: #475467;
  font-weight: 800;
}

.card-actions button:hover,
.icon-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.danger-icon-button:hover {
  border-color: var(--red);
  color: var(--red);
}

.empty-lane {
  display: grid;
  place-items: center;
  min-height: 92px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  padding: 0 13px;
  border-radius: 6px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #ffffff;
}

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

.secondary-button {
  border: 1px solid #0f766e;
  background: #0f766e;
  color: #ffffff;
}

.ghost-button {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: #344054;
}

.ghost-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.danger-button {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #b91c1c;
}

.hidden {
  display: none !important;
}

.dialog {
  width: min(720px, calc(100vw - 30px));
  max-height: calc(100vh - 30px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.settings-dialog {
  width: min(660px, calc(100vw - 30px));
}

.users-dialog {
  width: min(620px, calc(100vw - 30px));
}

.login-dialog {
  width: min(430px, calc(100vw - 30px));
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog form {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.dialog-body {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 20px;
}

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

.wide-field {
  grid-column: 1 / -1;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
}

.compact-actions {
  grid-template-columns: 1fr auto;
}

.form-message {
  min-height: 20px;
  margin: -6px 0 0;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 700;
}

.managed-user-list {
  max-height: 320px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.managed-user-list .user-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(116px, 140px) minmax(130px, 170px) auto;
  padding: 10px;
  border-radius: 6px;
  background: #ffffff;
}

.managed-user-list .user-row + .user-row {
  margin-top: 6px;
}

.managed-user-list .user-row > div {
  min-width: 0;
}

.managed-user-list .danger-icon-button {
  margin-left: auto;
}

.managed-user-list select,
.managed-user-list input {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 12px;
}

.account-meta {
  display: grid;
  gap: 2px;
}

.account-meta strong,
.account-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog .add-user-form {
  gap: 12px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
}

.lane-settings {
  display: grid;
  gap: 8px;
}

.lane-setting-row,
.add-lane-row {
  display: grid;
  align-items: end;
  gap: 8px;
}

.lane-setting-row {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
}

.add-lane-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

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

  .sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-section {
    margin: 0;
    padding: 0;
    border: 0;
  }

  .board-heading {
    display: grid;
  }

  .board-stats {
    min-width: 0;
  }

  .board-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .sidebar,
  .board-toolbar,
  .field-grid,
  .add-lane-row {
    grid-template-columns: 1fr;
  }

  .board-area {
    padding: 16px 12px;
  }

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

  .board-stats div {
    padding: 8px;
  }

  .dialog-actions {
    grid-template-columns: 1fr;
  }

  .dialog-actions span {
    display: none;
  }

  .managed-user-list .user-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .managed-user-list .user-row select,
  .managed-user-list .user-row input {
    grid-column: 2 / -1;
  }
}
