:root {
  color-scheme: dark;
  --bg: #0c0e14;
  --surface: #151822;
  --surface-2: #1d2230;
  --border: #293042;
  --text: #eef1f7;
  --muted: #98a2b8;
  --accent: #6366f1;
  --accent-hover: #7578f5;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --open-bg: rgba(59, 130, 246, 0.16);
  --open-fg: #60a5fa;
  --prog-bg: rgba(245, 158, 11, 0.16);
  --prog-fg: #fbbf24;
  --done-bg: rgba(34, 197, 94, 0.16);
  --done-fg: #4ade80;
  --wont-bg: rgba(148, 163, 184, 0.16);
  --wont-fg: #cbd5e1;
  --radius: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

[hidden] {
  display: none !important;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.brand-icon {
  font-size: 26px;
  line-height: 1;
}

.login-card h1 {
  margin: 0;
  font-size: 20px;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
}

/* Shared inputs & buttons */
.input,
.select,
.textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
}

.textarea {
  width: 100%;
  min-height: 68px;
  resize: vertical;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: #272e40;
  border-color: #3f4a66;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn-ghost {
  background: transparent;
}

.btn-full {
  width: 100%;
  margin-top: 4px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(21, 24, 34, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-brand h1 {
  margin: 0;
  font-size: 17px;
}

.count-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  font-variant-numeric: tabular-nums;
}

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

/* Main container */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

/* Filters */
.filters-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover {
  color: var(--text);
  border-color: #424c66;
}

.pill.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent);
  color: #ffffff;
}

/* Report cards */
.reports-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 16px;
  font-size: 14px;
}

.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.report-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.report-id {
  font-weight: 700;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.badge-project {
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.12);
}

.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
}

.status-open { background: var(--open-bg); color: var(--open-fg); }
.status-in_progress { background: var(--prog-bg); color: var(--prog-fg); }
.status-done { background: var(--done-bg); color: var(--done-fg); }
.status-wontfix { background: var(--wont-bg); color: var(--wont-fg); }

.report-body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.report-main {
  flex: 1 1 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-desc {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}

.report-submeta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.report-link {
  color: #93c5fd;
  text-decoration: none;
  word-break: break-all;
}

.report-link:hover {
  text-decoration: underline;
}

.report-thumb {
  width: 150px;
  max-height: 115px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  background: #090b10;
  flex-shrink: 0;
}

.report-thumb:hover {
  border-color: var(--accent);
}

.report-editor {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.editor-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.editor-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.save-feedback {
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}

.lightbox img {
  max-width: 94vw;
  max-height: 90vh;
  border-radius: 10px;
  object-fit: contain;
}

@media (max-width: 600px) {
  .report-thumb {
    width: 100%;
    max-height: 200px;
  }

  .editor-controls {
    align-items: stretch;
  }

  .editor-right {
    width: 100%;
    justify-content: flex-end;
  }
}
