:root {
  --bg: #ffffff;
  --bg-card: #ffffff;
  --bg-muted: #f7f8fa;
  --fg: #0b1320;
  --fg-muted: #36445b;
  --fg-subtle: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #0B2545;
  --accent-hover: #13345f;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --warn-bg: #fff7ed;
  --warn-fg: #9a3412;
  --shadow-sm: 0 1px 2px rgba(11, 37, 69, 0.06);
  --shadow: 0 4px 12px rgba(11, 37, 69, 0.06), 0 1px 2px rgba(11, 37, 69, 0.04);
  --shadow-lg: 0 20px 40px rgba(11, 37, 69, 0.12), 0 4px 10px rgba(11, 37, 69, 0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-pill: 999px;

  /* Status colors — muted to read well on white against the navy palette */
  --st-idea-bg: #f1f5f9; --st-idea-fg: #475569;
  --st-planned-bg: #dbeafe; --st-planned-fg: #1e3a8a;
  --st-progress-bg: #fef3c7; --st-progress-fg: #854d0e;
  --st-shipped-bg: #dcfce7; --st-shipped-fg: #166534;
  --st-declined-bg: #fee2e2; --st-declined-fg: #991b1b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

button { font-family: inherit; }
code { font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace; font-size: 0.92em; }

.muted { color: var(--fg-muted); }
.muted-small { color: var(--fg-subtle); font-size: 12px; }
.error { color: var(--danger); margin-top: 0.75rem; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: var(--bg-muted);
  color: var(--fg);
}
.btn-ghost:hover { background: #e6e9f1; }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { background: #fef2f2; }
.link-danger {
  background: none; border: none; color: var(--danger);
  font-size: 12px; cursor: pointer; padding: 0 0.25rem; margin-left: auto;
}
.link-danger:hover { text-decoration: underline; }

/* ---------- Login / connect ---------- */
.center-card {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.center-card .card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
}
.brand {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-small {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.brand-logo-link { display: flex; align-items: center; }
.brand-logo { height: 28px; width: auto; display: block; }
.brand-divider {
  height: 20px;
  width: 1px;
  background: var(--border-strong);
  margin: 0 4px;
}
.back-link {
  font-size: 14px;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  line-height: 1;
}
.back-link:hover { background: var(--bg-muted); color: var(--accent); border-color: var(--accent); }
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.25rem;
}
.login-form input {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  font-size: 15px;
  text-align: center;
  letter-spacing: 0.05em;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
}
.topbar-center { display: flex; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; }
.search {
  width: 100%;
  max-width: 520px;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg);
  font-size: 14px;
}
.search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
  background: var(--bg-card);
}

.user-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.7rem 0.35rem 0.4rem;
  border-radius: var(--radius-pill);
  background: var(--bg-muted);
  cursor: pointer;
  user-select: none;
}
.user-chip:hover { background: #e6e9f1; }
.admin-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: white;
  font-weight: 600;
}
.user-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  overflow: hidden;
}
.user-menu.open { display: block; }
.user-menu button {
  display: block;
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: none;
  border: none;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}
.user-menu button:hover { background: var(--bg-muted); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.avatar.small { width: 22px; height: 22px; font-size: 10px; }
.user-name { font-weight: 500; font-size: 13px; }

/* ---------- Banner ---------- */
.banner {
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.banner-warn { background: var(--warn-bg); color: var(--warn-fg); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}
.sidebar {
  position: sticky;
  top: 68px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.filter-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-subtle);
  margin: 0 0 0.5rem;
  font-weight: 600;
}
.filter-section select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 13px;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.1rem;
  cursor: pointer;
  font-size: 13px;
}
.checkbox input { cursor: pointer; }
.checkbox .count { margin-left: auto; color: var(--fg-subtle); font-size: 12px; }

.content-header { margin-bottom: 1rem; }
.content-header h2 { margin: 0; font-size: 1.1rem; color: var(--fg-muted); font-weight: 600; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 0.75rem;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.feature-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.vote-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.vote-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--fg-subtle);
  font-size: 14px;
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-sm);
  line-height: 1;
}
.vote-btn:hover { background: var(--bg-muted); color: var(--fg); }
.vote-btn.active.up { color: var(--accent); }
.vote-btn.active.down { color: var(--danger); }
.score { font-weight: 700; font-size: 14px; min-width: 18px; text-align: center; }

