/*
 * Master CRM Design System — master-theme.css
 * =============================================
 * Entity themes, page type layouts, component library, typography,
 * view-mode visibility rules, and responsive breakpoints.
 *
 * Entity themes:  .theme-nc  |  .theme-and  |  .theme-ru  |  .theme-default
 * Page types:     .page-dossier  |  .page-hub  |  .page-proposal  |
 *                 .page-meeting  |  .page-dashboard  |  .page-activity  |
 *                 .page-target
 * View modes:     .view-internal  |  .view-client  |  .view-buyer
 */

/* ============================================================
   1. CSS CUSTOM PROPERTIES — TOKEN LAYER
   ============================================================ */

:root {
  /* --- Spacing scale --- */
  --space-1:  4px;
  --space-2:  8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* --- Radius --- */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;

  /* --- Elevation / Shadow --- */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.12);

  /* --- Transition --- */
  --transition-fast: 0.12s ease;
  --transition-base: 0.2s ease;

  /* --- Typography scale --- */
  --font-sans:   'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  --font-serif:  Georgia, 'Times New Roman', serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;

  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-md:   15px;
  --text-lg:   18px;
  --text-xl:   22px;
  --text-2xl:  28px;
  --text-3xl:  36px;

  --weight-normal:  400;
  --weight-medium:  500;
  --weight-semibold: 600;
  --weight-bold:    700;

  --leading-tight:  1.3;
  --leading-base:   1.6;
  --leading-loose:  1.8;
}

/* ============================================================
   2. DEFAULT THEME (dark base — shared by all entities)
   ============================================================ */

:root,
.theme-default {
  /* Backgrounds */
  --bg-base:       #ffffff;
  --bg-surface:    #f7f8fa;
  --bg-elevated:   #eef0f4;
  --bg-overlay:    #e2e5eb;
  --bg-inset:      #f3f4f6;

  /* Borders */
  --border-subtle: #e5e7eb;
  --border-base:   #d1d5db;
  --border-strong: #9ca3af;

  /* Text */
  --text-primary:   #1a1d23;
  --text-secondary: #3d4452;
  --text-muted:     #6b7280;
  --text-dim:       #9ca3af;
  --text-disabled:  #d1d5db;

  /* Accent — default is NC blue */
  --accent:         #2563eb;
  --accent-soft:    rgba(37,99,235,.08);
  --accent-border:  rgba(37,99,235,.25);
  --accent-hover:   #1d4ed8;

  /* Semantic colors */
  --color-success:  #059669;
  --color-warning:  #d97706;
  --color-danger:   #dc2626;
  --color-info:     #2563eb;
  --color-neutral:  #6b7280;

  --color-success-bg: rgba(5,150,105,.06);
  --color-warning-bg: rgba(217,119,6,.06);
  --color-danger-bg:  rgba(220,38,38,.06);
  --color-info-bg:    rgba(37,99,235,.06);

  /* Interactive */
  --focus-ring: 0 0 0 3px rgba(37,99,235,.25);
}

/* ============================================================
   3. ENTITY THEMES
   ============================================================ */

