:root {
  color-scheme: light;
  --bg: #f7f7f6;
  --panel: #ffffff;
  --panel-soft: #fbfbfa;
  --text: #242331;
  --navy: #102a3d;
  --muted: #6f727b;
  --line: #ebe9e5;
  --accent: #FFD07A;
  --accent-strong: #242331;
  --accent-soft: #fff4d9;
  --blue: var(--accent);
  --blue-soft: var(--accent-soft);
  --shadow: 0 14px 36px rgb(36 35 49 / 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #20232a;
  --panel: #111827;
  --panel-soft: #172033;
  --text: #edf4ff;
  --navy: #edf4ff;
  --muted: #9aa8bc;
  --line: #2b3a52;
  --accent: #FFD07A;
  --accent-strong: #111827;
  --accent-soft: #332b1a;
  --blue: var(--accent);
  --blue-soft: var(--accent-soft);
  --shadow: 0 18px 44px rgb(0 0 0 / 0.28);
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

.page-loading {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--text);
}

.loading-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid color-mix(in srgb, var(--blue) 18%, var(--line));
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-strong);
  cursor: pointer;
  padding: 0 12px;
  font-weight: 700;
}

button:hover {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--text));
  background: color-mix(in srgb, var(--accent) 84%, white);
}

button.secondary {
  background: var(--panel);
  color: var(--text);
}

button.danger {
  border-color: #fecaca;
  color: #b91c1c;
}

.app-shell {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 48px;
  min-height: 100vh;
  padding: 28px 48px 28px 18px;
}

.app-shell.sidebar-collapsed,
.app-shell:has(.sidebar.collapsed) {
  gap: 28px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 326px;
  min-height: calc(100vh - 56px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: width 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 64px;
}

.sidebar.collapsed strong,
.sidebar.collapsed .side-nav span:not(.nav-icon),
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .role-badge,
.sidebar.collapsed .side-footer strong,
.sidebar.collapsed .side-footer button span { display: none; }

.sidebar.collapsed .brand {
  justify-content: center;
  min-height: 104px;
  padding: 24px 8px 14px;
}

.sidebar.collapsed .nep-mark {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  font-size: 12px;
}

.sidebar.collapsed .side-nav {
  gap: 14px;
  padding: 18px 8px;
}

.sidebar.collapsed .side-nav button {
  justify-content: center;
  min-height: 46px;
  padding: 0;
  border-radius: 12px;
}

.sidebar.collapsed .nav-icon {
  width: 24px;
  font-size: 19px;
}

.sidebar.collapsed .side-footer {
  justify-content: center;
  min-height: 104px;
  padding: 16px 8px;
}

.sidebar.collapsed .side-footer .avatar {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  font-size: 13px;
}

.sidebar.collapsed .side-footer button {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 132px;
  padding: 36px 34px 20px;
  border-bottom: 0;
}

.nep-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-strong);
  font-size: 15px;
  font-weight: 950;
  box-shadow: none;
}

.brand strong {
  color: var(--text);
  font-size: 27px;
  line-height: 1.05;
  letter-spacing: 0;
}

.nep-mark.image-logo {
  overflow: hidden;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: none;
  box-shadow: none;
}

.nep-mark.image-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 20px 36px;
  flex: 1;
}

.side-nav button {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 62px;
  padding: 0 24px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 20px;
  font-weight: 500;
}

