/* ════════════════════════════════════════════════════════════════════
   Backlog PM — unified app stylesheet
   Brand tokens from style.css; Linear/Jira/ProductBoard-grade surface.
   ════════════════════════════════════════════════════════════════════ */

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

:root {
  --purple: #6E2C8B; --purple-dark: #4A1D5E; --purple-light: #9B59B6;
  --cyan: #00B8CF; --cyan-dark: #008B9A;
  --text: #404B5C; --text-secondary: #6B7280; --text-faint: #9CA3AF;
  --bg: #F8F9FC; --bg-sunken: #F1F2F7;
  --border: #E5E7EB; --border-strong: #D1D5DB; --white: #FFFFFF;
  --success: #059669; --success-bg: #ECFDF5;
  --warning: #D97706; --warning-bg: #FFFBEB;
  --danger: #DC2626; --danger-bg: #FEF2F2;
  --info: #2563EB;
  --font-title: 'Lexend Deca', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --radius: 6px; --radius-lg: 8px; --radius-xl: 12px;
  --shadow-xs: 0 1px 2px rgba(16,24,40,0.06);
  --shadow: 0 2px 8px rgba(16,24,40,0.08);
  --shadow-md: 0 4px 14px rgba(16,24,40,0.10);
  --shadow-lg: 0 12px 32px rgba(16,24,40,0.16);
  --transition: 0.16s cubic-bezier(0.4,0,0.2,1);

  /* status accents (canonical + fallbacks) */
  --st-idea: #8B5CF6; --st-building: #2563EB; --st-propen: #D97706;
  --st-done: #059669; --st-default: #6B7280;
}

html, body { height: 100%; }
body {
  font-family: var(--font-body); background: var(--bg); color: var(--text);
  line-height: 1.5; -webkit-font-smoothing: antialiased; overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
::selection { background: rgba(110,44,139,0.16); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D7DAE2; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #BCC0CC; background-clip: content-box; }

/* ─── App frame ─────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  flex-shrink: 0; height: 56px; display: flex; align-items: center;
  gap: 16px; padding: 0 20px; color: var(--white);
  background: linear-gradient(90deg, #6E2C8B 0%, #7B2E8E 38%, #00B8CF 100%);
  box-shadow: 0 1px 0 rgba(0,0,0,0.06); z-index: 40; position: relative;
}
.topbar-logo { height: 24px; opacity: 0.96; display: block; }
.topbar-brand { display: flex; align-items: center; gap: 12px; cursor: pointer; text-decoration: none; color: #fff; }
.topbar-brand .sep { width: 1px; height: 22px; background: rgba(255,255,255,0.28); }
.topbar-brand h1 { font-family: var(--font-title); font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; min-width: 0; }
.topbar-breadcrumb .crumb-sep { opacity: 0.5; }
.topbar-breadcrumb .crumb-project { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.topbar-spacer { flex: 1; }

.global-search {
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.22); border-radius: 8px; padding: 0 10px;
  height: 34px; width: 300px; max-width: 34vw; transition: background var(--transition);
}
.global-search:focus-within { background: rgba(255,255,255,0.26); border-color: rgba(255,255,255,0.5); }
.global-search svg { width: 15px; height: 15px; opacity: 0.85; flex-shrink: 0; }
.global-search input {
  background: transparent; border: none; outline: none; color: #fff;
  font-family: inherit; font-size: 13px; width: 100%;
}
.global-search input::placeholder { color: rgba(255,255,255,0.75); }

.topbar-auth { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.btn-signin {
  background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.35);
  color: #fff; padding: 6px 14px; border-radius: 7px; font-size: 13px; font-weight: 600;
  transition: background var(--transition);
}
.btn-signin:hover { background: rgba(255,255,255,0.28); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,0.22);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  font-size: 12px; font-family: var(--font-title); border: 1px solid rgba(255,255,255,0.3);
}
.user-menu { position: relative; }
.user-dropdown {
  position: absolute; right: 0; top: 38px; background: var(--white); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  min-width: 200px; padding: 8px; z-index: 60; display: none;
}
.user-dropdown.open { display: block; }
.user-dropdown .udd-name { font-weight: 600; font-size: 13px; padding: 6px 8px; }
.user-dropdown .udd-email { font-size: 12px; color: var(--text-secondary); padding: 0 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-dropdown button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 8px; border-radius: 5px; font-size: 13px; color: var(--text); }
.user-dropdown button:hover { background: var(--bg-sunken); }

/* ─── Body: optional rail + content ─────────────────────────────── */
.app-body { flex: 1; display: flex; min-height: 0; }

.rail {
  flex-shrink: 0; width: 208px; background: var(--white); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; overflow-y: auto;
}
.rail-section-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); padding: 10px 10px 4px; }
.rail-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500; color: var(--text-secondary); text-decoration: none;
  transition: background var(--transition), color var(--transition); border: none; background: none; width: 100%; text-align: left;
}
.rail-link:hover { background: var(--bg-sunken); color: var(--text); }
.rail-link.active { background: rgba(110,44,139,0.09); color: var(--purple); font-weight: 600; }
.rail-link.active svg { color: var(--purple); }
.rail-link svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-faint); }
.rail-link .badge-count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--text-faint); background: var(--bg-sunken); border-radius: 9px; padding: 1px 7px; }
.rail-spacer { flex: 1; }
.rail-back { color: var(--text-faint); font-size: 12.5px; }