/* --- Next Chapter: blue on light --- */
.theme-nc {
  --accent:           #2563eb;
  --accent-soft:      rgba(37,99,235,.08);
  --accent-border:    rgba(37,99,235,.25);
  --accent-hover:     #1d4ed8;
  --focus-ring:       0 0 0 3px rgba(37,99,235,.25);

  --entity-name:      'Next Chapter';
  --entity-primary:   #2563eb;
  --entity-secondary: #1d4ed8;
  --entity-gradient:  linear-gradient(135deg, #f7f8fa 0%, #ffffff 50%, #f7f8fa 100%);
  --entity-badge-bg:  #2563eb;
  --entity-badge-text:#ffffff;
}

/* --- AND Capital: gold accent on light --- */
.theme-and {
  --bg-base:          #fefdfb;
  --bg-surface:       #faf8f4;
  --bg-elevated:      #f5f2ec;
  --bg-overlay:       #ede9e0;
  --bg-inset:         #fcfbf8;

  --border-subtle:    #e8e3d8;
  --border-base:      #d4cdbf;
  --border-strong:    #b8ae9a;

  --accent:           #a07d1c;
  --accent-soft:      rgba(160,125,28,.08);
  --accent-border:    rgba(160,125,28,.25);
  --accent-hover:     #8a6b16;
  --focus-ring:       0 0 0 3px rgba(160,125,28,.25);

  --entity-name:      'AND Capital';
  --entity-primary:   #a07d1c;
  --entity-secondary: #8a6b16;
  --entity-gradient:  linear-gradient(135deg, #faf8f4 0%, #fefdfb 50%, #faf8f4 100%);
  --entity-badge-bg:  #a07d1c;
  --entity-badge-text:#ffffff;
}

/* --- RevsUp: red accent on light --- */
.theme-ru {
  --bg-base:          #fffbfb;
  --bg-surface:       #fef5f5;
  --bg-elevated:      #fce8e8;
  --bg-overlay:       #f8d4d4;
  --bg-inset:         #fff7f7;

  --border-subtle:    #f3d1d1;
  --border-base:      #e8b0b0;
  --border-strong:    #d88888;

  --accent:           #b91c1c;
  --accent-soft:      rgba(185,28,28,.08);
  --accent-border:    rgba(185,28,28,.25);
  --accent-hover:     #991b1b;
  --focus-ring:       0 0 0 3px rgba(185,28,28,.25);

  --entity-name:      'RevsUp';
  --entity-primary:   #b91c1c;
  --entity-secondary: #991b1b;
  --entity-gradient:  linear-gradient(135deg, #fef5f5 0%, #fffbfb 50%, #fef5f5 100%);
  --entity-badge-bg:  #b91c1c;
  --entity-badge-text:#ffffff;
}

/* ============================================================
   4. RESET & BASE
   ============================================================ */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-secondary);
  line-height: var(--leading-base);
  font-size: var(--text-base);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   5. TYPOGRAPHY SYSTEM
   ============================================================ */

/* --- Headings --- */
h1, .h1 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.4px;
  line-height: var(--leading-tight);
}
h2, .h2 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  letter-spacing: -0.2px;
  line-height: var(--leading-tight);
}
h3, .h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
h4, .h4 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
h5, h6, .h5, .h6 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* --- Body text utilities --- */
.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-dim       { color: var(--text-dim) !important; }
.text-accent    { color: var(--accent) !important; }
.text-success   { color: var(--color-success) !important; }
.text-warning   { color: var(--color-warning) !important; }
.text-danger    { color: var(--color-danger) !important; }

.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-md   { font-size: var(--text-md); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }

.font-normal   { font-weight: var(--weight-normal); }
.font-medium   { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold     { font-weight: var(--weight-bold); }

/* --- Captions --- */
.caption {
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: 0.3px;
}
.label-overline {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* --- Monospace / data --- */
.mono, code, pre, .nc-data {
  font-family: var(--font-mono);
  font-size: 0.9em;
}
pre {
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
code {
  background: var(--bg-overlay);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  color: var(--accent);
}

/* --- Links --- */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* --- Lists --- */
ul, ol { padding-left: 22px; }
li     { margin: var(--space-1) 0; }

/* --- Horizontal rule --- */
hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-6) 0;
}

/* --- Paragraph spacing --- */
p + p { margin-top: var(--space-3); }

/* ============================================================
   6. LAYOUT — SHARED SHELL
   ============================================================ */

/* --- Header --- */
.page-header {
  background: var(--entity-gradient, linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-base) 50%, var(--bg-surface) 100%));
  border-bottom: 1px solid var(--border-base);
  padding: 28px var(--space-8) 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
}
.header-left h1 { font-size: 26px; }
.header-left .subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* --- Top navigation --- */
.top-nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-base);
  padding: 0 var(--space-8);
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.top-nav::-webkit-scrollbar { display: none; }
.top-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 12px 18px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}
.top-nav a:hover { color: var(--text-secondary); border-bottom-color: var(--border-base); }
.top-nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* --- Outer layout wrapper --- */
.page-layout {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  min-height: calc(100vh - 160px);
}

/* --- Sidebar --- */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-base);
  border-right: 1px solid var(--border-subtle);
  padding: var(--space-5) 0;
  position: sticky;
  top: 90px;
  align-self: flex-start;
  height: fit-content;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-base) transparent;
  z-index: 50;
}

/* Scroll-spy anchor offset for cards linked from sidebar */
.card[id] {
  scroll-margin-top: 100px;
}
.sidebar::-webkit-scrollbar       { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-base); border-radius: 2px; }
.sidebar-heading {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: var(--space-2) var(--space-5);
  margin-bottom: var(--space-1);
}
.sidebar-link {
  display: block;
  padding: 7px var(--space-5);
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  border-left: 2px solid transparent;
  transition: all var(--transition-fast);
}
.sidebar-link:hover { color: var(--text-secondary); background: var(--bg-surface); border-left-color: var(--border-base); }
.sidebar-link.active { color: var(--accent); border-left-color: var(--accent); background: var(--bg-surface); }

