:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --line-strong: #c4ccd8;
  --text: #17202e;
  --muted: #667085;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --ok: #047857;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body:has(.workspace) {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body:has(.workspace) .topbar {
  flex: 0 0 auto;
}

body:has(.workspace) .workspace {
  flex: 1 1 auto;
  min-height: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

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

.auth-panel {
  width: min(480px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 36px;
  display: grid;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.primary-action,
.secondary-action,
button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 650;
}

.primary-action,
button[type="submit"] {
  color: white;
  background: var(--accent);
}

.primary-action:hover,
button[type="submit"]:hover {
  background: var(--accent-strong);
}

.secondary-action {
  color: var(--text);
  border-color: var(--line-strong);
  background: white;
}

.notice {
  border-radius: 6px;
  padding: 12px;
}

.notice.danger {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #ffccc7;
}

.topbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-main {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  flex: 0 0 auto;
  font-weight: 800;
}

.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--line-strong);
}

.topbar-title {
  min-width: 0;
  max-width: min(28vw, 520px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: var(--text);
  font-weight: 800;
}

.topbar-title:hover {
  color: var(--accent);
}

.topbar-filter-controls {
  flex: 1 1 720px;
  min-width: 420px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  overflow: hidden;
}

.topbar-filter {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  color: #5f6f85;
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 700;
}

.topbar-filter select {
  width: auto;
  min-width: 112px;
  height: 30px;
  padding: 4px 28px 4px 10px;
  border: 1px solid #cfd8e5;
  border-radius: 7px;
  color: var(--text);
  background: white;
  font-size: 13px;
  font-weight: 700;
}

.topbar-filter select[name="orderBy"] {
  min-width: 132px;
}

.topbar-user {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.topbar-user form {
  margin: 0;
}

.topbar-user button {
  min-height: 32px;
  color: var(--text);
  background: white;
  border-color: var(--line);
}

.compact-action {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
}

.user-menu {
  position: relative;
}

.user-menu-button {
  max-width: 110px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  background: transparent !important;
  border-color: transparent !important;
  padding: 6px 4px;
}

.user-menu-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-button::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.65;
}

.user-menu-button:hover,
.user-menu-button[aria-expanded="true"] {
  color: var(--text);
}

.user-menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  min-width: 118px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.user-menu-popover button {
  width: 100%;
  min-height: 30px;
  justify-content: flex-start;
  color: var(--text);
  background: transparent;
  border-color: transparent;
  text-align: left;
  font-size: 12px;
}

.user-menu-popover button:hover {
  background: #f4f7fb;
}

.page,
.workspace {
  padding: 12px 14px;
}

.workspace {
  overflow: hidden;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

label {
  min-height: 34px;
  display: grid;
  grid-template-columns: auto minmax(96px, 1fr);
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  border: 1px solid #dbe3ee;
  border-radius: 7px;
  color: #526174;
  background: white;
  font-size: 12px;
  font-weight: 650;
}

.topbar-filter-controls .topbar-filter {
  min-height: 32px;
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  padding: 0;
  color: #5f6f85;
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 700;
}

.topbar-filter-controls .topbar-filter select {
  width: auto;
  min-width: 112px;
  height: 30px;
  padding: 4px 28px 4px 10px;
  border: 1px solid #cfd8e5;
  border-radius: 7px;
  color: var(--text);
  background: white;
  font-size: 13px;
  font-weight: 700;
}

.topbar-filter-controls .topbar-filter select[name="orderBy"] {
  min-width: 132px;
}

label.wide {
  min-width: min(260px, 100%);
  flex: 1;
}

input,
select {
  height: 26px;
  min-width: 108px;
  border: 0;
  border-radius: 4px;
  padding: 3px 4px;
  color: var(--text);
  background: transparent;
  font-weight: 650;
}

input:focus,
select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.14);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.project-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.project-card:hover {
  border-color: var(--accent);
}

.project-name {
  font-weight: 750;
}

.project-meta,
.back-link {
  color: var(--muted);
  font-size: 13px;
}

.table-shell {
  overflow: auto;
  height: calc(100% - 2vh);
  max-height: none;
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.calendar-workspace {
  overflow: hidden;
}

.calendar-shell {
  height: calc(100% - 2vh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.calendar-toolbar h1 {
  margin: 0;
  font-size: 17px;
}

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

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-board {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  grid-template-rows: 32px repeat(6, minmax(116px, 1fr));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.calendar-weekday {
  z-index: 2;
  padding: 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: #344054;
  background: #eef2f7;
  font-size: 12px;
  font-weight: 800;
}

.calendar-week {
  position: relative;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  grid-template-rows: 28px repeat(3, 24px) minmax(8px, 1fr);
  min-height: calc(42px + var(--lane-count, 1) * 24px);
  overflow: visible;
  border-bottom: 1px solid var(--line);
}

.calendar-day {
  min-width: 0;
  overflow: hidden;
  grid-row: 1 / -1;
  z-index: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 6px 7px;
  border-right: 1px solid var(--line);
  background: white;
  font-size: 12px;
  font-weight: 800;
}

.calendar-day.outside-month {
  background: #f8fafc;
  color: var(--muted);
}

.calendar-day.rest-day {
  background: #fbfcff;
}

.calendar-day.today {
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.38);
}

.calendar-day small {
  color: var(--muted);
  font-size: 11px;
}

.calendar-week-bars {
  display: contents;
  pointer-events: none;
}

.calendar-bar {
  height: 22px;
  min-width: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  align-self: center;
  margin: 0 3px;
  padding: 3px 8px;
  pointer-events: auto;
  overflow: hidden;
  border: 1px solid #bad4ff;
  border-radius: 6px;
  color: #1749a8;
  background: #e8f1ff;
  box-shadow: 0 1px 2px rgba(23, 73, 168, 0.12);
  font-size: 11px;
  line-height: 1;
}

.calendar-bar.continues-before {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.calendar-bar.continues-after {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.calendar-bar strong {
  flex: 0 0 auto;
}

.calendar-bar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-hidden-count {
  grid-column: 1 / -1;
  z-index: 1;
  justify-self: start;
  align-self: center;
  margin-left: 7px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(246, 247, 249, 0.9);
  font-size: 11px;
  font-weight: 800;
}

/* Deprecated daily item classes kept harmless for cached pages. */
.calendar-item {
  display: flex;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 5px;
  padding: 4px 5px;
  border: 1px solid #dbe7ff;
  border-radius: 5px;
  color: #1d4ed8;
  background: #eff6ff;
  font-size: 11px;
  line-height: 1.25;
}

.calendar-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-more {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.unscheduled-issues {
  min-height: 0;
  max-height: 72px;
  overflow: hidden;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.unscheduled-issues h2 {
  margin: 0 0 6px;
  font-size: 12px;
}

.unscheduled-issues div {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
}

.unscheduled-issues a {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
}

.issue-table {
  width: 100%;
  min-width: 1500px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.issue-table th,
.issue-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 5px 6px;
  text-align: left;
  vertical-align: middle;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.issue-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2f7;
  color: #344054;
  font-weight: 750;
  white-space: nowrap;
}

.issue-table tr:hover td {
  background: #f9fbff;
}

.title-col {
  width: 480px;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.issue-id-col {
  width: 56px;
  white-space: nowrap;
}

.label-col {
  width: 138px;
}

.compact-label-col {
  width: 98px;
}

.date-col {
  width: 150px;
}

.duration-col {
  width: 90px;
}

.user-col,
.assignee-col {
  width: 112px;
}

.issue-table .assignee-col {
  position: sticky;
  right: 0;
  z-index: 2;
  background: white;
  box-shadow: -8px 0 12px -12px rgba(16, 24, 40, 0.45);
}

.issue-table th.assignee-col {
  z-index: 4;
  background: #eef2f7;
}

.issue-table tr:hover td.assignee-col {
  background: #f9fbff;
}

.wrap-cell {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.th-filter {
  width: 100%;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
}

.th-filter:hover {
  color: var(--accent);
  background: transparent;
}

.th-filter::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.65;
}

.th-filter.active {
  color: var(--accent);
}

.filter-count {
  min-width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: white;
  background: var(--accent);
  font-size: 10px;
}

.filter-count:empty {
  display: none;
}

.issue-link {
  color: var(--accent);
  font-weight: 800;
}

.cell-input,
.cell-select {
  width: 132px;
  min-width: 0;
  height: 28px;
  font-size: 12px;
}

.assignee-col .cell-select {
  width: 100%;
}

.compact-duration {
  width: 72px;
  text-align: center;
}

.editable-cell:disabled {
  color: var(--text);
  opacity: 1;
  cursor: pointer;
  background: transparent;
  border-color: transparent;
  appearance: none;
  pointer-events: none;
}

select.editable-cell:disabled {
  color: var(--text);
}

.editing-cell {
  background: #eef6ff !important;
}

.saving {
  opacity: 0.65;
}

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

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 12px 16px;
  background: var(--ok);
  color: white;
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

.filter-popover {
  position: fixed;
  z-index: 100;
  width: 230px;
  max-height: min(360px, calc(100vh - 90px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.filter-popover-title {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 800;
}

.filter-options {
  overflow: auto;
  padding: 6px;
}

.filter-option {
  display: grid;
  grid-template-columns: 16px 1fr;
  align-items: start;
  gap: 8px;
  padding: 7px 6px;
  min-height: auto;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  font-size: 12px;
  font-weight: 500;
}

.filter-option:hover {
  background: #f4f7fb;
}

.filter-option input {
  width: 14px;
  min-width: 14px;
  height: 14px;
  padding: 0;
  margin: 1px 0 0;
}

.filter-option span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  padding: 8px;
  border-top: 1px solid var(--line);
}

.filter-actions button {
  min-height: 28px;
  color: var(--text);
  background: white;
  border-color: var(--line);
  font-size: 12px;
}

.empty-filter {
  padding: 12px 8px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 760px) {
  .page,
  .workspace {
    padding: 6px 8px;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .search-form,
  .search-form input,
  .search-form button {
    width: 100%;
  }

  label {
    grid-template-columns: 1fr;
  }

  .topbar {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "main user"
      "filters filters";
    align-items: center;
    justify-content: normal;
    gap: 6px 8px;
    padding: 6px 10px;
  }

  .topbar-main {
    grid-area: main;
    gap: 8px;
    overflow: hidden;
  }

  .brand {
    font-size: 18px;
  }

  .topbar-divider {
    height: 18px;
  }

  .back-link {
    display: none;
  }

  .topbar-title {
    max-width: none;
    font-size: 15px;
  }

  .topbar-filter-controls {
    grid-area: filters;
    min-width: 0;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 8px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .topbar-filter-controls::-webkit-scrollbar {
    display: none;
  }

  .topbar-filter {
    flex: 0 0 auto;
    width: auto;
    min-height: 28px;
  }

  .topbar-filter-controls .topbar-filter select {
    min-width: 94px;
    height: 28px;
    font-size: 12px;
  }

  .topbar-filter-controls .topbar-filter select[name="orderBy"] {
    min-width: 108px;
  }

  .topbar-user {
    grid-area: user;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .compact-action {
    min-height: 30px;
    padding: 5px 8px;
  }

  .user-menu-button {
    max-width: 74px;
    min-height: 30px;
    padding: 5px 0;
  }

  .table-shell {
    height: calc(100% - 2vh);
  }

  .calendar-workspace {
    padding: 6px 8px;
  }

  .calendar-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 8px;
  }

  .calendar-nav {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .calendar-board {
    min-height: 0;
    overflow-x: auto;
    grid-template-columns: repeat(7, minmax(118px, 1fr));
  }

  .calendar-week,
  .calendar-week-bars {
    grid-template-columns: repeat(7, minmax(118px, 1fr));
  }

  .calendar-bar {
    height: 20px;
    margin-top: 0;
    margin-bottom: 0;
    padding: 3px 6px;
  }
}