.content { flex: 1; min-width: 0; overflow-y: auto; position: relative; }
.content-inner { padding: 24px 28px 64px; }
.content.flush .content-inner { padding: 0; }

/* ─── Generic bits ──────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-family: var(--font-title); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: #1f2733; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; border: 1px solid var(--border-strong); background: var(--white);
  color: var(--text); transition: all var(--transition); white-space: nowrap;
}
.btn:hover { border-color: var(--purple-light); color: var(--purple); box-shadow: var(--shadow-xs); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-dark); border-color: var(--purple-dark); color: #fff; }
.btn-cyan { background: var(--cyan); border-color: var(--cyan); color: #053b42; }
.btn-cyan:hover { background: var(--cyan-dark); border-color: var(--cyan-dark); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--text); border-color: transparent; box-shadow: none; }
.btn-danger { color: var(--danger); border-color: #F3C9C9; }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: var(--radius); }

.input, .select, textarea.input {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-family: var(--font-body); font-size: 13.5px; color: var(--text); background: var(--white);
  outline: none; transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--purple-light); box-shadow: 0 0 0 3px rgba(155,89,182,0.14); }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.55; }
label.field-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin-bottom: 6px; }

.pill-toggle { display: inline-flex; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.pill-toggle button { border: none; background: transparent; padding: 5px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.pill-toggle button.active { background: var(--white); color: var(--purple); box-shadow: var(--shadow-xs); }

/* ─── Chips / badges ────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 11px; white-space: nowrap; line-height: 1.5; }
.chip-mono { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text-secondary); background: var(--bg-sunken); padding: 1px 6px; border-radius: 5px; }
.prio { border: 1px solid transparent; }
.prio-must { color: #B91C1C; background: #FEE9E9; border-color: #F7CFCF; }
.prio-should { color: #B45309; background: #FEF3E2; border-color: #FADFB2; }
.prio-could { color: #1D4ED8; background: #E8F0FE; border-color: #C7DAFB; }
.prio-wont { color: #6B7280; background: #F1F2F7; border-color: #E2E4EB; }
.effort { color: var(--text-secondary); background: var(--bg-sunken); border: 1px solid var(--border); font-weight: 700; min-width: 26px; justify-content: center; }
.status-chip { color: #fff; }
.type-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex-shrink: 0; }
.type-feature { color: var(--purple); }
.type-bug { color: var(--danger); }
.type-chore { color: var(--text-secondary); }
.theme-tag { font-size: 11px; font-weight: 600; color: var(--cyan-dark); background: #E2F8FB; border: 1px solid #BEEFF5; padding: 1px 8px; border-radius: 11px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* ─── Portfolio ─────────────────────────────────────────────────── */
.portfolio-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.portfolio-stat-row { display: flex; gap: 12px; margin-bottom: 26px; flex-wrap: wrap; }
.kpi { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 18px; min-width: 130px; box-shadow: var(--shadow-xs); }
.kpi-value { font-family: var(--font-title); font-size: 24px; font-weight: 700; color: #1f2733; line-height: 1.1; }
.kpi-label { font-size: 11.5px; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }

.proj-section-label { font-family: var(--font-title); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); margin: 8px 0 14px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; margin-bottom: 34px; }
.proj-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 18px; box-shadow: var(--shadow-xs); transition: all var(--transition); cursor: pointer; display: flex; flex-direction: column; gap: 12px; position: relative; }
.proj-card:hover { border-color: var(--purple-light); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.proj-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.proj-card-name { font-family: var(--font-title); font-size: 16px; font-weight: 700; color: #1f2733; letter-spacing: -0.01em; }
.proj-card-slug { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.proj-card-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 18px; }
.proj-card-edit { opacity: 0; flex-shrink: 0; }
.proj-card:hover .proj-card-edit { opacity: 1; }
.rollup { display: flex; flex-direction: column; gap: 7px; }
.rollup-bar { display: flex; height: 8px; border-radius: 5px; overflow: hidden; background: var(--bg-sunken); }
.rollup-seg { height: 100%; }
.rollup-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--text-secondary); }
.rollup-legend span { display: inline-flex; align-items: center; gap: 5px; }
.proj-card-foot { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-secondary); border-top: 1px solid var(--border); padding-top: 11px; margin-top: auto; }
.proj-card-foot .sprint-hint { display: inline-flex; align-items: center; gap: 5px; color: var(--cyan-dark); font-weight: 600; }