/* --- Main content area --- */
.main-content {
  flex: 1;
  padding: var(--space-6) var(--space-8);
  min-width: 0; /* prevent flex overflow */
}

/* --- Footer --- */
.page-footer {
  text-align: center;
  padding: var(--space-6) var(--space-8);
  color: var(--text-dim);
  font-size: var(--text-xs);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-5);
}
.page-footer strong { color: var(--text-muted); }

/* ============================================================
   7. COMPONENT LIBRARY
   ============================================================ */

/* --- nc-card --- */
.nc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  transition: border-color var(--transition-fast);
}
.nc-card:hover { border-color: var(--border-strong); }
.nc-card--accent { border-color: var(--accent-border); }
.nc-card--inset { background: var(--bg-inset); }
.nc-card--elevated {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}
.nc-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}
.nc-card__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
.nc-card__subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 2px;
}
.nc-card__body { /* inherits parent */ }
.nc-card__footer {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Highlight card (narrative / featured) */
.nc-card--highlight {
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-elevated));
  border-color: var(--accent-border);
}
.nc-card--highlight .nc-card__title { color: var(--accent); }

/* --- nc-table --- */
.nc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.nc-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-inset);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-base);
  white-space: nowrap;
}
.nc-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}
.nc-table tbody tr:hover td { background: var(--bg-elevated); }
.nc-table tbody tr:last-child td { border-bottom: none; }

/* Compact variant */
.nc-table--compact th,
.nc-table--compact td { padding: 6px 10px; }

/* Striped variant */
.nc-table--striped tbody tr:nth-child(even) td { background: var(--bg-elevated); }
.nc-table--striped tbody tr:nth-child(even):hover td { background: var(--bg-overlay); }

/* --- nc-badge --- */
.nc-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.3px;
  white-space: nowrap;
  line-height: 1.4;
}

/* Color variants */
.nc-badge--default  { background: var(--bg-overlay);          color: var(--text-secondary); }
.nc-badge--accent   { background: var(--accent-soft);          color: var(--accent); border: 1px solid var(--accent-border); }
.nc-badge--success  { background: var(--color-success-bg);     color: var(--color-success); }
.nc-badge--warning  { background: var(--color-warning-bg);     color: var(--color-warning); }
.nc-badge--danger   { background: var(--color-danger-bg);      color: var(--color-danger); }
.nc-badge--info     { background: var(--color-info-bg);        color: var(--color-info); }
.nc-badge--solid    { background: var(--accent);               color: var(--bg-base); }

/* Entity deal badges */
.deal-badge {
  display: inline-block;
  padding: 5px 16px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 1px;
  text-transform: uppercase;
  background: var(--entity-badge-bg, var(--accent));
  color: var(--entity-badge-text, var(--bg-base));
}

/* Legacy badge aliases for backward compatibility */
.badge           { display: inline-block; padding: 4px 12px; border-radius: 12px; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--text-primary); }
.badge.green     { background: var(--color-success); }
.badge.orange    { background: var(--color-warning); color: var(--bg-base); }
.badge.blue      { background: #2563eb; }
.badge.red       { background: var(--color-danger); }
.badge.gray      { background: var(--bg-overlay); }

/* --- nc-stat --- */
.nc-stat {
  text-align: center;
  padding: 18px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}
.nc-stat:hover { border-color: var(--border-base); }
.nc-stat__num {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.nc-stat__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}
.nc-stat__delta {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  margin-top: var(--space-1);
}
.nc-stat__delta--up   { color: var(--color-success); }
.nc-stat__delta--down { color: var(--color-danger); }

/* Legacy stat alias */
.stat                  { text-align: center; padding: 18px 12px; background: var(--bg-inset); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.stat .num             { font-size: 30px; font-weight: var(--weight-bold); color: var(--text-primary); line-height: 1.1; }
.stat .label           { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-1); }

/* --- nc-progress --- */
.nc-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.nc-progress__label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.nc-progress__track {
  height: 6px;
  background: var(--bg-overlay);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.nc-progress__fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}
.nc-progress--thin .nc-progress__track  { height: 3px; }
.nc-progress--thick .nc-progress__track { height: 10px; }
.nc-progress--success .nc-progress__fill { background: var(--color-success); }
.nc-progress--warning .nc-progress__fill { background: var(--color-warning); }
.nc-progress--danger  .nc-progress__fill { background: var(--color-danger); }

/* --- nc-timeline --- */
.nc-timeline {
  position: relative;
  padding-left: 28px;
}
.nc-timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border-base);
  border-radius: 1px;
}
.nc-timeline__item {
  position: relative;
  margin-bottom: var(--space-5);
}
.nc-timeline__item:last-child { margin-bottom: 0; }
.nc-timeline__dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-base);
  border: 2px solid var(--bg-base);
}
.nc-timeline__item--active   .nc-timeline__dot { background: var(--accent); }
.nc-timeline__item--success  .nc-timeline__dot { background: var(--color-success); }
.nc-timeline__item--warning  .nc-timeline__dot { background: var(--color-warning); }
.nc-timeline__item--danger   .nc-timeline__dot { background: var(--color-danger); }
.nc-timeline__date {
  font-size: var(--text-xs);
  color: var(--text-dim);
  margin-bottom: 2px;
  font-family: var(--font-mono);
}
.nc-timeline__content { font-size: var(--text-sm); color: var(--text-secondary); }
.nc-timeline__title   { font-weight: var(--weight-semibold); color: var(--text-primary); margin-bottom: 2px; }

