/* ==========================================================================
   SkillBridge Digital — institutional workspace theme
   Crisp 1px borders, solid surfaces, 8px spacing grid, navy ink + teal accent.
   Amber is reserved for important status only. No blur, no glassmorphism.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;

  /* Ink */
  --ink: #0c1f33;
  --ink-2: #2e4258;
  --muted: #51667b;

  /* Lines */
  --line: #d7dde3;
  --line-strong: #b3bfca;

  /* Brand teal */
  --accent: #0e6f66;
  --accent-strong: #0a5750;
  --accent-deep: #07443f;
  --accent-soft: #e4efed;
  --accent-line: #a9cdc8;

  /* Status */
  --amber: #8a5b0a;
  --amber-bg: #fbf1dd;
  --amber-line: #e0c48b;
  --red: #a83a2a;
  --red-bg: #faeeec;
  --red-line: #e2b1a8;

  /* Elevation — restrained, hierarchy only */
  --shadow-1: 0 1px 2px rgba(12, 31, 51, 0.05);
  --shadow-2: 0 1px 3px rgba(12, 31, 51, 0.06), 0 4px 12px rgba(12, 31, 51, 0.06);
  --shadow-3: 0 4px 10px rgba(12, 31, 51, 0.08), 0 16px 40px rgba(12, 31, 51, 0.12);

  /* Radius */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
}

body.high-contrast {
  --bg: #eef0f3;
  --surface: #ffffff;
  --surface-2: #e4e9ee;
  --line: #9fadba;
  --line-strong: #74879a;
  --muted: #3c5166;
  --ink-2: #22364c;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
}

img {
  max-width: 100%;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(14, 111, 102, 0.18);
}

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

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

h2 {
  font-size: 1.0625rem;
  font-weight: 600;
}

.eyebrow,
.preview-kicker {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* Numeric alignment for scores, counts, and stats */
.score-summary span,
.score-summary small,
.rating-row output,
.eco-row output,
.manager-overview strong,
.score-pill {
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  align-items: center;
  gap: 16px;
  min-height: 60px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

body[data-view="home"] .topbar {
  grid-template-columns: auto;
  background: transparent;
  border-bottom-color: transparent;
}

body:not([data-view="journal"]) .dashboard-link,
body[data-view="home"] .nav,
body[data-view="home"] .journal-link,
body[data-view="home"] .session-bar,
body[data-view="home"] #theme-toggle {
  display: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: var(--accent-strong);
  color: #ffffff;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.nav a {
  padding: 8px 12px;
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* Signed-in users navigate between workspaces, not back to the login page */
body[data-role="analyst"] .nav a[data-view-link="home"],
body[data-role="manager"] .nav a[data-view-link="home"] {
  display: none;
}

.dashboard-link,
.journal-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  white-space: nowrap;
  border-radius: var(--r-md);
  padding: 8px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.dashboard-link {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent-strong);
}

.dashboard-link:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.journal-link {
  border: 1px solid var(--accent-strong);
  background: var(--accent-strong);
  color: #ffffff;
}

.journal-link:hover {
  border-color: var(--accent-deep);
  background: var(--accent-deep);
}

.journal-link.is-active {
  border-color: var(--accent-deep);
  background: var(--accent-deep);
}

.dashboard-link svg,
.journal-link svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.logout-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-2);
  padding: 8px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.logout-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-2);
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.icon-button svg,
button svg,
.search-box svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

/* --------------------------------------------------------------------------
   Layout shell
   -------------------------------------------------------------------------- */

main {
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
  animation: fade-in 140ms ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

svg.lucide-loader-circle {
  animation: spin 0.9s linear infinite;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.primary-action,
.secondary-action,
.danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: var(--r-md);
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
}

.primary-action {
  border: 1px solid var(--accent-strong);
  background: var(--accent-strong);
  color: #ffffff;
}

.primary-action:hover {
  border-color: var(--accent-deep);
  background: var(--accent-deep);
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent-strong);
}

.secondary-action:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.danger-action {
  border: 1px solid var(--red-line);
  background: var(--surface);
  color: var(--red);
}