.create-proj-card { border: 1.5px dashed var(--border-strong); background: transparent; box-shadow: none; align-items: center; justify-content: center; min-height: 150px; color: var(--text-secondary); font-weight: 600; font-size: 14px; gap: 8px; flex-direction: row; }
.create-proj-card:hover { border-color: var(--purple-light); color: var(--purple); transform: none; box-shadow: none; }

/* ─── Board (kanban) ────────────────────────────────────────────── */
.board-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--white); flex-wrap: wrap; }
.board-scroll { display: flex; gap: 14px; padding: 18px 24px 28px; overflow-x: auto; align-items: flex-start; min-height: calc(100vh - 56px - 60px); }
.kcol { flex: 0 0 300px; width: 300px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 56px - 60px - 46px); }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px 9px; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.kcol-head .dot { width: 9px; height: 9px; }
.kcol-title { font-family: var(--font-title); font-size: 12.5px; font-weight: 700; letter-spacing: 0.01em; color: var(--text); }
.kcol-count { font-size: 11px; font-weight: 600; color: var(--text-faint); background: var(--white); border: 1px solid var(--border); border-radius: 9px; padding: 0 7px; }
.kcol-head-bar { height: 3px; border-radius: 3px 3px 0 0; }
.kcol-body { padding: 8px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kcol-add { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.kcol-add input { flex: 1; padding: 6px 9px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 12.5px; font-family: inherit; outline: none; }
.kcol-add input:focus { border-color: var(--purple-light); }

.kcard { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 11px 12px; box-shadow: var(--shadow-xs); cursor: pointer; display: flex; flex-direction: column; gap: 9px; transition: box-shadow var(--transition), border-color var(--transition); }
.kcard:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.kcard.sortable-ghost { opacity: 0.4; }
.kcard.sortable-chosen { box-shadow: var(--shadow-md); }
.kcard.saving { opacity: 0.6; pointer-events: none; }
.kcard-top { display: flex; align-items: center; gap: 7px; }
.kcard-id { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text-faint); }
.kcard-top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.kcard-title { font-size: 13.5px; font-weight: 500; color: #283040; line-height: 1.35; }
.kcard-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kcard-foot { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-secondary); }
.kcard-foot .spacer { flex: 1; }
.kcard-assignee { display: inline-flex; align-items: center; gap: 5px; }
.mini-avatar { width: 19px; height: 19px; border-radius: 50%; background: var(--purple); color: #fff; font-size: 9.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-title); }
.mini-avatar.agent { background: var(--cyan-dark); }
.kcard-icon { color: var(--text-faint); display: inline-flex; }
.kcard-icon svg { width: 13px; height: 13px; }
.kcard-icon.has-pr { color: var(--success); }

/* ─── Backlog list / table ──────────────────────────────────────── */
.list-toolbar { display: flex; align-items: center; gap: 8px; padding: 14px 0; flex-wrap: wrap; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; }
.filter-chip .select { width: auto; padding: 6px 9px; font-size: 12.5px; }
.bl-group { margin-bottom: 22px; }
.bl-group-head { display: flex; align-items: center; gap: 10px; padding: 8px 4px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.bl-group-title { font-family: var(--font-title); font-size: 13px; font-weight: 700; color: var(--text); }
.bl-group-count { font-size: 11px; color: var(--text-faint); font-weight: 600; }
.bl-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.bl-table th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); padding: 10px 12px; background: var(--bg-sunken); border-bottom: 1px solid var(--border); cursor: pointer; white-space: nowrap; user-select: none; }
.bl-table th:hover { color: var(--purple); }
.bl-table th .sort-ind { font-size: 9px; margin-left: 3px; opacity: 0.6; }
.bl-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.bl-table tr:last-child td { border-bottom: none; }
.bl-table tbody tr { cursor: pointer; transition: background var(--transition); }
.bl-table tbody tr:hover { background: var(--bg); }
.bl-cell-title { font-weight: 500; color: #283040; max-width: 420px; }
.bl-cell-title .id { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin-right: 8px; }
.inline-select { border: 1px solid transparent; background: transparent; font-family: inherit; font-size: 12px; font-weight: 600; padding: 3px 6px; border-radius: 6px; color: var(--text); }
.inline-select:hover { border-color: var(--border-strong); background: var(--white); }
.row-pr-link { color: var(--success); display: inline-flex; }
.row-pr-link svg { width: 15px; height: 15px; }

/* ─── Roadmap ───────────────────────────────────────────────────── */
.roadmap-grid { display: flex; flex-direction: column; gap: 2px; }
.roadmap-cols-head { display: grid; grid-template-columns: 180px 1fr 1fr 1fr; gap: 2px; position: sticky; top: 0; z-index: 6; }
.roadmap-col-label { padding: 11px 14px; font-family: var(--font-title); font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; color: #fff; border-radius: var(--radius) var(--radius) 0 0; text-align: center; }
.rc-now { background: linear-gradient(180deg, var(--purple) 0%, #7a3597 100%); }
.rc-next { background: var(--purple-light); }
.rc-later { background: #94A3B8; }
.roadmap-corner { background: transparent; }
.roadmap-lane { display: grid; grid-template-columns: 180px 1fr 1fr 1fr; gap: 2px; }
.lane-label { background: var(--white); border: 1px solid var(--border); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.lane-label .ll-name { font-weight: 700; font-size: 13px; color: #283040; }
.lane-label .ll-count { font-size: 11px; color: var(--text-faint); }
.lane-cell { background: rgba(255,255,255,0.55); border: 1px solid var(--border); padding: 8px; min-height: 64px; display: flex; flex-direction: column; gap: 7px; }
.lane-cell.now { background: rgba(110,44,139,0.045); }
.rmcard { background: var(--white); border: 1px solid var(--border); border-left: 3px solid var(--st-default); border-radius: var(--radius); padding: 8px 10px; cursor: pointer; box-shadow: var(--shadow-xs); transition: box-shadow var(--transition); }
.rmcard:hover { box-shadow: var(--shadow); }
.rmcard-title { font-size: 12.5px; font-weight: 500; color: #283040; line-height: 1.3; margin-bottom: 5px; }
.rmcard-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ─── Sprints ───────────────────────────────────────────────────── */
.sprint-block { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 16px; overflow: hidden; }
.sprint-block-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); background: var(--bg-sunken); }
.sprint-status { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 9px; border-radius: 11px; }
.sprint-status.active { color: var(--success); background: var(--success-bg); }
.sprint-status.planned { color: var(--info); background: #EAF1FE; }
.sprint-status.done { color: var(--text-secondary); background: var(--bg-sunken); border: 1px solid var(--border); }
.sprint-block-title { font-family: var(--font-title); font-weight: 700; font-size: 15px; color: #1f2733; }
.sprint-block-body { padding: 8px; }
.sprint-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius); cursor: pointer; }
.sprint-row:hover { background: var(--bg); }
.sprint-row + .sprint-row { border-top: 1px solid var(--border); }
.sprint-move { margin-left: auto; }
.sprint-empty { padding: 16px; text-align: center; color: var(--text-faint); font-size: 12.5px; }

/* ─── Directives ────────────────────────────────────────────────── */
.cat-block { margin-bottom: 26px; }
.cat-label { font-family: var(--font-title); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 12px; }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.dir-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-xs); display: flex; flex-direction: column; gap: 10px; }
.dir-card.inactive { opacity: 0.62; }
.dir-card-head { display: flex; align-items: flex-start; gap: 10px; }
.dir-card-title { font-family: var(--font-title); font-weight: 700; font-size: 14.5px; color: #1f2733; flex: 1; }
.dir-card-key { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.dir-card-body { font-size: 13px; color: var(--text); line-height: 1.5; max-height: 220px; overflow: hidden; position: relative; }
.dir-card-body.collapsed::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 40px; background: linear-gradient(transparent, var(--white)); }
.dir-card-actions { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; }
.toggle { position: relative; width: 36px; height: 20px; border-radius: 11px; background: var(--border-strong); transition: background var(--transition); border: none; flex-shrink: 0; }
.toggle.on { background: var(--success); }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left var(--transition); box-shadow: var(--shadow-xs); }
.toggle.on::after { left: 18px; }

/* ─── Docs ──────────────────────────────────────────────────────── */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.doc-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-xs); cursor: pointer; display: flex; flex-direction: column; gap: 9px; transition: all var(--transition); }
.doc-card:hover { border-color: var(--purple-light); box-shadow: var(--shadow); }
.doc-card-head { display: flex; align-items: flex-start; gap: 8px; }
.doc-card-title { font-family: var(--font-title); font-weight: 700; font-size: 14.5px; color: #1f2733; flex: 1; line-height: 1.3; }
.doc-card-meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-secondary); flex-wrap: wrap; }
.doc-type-badge { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 5px; background: rgba(110,44,139,0.1); color: var(--purple); }
.doc-status-badge { font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 11px; }
.ds-draft { color: var(--text-secondary); background: var(--bg-sunken); }
.ds-review { color: var(--warning); background: var(--warning-bg); }
.ds-approved { color: var(--success); background: var(--success-bg); }
.ds-superseded { color: var(--text-faint); background: var(--bg-sunken); text-decoration: line-through; }
.doc-tags { display: flex; flex-wrap: wrap; gap: 5px; }

/* ─── Insights ──────────────────────────────────────────────────── */
.insights-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.panel { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-xs); }
.panel-title { font-family: var(--font-title); font-size: 14px; font-weight: 700; color: #1f2733; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.panel-title .count-pill { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--text-secondary); background: var(--bg-sunken); border-radius: 9px; padding: 1px 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-label { width: 110px; font-size: 12px; color: var(--text-secondary); flex-shrink: 0; display: flex; align-items: center; gap: 6px; }
.bar-track { flex: 1; height: 18px; background: var(--bg-sunken); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; transition: width 0.5s cubic-bezier(0.4,0,0.2,1); min-width: 2px; }
.bar-value { width: 34px; text-align: right; font-size: 12px; font-weight: 700; color: var(--text); flex-shrink: 0; }
.gauge { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.gauge-num { font-family: var(--font-title); font-size: 34px; font-weight: 700; color: var(--purple); }
.gauge-label { font-size: 13px; color: var(--text-secondary); }
.viol-list { display: flex; flex-direction: column; gap: 8px; }
.viol-item { display: flex; gap: 10px; padding: 9px 11px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--border); font-size: 12.5px; cursor: pointer; }
.viol-item:hover { border-color: var(--border-strong); }
.viol-item .viol-dot { margin-top: 4px; }
.viol-item .viol-id { font-family: var(--font-mono); font-weight: 600; color: var(--text); }
.viol-item .viol-msg { color: var(--text-secondary); }
.clean-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px; color: var(--success); font-size: 13px; font-weight: 600; }

/* ─── Claims ────────────────────────────────────────────────────── */
.claims-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.claims-table th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-secondary); padding: 10px 14px; background: var(--bg-sunken); border-bottom: 1px solid var(--border); }
.claims-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.claims-table tr:last-child td { border-bottom: none; }