/* --- Narrative / script boxes --- */
.narrative-box {
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent);
  padding: 18px 20px;
  border-radius: var(--radius-md);
  margin: 12px 0;
  line-height: var(--leading-loose);
  white-space: pre-wrap;
  font-size: var(--text-base);
}
.script-box {
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin: 10px 0;
  white-space: pre-wrap;
  font-size: var(--text-sm);
  line-height: var(--leading-base);
}
.script-label {
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
}

/* --- Highlight card (legacy alias, now nc-card--highlight) --- */
.highlight-card {
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-elevated));
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
}
.highlight-card h2 { color: var(--accent); border-bottom-color: var(--accent-soft); }

/* --- card (legacy alias) --- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}
.card h2 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}
.card p { margin-bottom: 10px; }

/* --- Buttons --- */
.nc-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-sans);
}
.nc-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.nc-btn--primary   { background: var(--accent);       color: var(--bg-base);     border-color: var(--accent); }
.nc-btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.nc-btn--secondary { background: var(--bg-surface);   color: var(--text-primary); border-color: var(--border-base); }
.nc-btn--secondary:hover { background: var(--bg-elevated); border-color: var(--border-strong); }
.nc-btn--ghost     { background: transparent;          color: var(--accent);       border-color: var(--accent-border); }
.nc-btn--ghost:hover { background: var(--accent-soft); }
.nc-btn--danger    { background: var(--color-danger);  color: var(--text-primary); border-color: var(--color-danger); }
.nc-btn--sm { padding: 4px 12px; font-size: var(--text-xs); }
.nc-btn--lg { padding: 12px 28px; font-size: var(--text-md); }

/* --- Forms --- */
.nc-input {
  background: var(--bg-inset);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: 8px 12px;
  width: 100%;
  transition: border-color var(--transition-fast);
}
.nc-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.nc-input::placeholder { color: var(--text-dim); }

.nc-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-1);
}
.nc-field { margin-bottom: var(--space-4); }

/* --- Dividers --- */
.nc-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-6) 0;
}
.nc-divider--strong { border-color: var(--border-base); }

/* ============================================================
   8. PAGE TYPE LAYOUTS
   ============================================================ */

/* --- .page-dossier (Buyer Dossier) --- */
.page-dossier .main-content {
  max-width: 960px;
}
.page-dossier .dossier-cover {
  background: var(--entity-gradient, var(--bg-surface));
  border: 1px solid var(--border-base);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  margin-bottom: var(--space-8);
  text-align: center;
}
.page-dossier .dossier-cover h1 {
  font-size: var(--text-3xl);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.page-dossier .dossier-cover .dossier-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-3);
}
.page-dossier .dossier-section { margin-bottom: var(--space-8); }
.page-dossier .dossier-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}
.page-dossier .dossier-field {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}
.page-dossier .dossier-field__key {
  font-size: var(--text-xs);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 2px;
}
.page-dossier .dossier-field__value {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}

/* --- .page-hub (Company Hub) --- */
.page-hub .hub-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.page-hub .hub-map-panel {
  height: 240px;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: var(--text-sm);
  overflow: hidden;
}

