:root {
  --bg: #0b0e14;
  --bg-elev: #121722;
  --bg-card: #171d2b;
  --bg-card-hover: #1d2538;
  --border: #252f45;
  --text: #e6ecf8;
  --muted: #8b98b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --ai-accent: #a855f7;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(99, 102, 241, 0.14), transparent 60%),
    radial-gradient(700px 380px at 88% -10%, rgba(168, 85, 247, 0.11), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.45;
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.22);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.38);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* LOGIN */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, #171e34 0%, var(--bg) 60%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

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

.brand-row h1 {
  margin: 0;
  font-size: 1.25rem;
}

.brand-row p {
  margin: 2px 0 0;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.25rem;
  color: #fff;
  flex-shrink: 0;
}

.brand-logo.sm {
  width: 32px;
  height: 32px;
  font-size: 0.95rem;
  border-radius: 9px;
}

/* TOPBAR */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(18, 23, 34, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
}

.brand-title span {
  color: var(--muted);
  font-weight: 500;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}

.nav-tab:hover {
  color: var(--text);
}

.nav-tab.active {
  background: var(--bg-card);
  color: #fff;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.875rem;
}

/* ROLE BADGES */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.role-OWNER {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.role-CONTENT {
  background: rgba(99, 102, 241, 0.18);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.role-AI {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.28), rgba(56, 189, 248, 0.25));
  color: #e9d5ff;
  border: 1px solid rgba(168, 85, 247, 0.55);
}

/* MAIN */
.main-content {
  padding: 16px 24px 40px;
  max-width: 1760px;
  margin: 0 auto;
}

/* STATS STRIP (compact status cards across full width) */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

@media (max-width: 1100px) {
  .stats-strip {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }
}

.stat-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(18, 23, 34, 0.78);
  backdrop-filter: blur(8px);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  text-align: left;
  overflow: hidden;
}

.stat-chip::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--chip-color, var(--primary));
  opacity: 0.65;
}

.stat-chip:hover {
  background: rgba(29, 37, 56, 0.88);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text);
  transform: translateY(-1px);
}

.stat-chip.active {
  background: rgba(31, 41, 66, 0.96);
  border-color: var(--chip-color, var(--primary));
  color: #fff;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--chip-color, #6366f1) 35%, transparent),
              0 8px 20px rgba(0, 0, 0, 0.25);
}

.stat-chip-label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-chip-count {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
  flex-shrink: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar-spacer {
  flex: 1;
}

.search-wrap {
  flex: 1;
  min-width: 240px;
  max-width: 420px;
}

.search-wrap input {
  width: 100%;
  background: rgba(18, 23, 34, 0.85);
}

/* SMART GROUPED GRID VIEW */
.sections-wrap {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.status-section {
  background: rgba(18, 23, 34, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.065);
  border-radius: 14px;
  padding: 14px 16px 16px;
}

.status-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.status-section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 0.95rem;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 10px;
}

/* BOARD */
.board-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  align-items: start;
}

.board-col {
  background: rgba(18, 23, 34, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 230px);
}

.board-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.board-col-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 0.82rem;
}

.col-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

/* COMPACT MODERN IDEA CARD */
.idea-card {
  position: relative;
  background: linear-gradient(180deg, rgba(25, 32, 48, 0.92), rgba(20, 26, 40, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.idea-card:hover {
  background: linear-gradient(180deg, rgba(32, 41, 62, 0.96), rgba(24, 31, 48, 0.96));
  border-color: rgba(129, 140, 248, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
}

.idea-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.idea-card-top-left {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
}

.idea-card-title {
  font-weight: 650;
  font-size: 0.88rem;
  line-height: 1.32;
  margin: 0;
  color: #f1f5f9;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.idea-card-desc {
  font-size: 0.77rem;
  line-height: 1.35;
  color: var(--muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.idea-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.card-quick-approve {
  border: 1px solid rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s;
}

.card-quick-approve:hover {
  background: rgba(16, 185, 129, 0.28);
  color: #fff;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
}

.id-pill {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.28);
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.prio-pill {
  font-size: 0.67rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  flex-shrink: 0;
}

.prio-HIGH {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

.prio-NORMAL {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
}

.prio-LOW {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.ai-indicator {
  font-size: 0.7rem;
  font-weight: 700;
  color: #d8b4fe;
}

/* LIST VIEW */
.list-wrap,
.table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.clickable-row {
  cursor: pointer;
}

.text-right {
  text-align: right !important;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ADMIN */
.admin-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  align-items: start;
}

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

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.panel-header h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.panel-header p {
  margin: 0 0 16px;
}

.create-user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.align-end {
  justify-content: flex-end;
}

.api-key-box {
  margin-bottom: 16px;
}

.key-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.key-row input {
  flex: 1;
  min-width: 200px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.api-docs-block h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.code-box {
  background: #080a0f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 0.78rem;
  color: #cbd5e1;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
  line-height: 1.55;
}

/* FORMS & BUTTONS */
.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
}

.field span {
  color: var(--muted);
  font-weight: 500;
}

input,
select,
textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 15px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  color: #fff;
  background: var(--bg-card);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #27324a;
  border-color: #364566;
}

.btn-secondary:hover {
  background: #32405e;
}

.btn-success {
  background: #059669;
}

.btn-success:hover {
  background: #047857;
}

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

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.28);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--bg-card);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.icon-btn:hover {
  background: var(--bg-card);
  color: #fff;
}

/* MODALS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6);
  max-height: 92vh;
  overflow-y: auto;
}

.modal-lg {
  max-width: 780px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.detail-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.status-control,
.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.detail-description {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
  min-height: 54px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

/* COMMENTS */
.comments-header h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  max-height: 320px;
  overflow-y: auto;
}

.comment-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
}

.comment-item.is-ai {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.12), rgba(56, 189, 248, 0.08));
  border-color: rgba(168, 85, 247, 0.42);
}

.comment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.comment-author {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

.comment-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
}

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

.comment-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-select {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ALERTS & TOAST */
.alert-error {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.alert-info {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  background: #1e293b;
  border: 1px solid #384a6b;
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 0.875rem;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.45);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 0.84rem;
  padding: 20px 10px;
}

/* TAG PICKER & ADMIN TAGS */
.tag-filter-select {
  min-width: 145px;
  font-size: 0.84rem;
  padding: 7px 10px;
}

.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  min-height: 42px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tag-choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}

.tag-choice:hover {
  color: var(--text);
  border-color: #47587d;
}

.tag-choice.selected {
  color: #fff;
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--primary);
}

.create-tag-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.create-tag-row input[type="text"] {
  flex: 1;
  min-width: 180px;
}

.create-tag-row input[type="color"] {
  width: 44px;
  height: 38px;
  padding: 3px;
  cursor: pointer;
}

.admin-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.84rem;
  font-weight: 600;
}

.admin-tag-chip button {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 2px;
  line-height: 1;
}

.admin-tag-chip button:hover {
  color: #f87171;
}