.danger-action:hover {
  background: var(--red-bg);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

label {
  color: var(--ink-2);
  font-size: 0.8125rem;
  font-weight: 600;
}

.form-row > label,
.login-form > label,
.password-setup-form > label,
.password-panel > label,
.technical-fields > label > span,
.volume-select > span {
  display: block;
  color: var(--ink-2);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 12px;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #7d8b99;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 111, 102, 0.14);
}

/* --------------------------------------------------------------------------
   Home / sign-in
   -------------------------------------------------------------------------- */

.home-shell {
  min-height: calc(100vh - 140px);
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 400px);
  align-items: center;
  gap: 48px;
  width: min(1000px, 100%);
  margin: 0 auto;
}

.home-copy {
  max-width: 620px;
}

.home-copy h1 {
  font-size: clamp(2.4rem, 4.5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.025em;
}

.lede {
  margin: 24px 0 0;
  padding-top: 16px;
  width: max-content;
  max-width: 100%;
  border-top: 2px solid var(--accent);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.login-panel {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  padding: 24px;
}

.login-panel h2 {
  margin-top: 2px;
  font-size: 1.375rem;
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 8px;
}

.login-form > label {
  margin-top: 8px;
}

.login-form > label:first-child {
  margin-top: 0;
}

.login-form .primary-action {
  margin-top: 16px;
  width: 100%;
}

/* --------------------------------------------------------------------------
   First-login password dialog
   -------------------------------------------------------------------------- */

.password-setup-dialog {
  width: min(92vw, 460px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-3);
  padding: 0;
}

.password-setup-dialog::backdrop {
  background: rgba(12, 31, 51, 0.6);
}

.password-setup-form {
  display: grid;
  gap: 10px;
  padding: 28px;
}

.password-setup-form h2 {
  margin-top: 4px;
  font-size: 1.375rem;
  font-weight: 700;
}

.password-setup-form > label {
  margin-top: 8px;
}

.password-setup-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  margin-bottom: 4px;
}

.password-setup-copy,
.password-requirements {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.password-setup-copy {
  margin-top: 8px;
  font-size: 0.9375rem;
}

.password-requirements {
  font-size: 0.8125rem;
}

.password-setup-error {
  margin: 0;
  min-height: 1.3em;
  color: var(--red);
  font-size: 0.8125rem;
  font-weight: 600;
}

.password-setup-form .primary-action {
  justify-content: center;
  margin-top: 8px;
  width: 100%;
}

/* --------------------------------------------------------------------------
   Workspace headers
   -------------------------------------------------------------------------- */

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.workspace-header h1 {
  font-size: 1.5rem;
}

.analyst-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.analyst-toolbar:has(#publish-report[hidden]) {
  display: none;
}

/* --------------------------------------------------------------------------
   Panels and cards (shared)
   -------------------------------------------------------------------------- */

.sidebar,
.work-form,
.preview-panel,
.work-list,
.selected-work,
.analysis-spaces,
.analyst-status-panel,
.rating-panel,
.manager-overview article,
.report-detail-tools {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.panel-empty {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  padding: 24px 16px;
  text-align: center;
}

.panel-empty p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Sidebars
   -------------------------------------------------------------------------- */

.sidebar {
  position: sticky;
  top: 76px;
  display: grid;
  gap: 2px;
  padding: 8px;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: transparent;
  color: var(--ink-2);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
}

.side-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.side-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  box-shadow: inset 2px 0 0 var(--accent);
}

.manager-controls {
  gap: 16px;
  padding: 12px;
}

.manager-tool-group {
  display: grid;
  gap: 4px;
}

.manager-tool-group > .eyebrow {
  margin: 4px 4px 6px;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Analyst workspace
   -------------------------------------------------------------------------- */

.dashboard-grid {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr) 336px;
  gap: 16px;
  align-items: start;
}

.analyst-workbench {
  display: grid;
  gap: 16px;
}

.analysis-spaces {
  display: grid;
  gap: 16px;
  padding: 16px;
}

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

.space-card {
  display: grid;
  gap: 4px;
  align-content: start;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.space-card:hover {
  border-color: var(--line-strong);
}

.space-card.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.space-card span {
  color: var(--accent-strong);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.space-card strong {
  font-size: 0.9375rem;
  font-weight: 600;
}

.space-card small {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.analyst-status-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.analyst-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.analyst-card-grid,
.work-group {
  display: grid;
  gap: 8px;
}

.analyst-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 16px;
}

.analyst-card h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.analyst-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.analyst-card > p {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.analyst-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analyst-card-actions .secondary-action {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 0.8125rem;
}

/* --------------------------------------------------------------------------
   LOVER rating panel
   -------------------------------------------------------------------------- */

.rating-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.rating-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.score-summary {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  justify-content: end;
  gap: 2px 4px;
  min-width: 128px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 10px 12px;
  text-align: right;
}

.score-summary span {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}

.score-summary small {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.score-summary strong {
  grid-column: 1 / -1;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.rating-grid,
.eco-data-panel,
#eco-rating-grid {
  display: grid;
  gap: 8px;
}

.rating-row,
.eco-row {
  display: grid;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 10px 12px;
}

.rating-row {
  grid-template-columns: minmax(150px, 1fr) minmax(120px, 190px) 48px;
}

.rating-row.is-fixed,
.eco-row {
  grid-template-columns: minmax(150px, 1fr) 72px;
}

.rating-row span,
.eco-row span {
  color: var(--ink);
  font-size: 0.875rem;
}

.rating-row strong {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
}

.rating-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.4;
}

.rating-row output,
.eco-row output {
  color: var(--accent-strong);
  font-size: 0.8125rem;
  font-weight: 700;
  text-align: right;
}

.rating-row select {
  min-height: 36px;
  padding: 6px 10px;
}

.rank-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.rank-scale span {
  display: grid;
  place-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--muted);
  padding: 6px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.rank-scale span.is-active {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #ffffff;
}

.rating-detail-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(280px, 1.2fr);
  gap: 8px;
}

.volume-select,
.eco-data-panel {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 12px;
}

.volume-select {
  display: grid;
  gap: 8px;
  align-content: start;
}

.eco-data-panel h3 {
  font-size: 0.9375rem;
  font-weight: 600;
}

/* Rank colors — amber only for the caution band */
.rank-no-trade,
.rank-ok-trade {
  color: var(--red);
}

.rank-tradable {
  color: var(--amber);
}

.rank-good-trade,
.rank-excellent-trade {
  color: var(--accent-strong);
}

/* --------------------------------------------------------------------------
   Technical workspace
   -------------------------------------------------------------------------- */

.technical-panel {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.technical-titlebar {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  background: var(--ink);
  color: #ffffff;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.technical-chart-card {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 16px;
}

.chart-upload-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 12px;
}

.chart-upload-bar label,
.chart-upload-bar .secondary-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--accent-strong);
  padding: 6px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
}

.chart-upload-bar label:hover,
.chart-upload-bar .secondary-action:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.chart-upload-bar input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.technical-chart {
  display: block;
  width: 100%;
  min-height: 320px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
}

.technical-chart-placeholder {
  display: grid;
  place-items: center;
  background: var(--surface-2);
}

.technical-chart-placeholder::after {
  content: "No chart image yet";
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.technical-uploaded-image {
  display: block;
  width: 100%;
  max-height: 620px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}

.technical-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 16px;
}

.technical-fields label {
  display: grid;
  gap: 6px;
  align-content: start;
}

.technical-fields label:nth-child(n + 3) {
  grid-column: 1 / -1;
}

.technical-fields label:nth-child(5),
.technical-fields label:nth-child(6) {
  border: 1px solid var(--accent-line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  background: #f4f9f8;
  padding: 12px;
}

.technical-fields label:nth-child(5) > span,
.technical-fields label:nth-child(6) > span {
  color: var(--accent-deep);
}

/* --------------------------------------------------------------------------
   Work form + preview
   -------------------------------------------------------------------------- */

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

.form-row {
  display: grid;
  gap: 6px;
}

.form-row:nth-child(5),
.form-row:nth-child(6) {
  grid-column: 1 / -1;
}

.preview-panel,
.selected-work {
  padding: 20px;
}

.preview-panel h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

#preview-notes,
#selected-notes {
  white-space: pre-line;
}

.preview-panel p,
.selected-work p {
  color: var(--muted);
  line-height: 1.6;
}

.preview-links,
.selected-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inline-auto-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 0 5px;
  font-size: 0.875em;
  font-weight: 600;
  line-height: 1.45;
}

.inline-auto-link.is-date {
  border-color: var(--amber-line);
  background: var(--amber-bg);
  color: var(--amber);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 3px 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.75rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Review workspace
   -------------------------------------------------------------------------- */

.manager-workspace {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.manager-workspace-header {
  margin-bottom: 20px;
}

.manager-main-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.manager-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.manager-overview article {
  padding: 14px 16px;
}

.manager-overview span {
  display: block;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.manager-overview strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.1;
}

.manager-review-panel {
  display: grid;
  gap: 12px;
}

.manager-review-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.manager-review-head h2 {
  margin-top: 4px;
  font-size: 1.25rem;
  font-weight: 700;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 320px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--muted);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 111, 102, 0.14);
}

.search-box input {
  border: 0;
  background: transparent;
  box-shadow: none !important;
  padding: 8px 0;
}

/* Review queue — table-like rows */
.work-list {
  display: block;
  padding: 4px 0;
  overflow: hidden;
}

.manager-review-panel .work-list {
  min-height: 320px;
}

.work-list > .panel-empty {
  margin: 12px;
}

.work-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.work-list > .work-card:first-child,
.work-group .work-card:first-of-type {
  border-top: 0;
}

.work-card:hover {
  background: #fafbfc;
}

.work-card.is-selected {
  background: #f4f9f8;
  box-shadow: inset 3px 0 0 var(--accent);
}

.work-group {
  gap: 0;
}

.work-group + .work-group {
  border-top: 1px solid var(--line);
}

.work-group h3 {
  margin: 0;
  padding: 12px 16px 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.work-card-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.work-card-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.work-card h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.work-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.work-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.work-card-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.work-card-actions small {
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Status pills — neutral by default; amber flags work awaiting review */
.status-pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 1px 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.6875rem;
  font-weight: 600;
}

.status-pill.is-new {
  border-color: var(--amber-line);
  background: var(--amber-bg);
  color: var(--amber);
}

.status-pill.is-reviewed {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.score-pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 1px 8px;
  background: var(--surface-2);
  font-size: 0.6875rem;
  font-weight: 700;
}

.score-pill.rank-no-trade,
.score-pill.rank-ok-trade {
  border-color: var(--red-line);
  background: var(--red-bg);
}

.score-pill.rank-tradable {
  border-color: var(--amber-line);
  background: var(--amber-bg);
}

.score-pill.rank-good-trade,
.score-pill.rank-excellent-trade {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.open-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--accent-strong);
  padding: 5px 10px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.open-button:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* Analyst access panel */
.password-panel {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.password-panel > label {
  margin: 0 4px;
}

.password-panel .secondary-action {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.8125rem;
}

.password-panel output {
  display: block;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink-2);
  padding: 9px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Report detail
   -------------------------------------------------------------------------- */

.report-detail-header {
  margin-bottom: 20px;
}

.report-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 304px;
  gap: 16px;
  align-items: start;
}

.report-detail-card {
  min-height: calc(100vh - 200px);
}

.report-detail-card h2 {
  margin: 6px 0 12px;
  font-size: clamp(1.5rem, 3vw, 2.125rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.report-detail-card #selected-notes {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 16px;
  margin: 12px 0 16px;
}

.selected-work textarea {
  margin-top: 16px;
}

.selected-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.selected-rating {
  margin-top: 16px;
}

.manager-rating-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 16px;
}

.manager-rating-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 700;
}

.manager-rating-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.manager-rating-grid strong {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.technical-review-card {
  gap: 12px;
}

.technical-review-card p {
  margin: 0;
}

.manager-technical-chart {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}

.report-detail-tools {
  position: sticky;
  top: 76px;
  padding: 16px;
}

.report-detail-tools .forex-links {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}

.forex-links {
  display: grid;
  gap: 12px;
}

.forex-links h2 {
  font-size: 1rem;
}

.forex-pair-list {
  display: grid;
  gap: 8px;
}

.forex-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 12px;
}

.forex-card strong {
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.forex-card span {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.forex-card div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.forex-card button {
  min-height: 24px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 2px 7px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.forex-card button:hover {
  border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Journal
   -------------------------------------------------------------------------- */

.journal-view {
  width: min(1840px, 100%);
  margin: 0 auto;
}

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

.journal-header h1 {
  font-size: 1.5rem;
}

.journal-frame {
  display: block;
  width: 100%;
  min-height: calc(100vh - 160px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #ffffff;
  box-shadow: var(--shadow-1);
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  max-width: 340px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Responsive — 1440 / 1024 / 768 / 360
   -------------------------------------------------------------------------- */

@media (max-width: 1240px) {
  .dashboard-grid {
    grid-template-columns: 208px minmax(0, 1fr) 296px;
  }
}

@media (max-width: 1120px) {
  .home-shell,
  .dashboard-grid,
  .manager-workspace,
  .report-detail-layout {
    grid-template-columns: 1fr;
  }

  .manager-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .space-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar {
    position: static;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  }

  .manager-controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .manager-controls .manager-tool-group:first-child {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }

  .manager-controls .manager-tool-group:first-child > .eyebrow {
    grid-column: 1 / -1;
  }

  .password-panel {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
    border-left: 1px solid var(--line);
    padding-left: 16px;
  }

  .report-detail-tools {
    position: static;
  }
}

@media (max-width: 820px) {
  .nav {
    display: none;
  }

  .topbar {
    grid-template-columns: auto 1fr auto auto;
    gap: 8px;
    padding: 8px 16px;
  }

  .brand span:last-child {
    display: none;
  }

  .topbar .brand {
    grid-column: 1;
    grid-row: 1;
  }

  .journal-link {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    max-width: 190px;
  }

  .session-bar {
    grid-column: 3;
    grid-row: 1;
  }

  .topbar > .icon-button {
    grid-column: 4;
    grid-row: 1;
  }

  .dashboard-link {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
  }

  main {
    width: calc(100% - 24px);
    padding-top: 16px;
  }

  .home-shell {
    min-height: 0;
    gap: 24px;
    padding-top: 16px;
  }

  .home-copy h1 {
    font-size: 2.125rem;
  }

  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .work-form,
  .technical-fields {
    grid-template-columns: 1fr;
  }

  .technical-fields label:nth-child(n + 1) {
    grid-column: auto;
  }

  .space-grid {
    grid-template-columns: 1fr;
  }

  .rating-header {
    display: grid;
    gap: 12px;
  }

  .score-summary {
    width: 100%;
    justify-content: start;
    text-align: left;
  }

  .rating-row,
  .eco-row,
  .rating-detail-grid {
    grid-template-columns: 1fr;
  }

  .rating-row output,
  .eco-row output {
    text-align: left;
  }

  .rank-scale {
    grid-template-columns: 1fr;
  }

  .rank-scale span {
    justify-items: start;
    padding: 8px 12px;
    text-align: left;
  }

  .manager-controls {
    grid-template-columns: 1fr;
  }

  .password-panel {
    border-left: 0;
    padding-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 16px;
  }

  .search-box {
    min-width: 0;
    width: 100%;
  }

  .manager-review-head {
    align-items: stretch;
    flex-direction: column;
  }

  .work-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .work-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-direction: row-reverse;
  }

  .work-card-actions small {
    text-align: left;
  }

  .selected-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  main {
    width: calc(100% - 16px);
  }

  .home-copy h1 {
    font-size: 1.875rem;
  }

  .login-panel,
  .preview-panel,
  .selected-work {
    padding: 16px;
  }

  .password-setup-form {
    padding: 20px;
  }

  .manager-overview {
    gap: 8px;
  }

  .manager-overview article {
    padding: 12px;
  }

  .manager-overview strong {
    font-size: 1.375rem;
  }

  .sidebar:not(.manager-controls) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