/* --- .page-proposal --- */
.page-proposal .proposal-header-card {
  background: var(--entity-gradient, var(--bg-surface));
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  margin-bottom: var(--space-6);
}
.page-proposal .proposal-header-card h1 { font-size: var(--text-2xl); color: var(--accent); }
.page-proposal .proposal-toc {
  position: sticky;
  top: 90px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--text-sm);
}
.page-proposal .proposal-toc a { display: block; padding: var(--space-1) 0; color: var(--text-muted); }
.page-proposal .proposal-toc a:hover { color: var(--accent); }
.page-proposal .fee-table {
  background: var(--bg-elevated);
  border: 2px solid var(--accent-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin: var(--space-6) 0;
  text-align: center;
}

/* --- .page-meeting --- */
.page-meeting .meeting-agenda {
  counter-reset: agenda;
}
.page-meeting .meeting-agenda-item {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.page-meeting .meeting-agenda-item::before {
  counter-increment: agenda;
  content: counter(agenda);
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-meeting .meeting-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-6);
}
.page-meeting .meeting-header-meta span::before { content: ''; }
.page-meeting .meeting-action-items .action-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}
.page-meeting .action-owner {
  flex-shrink: 0;
  width: 120px;
  font-weight: var(--weight-medium);
  color: var(--accent);
}

/* --- .page-dashboard --- */
.page-dashboard .dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-4);
}
.page-dashboard .dashboard-cell-3  { grid-column: span 3; }
.page-dashboard .dashboard-cell-4  { grid-column: span 4; }
.page-dashboard .dashboard-cell-6  { grid-column: span 6; }
.page-dashboard .dashboard-cell-8  { grid-column: span 8; }
.page-dashboard .dashboard-cell-12 { grid-column: span 12; }
.page-dashboard .kpi-row {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  overflow-x: auto;
}
.page-dashboard .kpi-row .nc-stat {
  flex: 1;
  min-width: 120px;
}

/* --- .page-activity (Activity Feed) --- */
.page-activity .activity-stream {
  max-width: 680px;
}
.page-activity .activity-item {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.page-activity .activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-overlay);
  border: 1px solid var(--border-base);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.page-activity .activity-body { font-size: var(--text-sm); }
.page-activity .activity-time {
  font-size: var(--text-xs);
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-top: var(--space-1);
}

/* --- .page-target (Target Profile) --- */
.page-target .target-scorecard {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}
.page-target .target-score-panel {
  background: var(--bg-surface);
  border: 2px solid var(--accent-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
}
.page-target .target-score-number {
  font-size: 64px;
  font-weight: var(--weight-bold);
  color: var(--accent);
  line-height: 1;
  font-family: var(--font-mono);
}
.page-target .target-score-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-2);
}
.page-target .target-fit-bars {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* ============================================================
   9. UTILITY GRID CLASSES
   ============================================================ */

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-4); }
.grid4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: var(--space-4); }

.flex        { display: flex; }
.flex-wrap   { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* ============================================================
   10. VIEW MODE — AUDIENCE VISIBILITY
   ============================================================ */

/*
 * Tagging convention:
 *   class="internal-only"  — visible only to internal users
 *   class="client-only"    — visible to internal + client, hidden from buyers
 *
 * View modes:
 *   .view-internal  — sees everything
 *   .view-client    — hides .internal-only
 *   .view-buyer     — hides .internal-only AND .client-only
 */

/* Internal view: show everything */
.view-internal .internal-only,
.view-internal .client-only {
  display: revert;
}

/* Client view: strip internal-only data */
.view-client .internal-only {
  display: none !important;
}

/* Buyer view: strip internal + client data */
.view-buyer .internal-only,
.view-buyer .client-only {
  display: none !important;
}

/* Visual flag in internal mode so editors know what's hidden externally */
.view-internal .internal-only {
  outline: 1px dashed rgba(248,81,73,.35);
  outline-offset: 2px;
}
.view-internal .client-only {
  outline: 1px dashed rgba(210,153,34,.25);
  outline-offset: 2px;
}

/* View mode indicator bar */
.view-mode-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 6px var(--space-8);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.5px;
}
.view-internal .view-mode-bar { background: rgba(248,81,73,.08); color: var(--color-danger); border-bottom: 1px solid rgba(248,81,73,.2); }
.view-client   .view-mode-bar { background: rgba(210,153,34,.08); color: var(--color-warning); border-bottom: 1px solid rgba(210,153,34,.2); }
.view-buyer    .view-mode-bar { background: rgba(63,185,80,.08);  color: var(--color-success); border-bottom: 1px solid rgba(63,185,80,.2); }

/* ============================================================
   11. RESPONSIVE BREAKPOINTS
   ============================================================ */