.side-nav button.active {
  background: var(--accent);
  color: var(--accent-strong);
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.role-badge + .nav-badge:not(.hidden) {
  margin-left: 4px;
}

.nav-badge-new {
  background: #ff4d5d;
  color: #ffffff;
}

.nav-badge-comingSoon {
  min-width: 78px;
  background: var(--panel-soft);
  color: var(--muted);
  border: 1px solid var(--line);
}

.nav-icon {
  display: grid;
  min-width: 26px;
  place-items: center;
  color: currentColor;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-icon svg path:first-child:last-child,
.nav-icon svg path:first-child {
  fill: none;
}

.side-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 106px;
  padding: 24px 36px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 18px;
}

.side-footer button {
  margin-left: auto;
  width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
}

.main-shell {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 0 0 18px;
  background: transparent;
  border-bottom: 0;
}

.account-control,
.issue-jump,
.top-user {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.account-control span,
.issue-jump label,
.top-search span {
  color: var(--muted);
  font-size: 12px;
}

.account-control button {
  min-height: 28px;
  border: 0;
  background: transparent;
  color: var(--text);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 8px 10px;
}

.required-label {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
}

.required-label strong,
.required-help {
  color: var(--danger);
}

.required-help {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  font-weight: 800;
}

.load-older-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.assignee-picker {
  display: grid;
  gap: 8px;
}

.assignee-picker label {
  display: block;
}

.assignee-picker select.current-user-value,
.assignee-picker option.current-user-option {
  background: var(--panel-soft);
}

.issue-jump input { width: 76px; padding: 5px 8px; }
.issue-jump button { min-height: 30px; }

.top-search {
  display: grid;
  flex: 1;
  max-width: 360px;
}

.top-search span { display: none; }
.top-search input { min-height: 32px; font-size: 12px; }

.top-user {
  margin-left: auto;
  font-size: 13px;
}

.top-user .avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 13px;
}

.theme-toggle,
.topbar-link {
  background: var(--blue-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  text-decoration: none;
}

.bell {
  display: grid;
  width: 28px;
  height: 28px;
  min-height: 28px;
  place-items: center;
  border-radius: 999px;
  padding: 0;
}

.bell {
  background: var(--accent);
  color: var(--accent-strong);
}

.avatar {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 850;
}

.avatar.large {
  width: 66px;
  height: 66px;
  border-radius: 12px;
  font-size: 20px;
}

main {
  padding: 0;
}

.page {
  display: none;
}

.page.active {
  display: grid;
  gap: 16px;
}

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

.welcome-row p {
  margin-top: 8px;
  font-size: 16px;
}

h1, h2, p { margin: 0; }
h1 {
  color: var(--text);
  font-size: clamp(38px, 3.2vw, 56px);
  line-height: 1.05;
  letter-spacing: 0;
}
h2 {
  color: var(--text);
  font-size: 16px;
}
p { color: var(--muted); font-size: 13px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgb(36 35 49 / 0.04);
  padding: 16px;
}

.card-title,
.card-actions,
.detail-head,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot.amber { background: #f59e0b; }
.empty-text { padding: 28px 0; text-align: center; color: #9ca3af; }

.mini-table,
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  color: var(--navy);
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.column-filters select,
.table-sort-button {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  background: var(--panel);
  color: var(--text);
}

.table-sort-button {
  min-height: 32px;
  box-shadow: none;
}

.column-filters th {
  padding-top: 10px;
  padding-bottom: 8px;
}

.clickable-issue-row {
  cursor: pointer;
}

.clickable-issue-row:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.clickable-issue-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.mini-table td:last-child {
  text-align: right;
  font-weight: 850;
}

.badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--blue-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.badge.in-progress { background: #dbeafe; color: #1d4ed8; }
.badge.closed { background: #e5e7eb; color: #4b5563; }
.badge.medium { background: #ffedd5; color: #c2410c; }
.badge.high { background: #fee2e2; color: #b91c1c; }
.badge.low { background: #dcfce7; color: #15803d; }
.badge.snqa { background: #ccfbf1; color: #0f766e; }
.badge.requires-assessment { background: #fef3c7; color: #b45309; }

.link-button {
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--navy);
}

.quick-list,
.watch-list {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.api-card {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 180px;
}

.quick-list button,
.watch-list button {
  justify-content: start;
  min-height: 30px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.watch-list button {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.watch-list span {
  color: var(--muted);
  font-size: 12px;
}

.bar-chart {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 28px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.bar-row div {
  height: 16px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.page-head {
  display: grid;
  gap: 4px;
}

.issue-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

label input,
label select,
label textarea {
  color: var(--text);
  font-weight: 500;
}

.span-2 { grid-column: 1 / -1; }

.settings-editor {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-soft);
}

.settings-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-editor h2 {
  margin: 0;
  font-size: 15px;
}

.tag-editor-rows {
  display: grid;
  gap: 8px;
}

.quick-report-editor-rows {
  display: grid;
  gap: 8px;
}

.section-badge-rows,
.section-access-rows {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-help {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.access-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  font-weight: 800;
}

.access-check.compact {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}

.access-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.access-hidden {
  display: none !important;
}

.user-access-dropdown,
.user-access-panel,
.user-access-checks {
  display: grid;
  gap: 8px;
}

.user-access-dropdown {
  position: relative;
  max-width: 220px;
}

.user-access-dropdown summary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

.user-access-dropdown summary::-webkit-details-marker {
  display: none;
}

.user-access-dropdown summary::after {
  content: "⌄";
  margin-left: 8px;
  color: var(--muted);
  font-size: 13px;
}

.user-access-dropdown[open] summary::after {
  transform: rotate(180deg);
}

.user-access-panel {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  width: min(320px, 70vw);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.user-access-checks {
  grid-template-columns: repeat(2, minmax(120px, 1fr));
}

.user-dashboard-defaults {
  margin-bottom: 18px;
}

.muted-text {
  color: var(--muted);
  font-weight: 800;
}

.quick-report-editor-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.tag-editor-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 52px auto;
  gap: 8px;
  align-items: center;
}

.tag-editor-row input[type="color"] {
  width: 52px;
  height: 38px;
  padding: 2px;
}

.settings-status {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.settings-status.ok { color: #15803d; }
.settings-status.error { color: #b91c1c; }

.csv-schema {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

.csv-schema strong {
  color: var(--text);
}

.logo-upload-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-card,
.report-form {
  display: grid;
  grid-template-columns: 1fr 220px 220px auto;
  gap: 12px;
  align-items: end;
}

.report-builder {
  display: grid;
  grid-template-columns: 280px minmax(360px, 1fr);
  gap: 16px;
  align-items: start;
}

.quick-report-panel {
  display: grid;
  gap: 10px;
}

.quick-report-panel select {
  min-height: 160px;
}

.report-filter-stack {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.report-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.table-controls {
  display: flex;
  justify-content: flex-end;
  padding-bottom: 12px;
}

.table-controls label,
.filter-card label {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.table-controls select,
.filter-card select {
  min-width: 120px;
}

fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.date-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.table-card {
  overflow: auto;
}

.detail-head {
  align-items: start;
}

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

.issue-save-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.inline-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

.progress-card {
  padding: 18px;
}

.progress-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.progress-close-action {
  display: flex;
  align-items: center;
  min-height: 78px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.stage-track {
  display: grid;
  grid-template-columns: repeat(var(--stage-count, 5), minmax(0, 1fr));
  gap: 10px;
}

.stage-track button {
  display: grid;
  justify-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: #9ca3af;
}

.stage-track i {
  width: 16px;
  height: 16px;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  background: var(--panel);
}

.stage-track button.complete i {
  border-color: var(--accent);
  background: var(--accent);
}

.stage-track button.current strong {
  color: var(--text);
}

.stage-track span {
  font-size: 10px;
}

.stage-track strong {
  font-size: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 16px;
}

.detail-main {
  display: grid;
  gap: 16px;
}

.field-card {
  display: grid;
  gap: 10px;
}

.drop-zone {
  display: grid;
  min-height: 100px;
  place-items: center;
  border: 2px dashed var(--line);
  border-radius: 8px;
  color: #9ca3af;
  font-size: 13px;
}

.side-detail dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

.side-detail div {
  display: grid;
  gap: 2px;
}

.side-detail dt {
  color: #9ca3af;
  font-size: 11px;
}

.side-detail dd {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.meta-editor {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}

.meta-editor dd {
  display: grid;
  gap: 10px;
}

.meta-editor label {
  gap: 5px;
}

.meta-editor label span {
  color: #9ca3af;
  font-size: 11px;
}

.assignment-editor {
  display: grid;
  gap: 10px;
}

@media (max-width: 1000px) {
  .app-shell,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    gap: 18px;
    padding: 14px;
  }

  .sidebar {
    position: static;
    width: 100%;
    min-height: 0;
  }

  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 14px;
  }

  .side-nav button {
    min-height: 48px;
    padding: 0 14px;
    font-size: 15px;
  }

  .brand {
    min-height: auto;
    padding: 20px;
  }

  .side-footer {
    min-height: auto;
    padding: 16px 20px;
  }

  .topbar {
    flex-wrap: wrap;
    height: auto;
  }

  .dashboard-grid,
  .issue-form,
  .filter-card,
  .report-form,
  .report-builder {
    grid-template-columns: 1fr;
  }

  .progress-layout {
    grid-template-columns: 1fr;
  }

  .progress-close-action {
    min-height: auto;
    padding: 14px 0 0;
    border-left: 0;
    border-top: 1px solid var(--line);
    justify-content: flex-end;
  }
}

/* Shared softer corner treatment. */
button,
input,
select,
textarea,
.theme-toggle,
.topbar-link,
.badge {
  border-radius: 12px;
}

.sidebar,
.card,
.filter-card,
.table-card,
.settings-editor,
.tag-editor-row,
.quick-report-editor-row,
.watch-list button,
.field-card,
.side-detail,
.drop-zone,
.page-loading {
  border-radius: 16px;
}

.side-nav button,
.sidebar.collapsed .side-nav button,
.avatar,
.nep-mark,
.top-user .avatar,
.avatar.large {
  border-radius: 14px;
}