/* ─── Drawer (item detail) ──────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(20,24,32,0.42); backdrop-filter: blur(1.5px); opacity: 0; transition: opacity var(--transition); z-index: 80; }
.overlay.open { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 540px; max-width: 94vw; background: var(--white); box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform 0.26s cubic-bezier(0.4,0,0.2,1); z-index: 90; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); }
.drawer-head-top { display: flex; align-items: flex-start; gap: 12px; }
.drawer-id { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--text-faint); }
.drawer-title-input { font-family: var(--font-title); font-size: 18px; font-weight: 700; color: #1f2733; border: 1px solid transparent; border-radius: var(--radius); padding: 4px 6px; margin: 2px -6px 0; width: 100%; background: transparent; outline: none; line-height: 1.3; }
.drawer-title-input:hover { background: var(--bg-sunken); }
.drawer-title-input:focus { background: var(--white); border-color: var(--purple-light); box-shadow: 0 0 0 3px rgba(155,89,182,0.14); }
.drawer-close { flex-shrink: 0; width: 32px; height: 32px; border-radius: var(--radius); border: none; background: var(--bg-sunken); color: var(--text-secondary); font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.drawer-close:hover { background: var(--border); color: var(--text); }
.drawer-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px; }
.drawer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin-bottom: 18px; }
.drawer-field.full { grid-column: 1 / -1; }
.md-editor { position: relative; }
.md-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.md-tab { font-size: 11.5px; font-weight: 600; color: var(--text-secondary); background: var(--bg-sunken); border: 1px solid var(--border); padding: 3px 10px; border-radius: 6px; }
.md-tab.active { color: var(--purple); background: var(--white); border-color: var(--purple-light); }
.md-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-height: 90px; font-size: 13px; line-height: 1.6; background: var(--bg); }
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4 { font-family: var(--font-title); margin: 0.7em 0 0.4em; color: #1f2733; }
.md-preview h1 { font-size: 17px; } .md-preview h2 { font-size: 15px; } .md-preview h3 { font-size: 14px; }
.md-preview p { margin: 0.5em 0; } .md-preview ul, .md-preview ol { margin: 0.5em 0 0.5em 1.3em; }
.md-preview code { font-family: var(--font-mono); background: var(--bg-sunken); padding: 1px 4px; border-radius: 4px; font-size: 0.88em; }
.md-preview pre { background: #1f2733; color: #e6e9ef; padding: 10px 12px; border-radius: var(--radius); overflow-x: auto; margin: 0.6em 0; }
.md-preview pre code { background: none; color: inherit; padding: 0; }
.md-preview table { width: 100%; border-collapse: collapse; margin: 0.6em 0; }
.md-preview th, .md-preview td { border: 1px solid var(--border); padding: 5px 8px; text-align: left; font-size: 12.5px; }
.md-preview th { background: var(--bg-sunken); }
.md-preview blockquote { border-left: 3px solid var(--purple-light); padding-left: 12px; color: var(--text-secondary); margin: 0.5em 0; }
.md-preview a { color: var(--purple); }
.dep-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dep-chip { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; color: var(--purple); background: rgba(110,44,139,0.08); border: 1px solid rgba(110,44,139,0.18); padding: 3px 8px; border-radius: 6px; }
.dep-chip:hover { background: rgba(110,44,139,0.14); }
.dep-chip.missing { color: var(--danger); background: var(--danger-bg); border-color: #F3C9C9; }
.attach-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12.5px; }
.attach-row a { color: var(--purple); font-weight: 500; text-decoration: none; }
.attach-row a:hover { text-decoration: underline; }
.activity-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--purple-light); margin-top: 5px; flex-shrink: 0; }
.activity-meta { color: var(--text-faint); font-size: 11px; }
.drawer-foot { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--bg); }
.drawer-foot .spacer { flex: 1; }
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin: 18px 0 8px; }

/* ─── Modal ─────────────────────────────────────────────────────── */
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -48%); background: var(--white); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); width: 560px; max-width: 94vw; max-height: 90vh; display: flex; flex-direction: column; z-index: 90; opacity: 0; transition: opacity var(--transition), transform var(--transition); }
.modal.open { opacity: 1; transform: translate(-50%, -50%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-title { font-family: var(--font-title); font-size: 17px; font-weight: 700; color: #1f2733; flex: 1; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--bg); }
.modal-foot .spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-row2 { margin-bottom: 14px; }
.form-msg { font-size: 12.5px; padding: 8px 11px; border-radius: var(--radius); margin-top: 12px; display: none; }
.form-msg.err { display: block; color: var(--danger); background: var(--danger-bg); border: 1px solid #F3C9C9; }
.form-msg.ok { display: block; color: var(--success); background: var(--success-bg); border: 1px solid #BBF7D0; }

/* ─── Toasts ────────────────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 120; }
.toast { display: flex; align-items: center; gap: 10px; background: #1f2733; color: #fff; padding: 11px 15px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500; min-width: 240px; max-width: 380px; transform: translateX(120%); transition: transform 0.28s cubic-bezier(0.4,0,0.2,1); }
.toast.show { transform: translateX(0); }
.toast.success { background: #064E3B; }
.toast.error { background: #7F1D1D; }
.toast .toast-icon { flex-shrink: 0; display: flex; }
.toast .toast-icon svg { width: 17px; height: 17px; }
.toast .toast-action { margin-left: auto; font-weight: 700; text-decoration: underline; cursor: pointer; white-space: nowrap; }

/* ─── Empty / loading states ────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 60px 24px; text-align: center; color: var(--text-secondary); }
.empty-state .es-icon { width: 46px; height: 46px; color: var(--text-faint); opacity: 0.7; }
.empty-state .es-title { font-family: var(--font-title); font-size: 15px; font-weight: 700; color: var(--text); }
.empty-state .es-sub { font-size: 13px; max-width: 360px; }
.skeleton { background: linear-gradient(90deg, #eef0f5 25%, #f6f7fa 50%, #eef0f5 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel-card { height: 150px; border-radius: var(--radius-xl); }
.skel-line { height: 12px; margin: 8px 0; }

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .rail { width: 64px; padding: 12px 8px; }
  .rail-link span.rl-text, .rail-section-label, .rail-link .badge-count { display: none; }
  .rail-link { justify-content: center; padding: 10px; }
  .global-search { width: 180px; }
}
@media (max-width: 720px) {
  .content-inner { padding: 16px; }
  .global-search { display: none; }
  .drawer-grid, .form-grid { grid-template-columns: 1fr; }
  .roadmap-cols-head, .roadmap-lane { grid-template-columns: 110px 1fr; }
  .roadmap-col-label.rc-next, .roadmap-col-label.rc-later, .lane-cell.col-next, .lane-cell.col-later { display: none; }
}
.hidden { display: none !important; }