/* --- Tablet (768–1024px) --- */
@media (max-width: 1024px) {
  .page-layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-3) 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
  }
  .sidebar-heading { width: 100%; }
  .sidebar-link { padding: 6px var(--space-4); }
  .main-content { padding: var(--space-5) var(--space-5); }
  .grid4 { grid-template-columns: 1fr 1fr; }
  .page-dashboard .dashboard-grid { grid-template-columns: repeat(6, 1fr); }
  .page-dashboard .dashboard-cell-3  { grid-column: span 3; }
  .page-dashboard .dashboard-cell-4  { grid-column: span 6; }
  .page-dashboard .dashboard-cell-8  { grid-column: span 6; }
  .page-target .target-scorecard { grid-template-columns: 1fr; }
}

/* --- Mobile (<768px) --- */
@media (max-width: 767px) {
  .page-header { padding: var(--space-4); }
  .header-inner { flex-direction: column; gap: var(--space-3); }
  .top-nav { padding: 0 var(--space-3); }
  .sidebar { display: none; }
  .page-layout { display: block; }
  .main-content { padding: var(--space-4); }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .page-dashboard .dashboard-grid { grid-template-columns: 1fr; }
  .page-dashboard .dashboard-cell-3,
  .page-dashboard .dashboard-cell-4,
  .page-dashboard .dashboard-cell-6,
  .page-dashboard .dashboard-cell-8,
  .page-dashboard .dashboard-cell-12 { grid-column: span 1; }
  .page-hub .hub-kpi-strip { grid-template-columns: 1fr 1fr; }
  .nc-stat__num { font-size: var(--text-2xl); }
  .page-dossier .dossier-cover { padding: var(--space-5); }
  .page-dossier .dossier-cover h1 { font-size: var(--text-2xl); }
  .page-target .target-score-number { font-size: 48px; }
  .view-mode-bar { padding: 6px var(--space-4); }
  .kpi-row { flex-wrap: wrap; }
}

/* --- Wide desktop (>1400px) --- */
@media (min-width: 1400px) {
  .page-layout, .header-inner { max-width: 1600px; }
}

/* ============================================================
   12. PRINT STYLESHEET
   ============================================================ */

@media print {
  /* Reset body for white paper */
  body {
    background: white !important;
    color: #1a1a2e !important;
    font-size: 12pt;
    line-height: 1.5;
  }

  /* Hide chrome */
  .page-header   { background: white !important; border-bottom: 2px solid #1a1a2e; position: static !important; }
  .top-nav       { display: none !important; }
  .sidebar       { display: none !important; }
  .view-mode-bar { display: none !important; }
  .page-footer   { color: #888; }

  /* Internal markers off */
  .view-internal .internal-only,
  .view-internal .client-only { outline: none; }

  /* Layout flatten */
  .page-layout  { display: block !important; }
  .main-content { padding: 0 !important; max-width: 100% !important; }
  .header-inner { flex-direction: column; }
  .header-left h1    { color: #1a1a2e; font-size: 20pt; }
  .header-left .subtitle { color: #555; }

  /* Cards / surfaces */
  .card, .nc-card, .highlight-card {
    background: white !important;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .card h2, .nc-card__title { color: #1a1a2e !important; border-bottom-color: #ddd !important; }

  /* Tables */
  .nc-table th { background: #f0f2f5 !important; color: #555 !important; }
  .nc-table td { color: #1a1a2e !important; border-color: #ddd !important; }
  .nc-table tbody tr:hover td { background: transparent !important; }

  /* Stats */
  .nc-stat, .stat { background: #f8f9fa !important; border-color: #ddd !important; }
  .nc-stat__num, .stat .num { color: #1a1a2e !important; }

  /* Narrative */
  .narrative-box { background: #f8f9fa !important; border-color: #ddd !important; border-left-color: #3498db !important; }
  .script-box    { background: #f8f9fa !important; border-color: #ddd !important; }
  .highlight-card { background: #f8f9fa !important; border-color: #3498db !important; }

  /* Links */
  a { color: #1a5276 !important; }

  /* Preserve badge colors for print */
  .deal-badge, .nc-badge, .badge {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  /* Page breaks */
  .dossier-section,
  .proposal-section,
  .nc-card { page-break-inside: avoid; break-inside: avoid; }
  .page-break-before { page-break-before: always; break-before: always; }
  .page-break-after  { page-break-after: always; break-after: always; }
  h1, h2 { page-break-after: avoid; break-after: avoid; }
}
