:root {
  --bg: #0d1117;
  --panel: #111827;
  --border: #1f2937;
  --text: #e6edf3;
  --muted: #9ca3af;
  --accent-strong: #7dd3fc;
  --accent: #38bdf8;
  --pill-bg: #1f2937;
  --pill-border: #273449;
  --pill-text: #e6edf3;
  --error-bg: #3f1d2e;
  --error-text: #fca5a5;
  --error-border: #b91c1c;
  --ok-bg: #132a1f;
  --ok-text: #86efac;
  --ok-border: #16a34a;
  --header-gradient: linear-gradient(135deg, #111827 0%, #0b1323 100%);
  --hover: #0b1323;
}

:root[data-theme="light"] {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --border: #d9e0ea;
  --text: #0f172a;
  --muted: #475569;
  --accent-strong: #0ea5e9;
  --accent: #0284c7;
  --pill-bg: #e2e8f0;
  --pill-border: #cbd5e1;
  --pill-text: #0f172a;
  --error-bg: #fef2f2;
  --error-text: #b91c1c;
  --error-border: #ef4444;
  --ok-bg: #ecfdf3;
  --ok-text: #166534;
  --ok-border: #22c55e;
  --header-gradient: linear-gradient(135deg, #e2e8f0 0%, #ffffff 100%);
  --hover: #eef2f7;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-width: 1366px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px 28px 12px;
  background: var(--header-gradient);
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--accent-strong);
  margin: 0 0 6px;
}

h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.meta {
  display: flex;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-text);
  font-size: 12px;
  border: 1px solid var(--pill-border);
}

.pill-error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

.pill-prod {
  background: #1d2635;
  color: #fcd34d;
  border-color: #b45309;
}

main {
  padding: 16px 24px 32px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  overflow: visible;
  min-height: 260px; /* keep tile height comfortable even with few rows */
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.panel__header h2 {
  margin: 4px 0 0;
  font-size: 18px;
}

.label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.ghost-btn--tiny {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
}

.ghost-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.primary-btn {
  background: var(--accent);
  color: #0b1221;
  border: 1px solid var(--accent);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.primary-btn:hover {
  filter: brightness(0.95);
}

.filter-label {
  font-size: 12px;
  color: var(--muted);
}

.filter-option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text);
}

.filter-dropdown {
  position: relative;
  overflow: visible;
}

.filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
  z-index: 200;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  padding: 0 16px 16px;
  position: relative;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: #b8c0cc transparent;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 1250px;
  margin-top: 12px;
  table-layout: fixed;
}

/* Lock key column widths for consistent gridlines */
colgroup col:nth-child(10) {
  width: 160px;
}

.table-wrapper::-webkit-scrollbar {
  height: 10px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: transparent;
  margin: 0 12px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: #b8c0cc;
  border-radius: 999px;
  border: 2px solid #f5f7fb;
}

.note-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.note-snippet {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.modal__notes-body {
  margin: 8px 0 4px;
  white-space: pre-wrap;
  line-height: 1.45;
  color: var(--text);
}

thead th {
  text-align: left;
  padding: 10px 8px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  user-select: none;
  position: relative;
  min-width: 110px;
  word-break: break-word;
  white-space: normal;
}

thead .th-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

thead th.sortable {
  cursor: pointer;
}

.th-filter {
  position: relative;
}

.filter-caret {
  margin-left: 6px;
  padding: 4px 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
  position: relative;
  z-index: 2;
}

.filter-caret:hover,
.filter-caret:focus-visible {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--accent);
  outline: none;
}

.filter-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  margin-left: 6px;
  padding: 4px 10px;
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 999px;
  font-size: 12px;
  background: rgba(56, 189, 248, 0.08);
  cursor: pointer;
  line-height: 1.2;
  max-width: 160px;
  white-space: normal;
}

.filter-chip:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent);
}

tbody td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
  white-space: normal;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--hover);
}

.sort-indicator {
  margin-left: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  opacity: 0.8;
  display: inline-block;
  min-width: 10px;
}

th.sortable:hover .sort-indicator {
  color: var(--accent);
  opacity: 1;
}

.resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  border-left: 1px solid var(--border);
  opacity: 0.4;
  transition: opacity 120ms ease, border-color 120ms ease;
}

th:hover .resize-handle {
  opacity: 0.7;
  border-color: rgba(148, 163, 184, 0.85);
}

.download-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  cursor: pointer;
}

.download-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.download-link:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status-cell {
  text-align: center;
  vertical-align: middle;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  min-width: 110px;
  max-width: 160px;
  width: auto;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease, box-shadow 120ms ease;
  white-space: nowrap;
  justify-content: space-between;
}

.status-btn {
  min-width: 90px;
  justify-content: center;
}

thead th:nth-child(10),
tbody td:nth-child(10) {
  text-align: center;
  vertical-align: middle;
}

thead th:nth-child(11),
tbody td:nth-child(11) {
  vertical-align: middle;
}

.status-pill:hover,
.status-pill:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
  flex-shrink: 0;
}

.status-caret {
  font-size: 11px;
  opacity: 0.8;
  flex-shrink: 0;
}

.status-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill.status-open {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}
.status-pill.status-open .status-dot {
  background: var(--accent);
}

.status-pill.status-in-progress {
  background: rgba(234, 179, 8, 0.16);
  border-color: #f59e0b;
  color: #f59e0b;
}
.status-pill.status-in-progress .status-dot {
  background: #f59e0b;
}

.status-pill.status-closed {
  background: rgba(34, 197, 94, 0.16);
  border-color: #22c55e;
  color: #22c55e;
}
.status-pill.status-closed .status-dot {
  background: #22c55e;
}

.inline-status-select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.empty-state,
.error-state {
  padding: 16px 20px 20px;
  color: var(--muted);
}

.error-state {
  color: var(--error-text);
}

.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal.hidden {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}

.modal__dialog {
  position: relative;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 18px 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  max-width: 520px;
  width: 92%;
  z-index: 1;
}

.modal__context {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.modal__label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.modal__textarea {
  width: 100%;
  min-height: 140px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  font-family: "Segoe UI", Arial, sans-serif;
}

.modal__actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.form-error {
  margin-top: 8px;
  color: var(--error-text);
  font-size: 13px;
}