.card-body { min-width: 0; }
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.card-title { margin: 0 0 0.35rem; font-size: 15px; font-weight: 600; line-height: 1.3; }
.card-desc {
  margin: 0 0 0.75rem;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.assignees { display: flex; gap: -0.3rem; align-items: center; }
.assignees .avatar { margin-right: -6px; border: 2px solid var(--bg-card); }
.assignees .avatar:last-child { margin-right: 0; }

/* ---------- Pills ---------- */
.pill {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-idea     { background: var(--st-idea-bg);     color: var(--st-idea-fg); }
.status-planned  { background: var(--st-planned-bg);  color: var(--st-planned-fg); }
.status-progress { background: var(--st-progress-bg); color: var(--st-progress-fg); }
.status-shipped  { background: var(--st-shipped-bg);  color: var(--st-shipped-fg); }
.status-declined { background: var(--st-declined-bg); color: var(--st-declined-fg); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 3px 10px 3px 3px;
  border-radius: var(--radius-pill);
  background: var(--bg-muted);
  font-size: 12px;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--fg-muted);
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty-state p { margin: 0 0 1rem; }

/* ---------- Modal ---------- */
#modal-root { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
#modal-root.open { pointer-events: auto; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
  animation: fade-in 0.15s;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.18s;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--fg-subtle);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  line-height: 1;
}
.modal-close:hover { background: var(--bg-muted); color: var(--fg); }
.modal-title { margin: 0; font-size: 1.25rem; font-weight: 700; line-height: 1.3; }

.feature-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.vote-row { display: flex; align-items: center; gap: 0.5rem; }
.vote-row .vote-btn {
  width: 36px; height: 36px;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  font-size: 16px;
}
.vote-row .score { font-size: 18px; }
.admin-actions { display: flex; gap: 0.5rem; align-items: center; }
.admin-actions select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 13px;
}

.detail-section { margin-bottom: 1.25rem; }
.detail-section h4 {
  margin: 0 0 0.5rem;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-subtle);
  font-weight: 600;
}
.detail-desc {
  margin: 0;
  color: var(--fg);
  line-height: 1.6;
  white-space: normal;
}
.assignees-big { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.assignee-editor {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.25rem;
}

.comments { display: flex; flex-direction: column; gap: 0.9rem; margin-bottom: 1rem; }
.comment {
  padding: 0.8rem;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
}
.comment-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 13px;
}
.comment-body { font-size: 13px; line-height: 1.5; color: var(--fg); }

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
}
.comment-form textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}
.comment-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.comment-form button { align-self: flex-end; }

/* ---------- Forms ---------- */
form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1rem;
  font-size: 13px;
  color: var(--fg-muted);
  font-weight: 500;
}
form input[type="text"],
form input[type="email"],
form textarea,
form select {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--fg);
}
form input[type="text"]:focus,
form input[type="email"]:focus,
form textarea:focus,
form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
form textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }

/* ---------- Admin panel ---------- */
.admin-section { margin-bottom: 1.5rem; }
.admin-section h3 { margin: 0 0 0.75rem; font-size: 14px; }
.code-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: end;
}
.code-form input,
.code-form select {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
}

.codes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.codes-table th, .codes-table td {
  padding: 0.55rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.codes-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-subtle);
  font-weight: 600;
}
.codes-table td code {
  background: var(--bg-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn { padding: 0.3rem 0.6rem; font-size: 12px; }

/* ---------- Toast ---------- */
#toast-host {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  padding: 0.7rem 1rem;
  background: var(--fg);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.18s;
  max-width: 360px;
}
.toast-success { background: #166534; }
.toast-error   { background: var(--danger); }
.toast-out { opacity: 0; transform: translateY(4px); transition: all 0.3s; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 1rem;
  }
  .sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .filter-section {
    flex: 1 1 auto;
    min-width: 160px;
  }
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'brand user'
      'search search';
    gap: 0.75rem;
    padding: 0.75rem;
  }
  .topbar-left { grid-area: brand; }
  .topbar-center { grid-area: search; }
  .topbar-right { grid-area: user; }
  .card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
  .user-name { display: none; }
  .feature-actions { flex-direction: column; align-items: flex-start; }
  .code-form { grid-template-columns: 1fr; }
  .modal { padding: 1.1rem; }
  .codes-table th:nth-child(4),
  .codes-table td:nth-child(4) { display: none; }
}
