/* Global Design System & Theme Variables */
:root {
  /* Dark Theme (Default) */
  --bg-primary: #0b0f19;
  --bg-secondary: #131a2c;
  --bg-tertiary: #1b253f;
  --border-color: #27365c;
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --color-primary: #6366f1; /* Indigo */
  --color-primary-hover: #4f46e5;
  --color-accent: #10b981; /* Emerald */
  --color-warning: #f59e0b; /* Amber */
  --color-error: #f43f5e; /* Rose */
  
  --color-bg-acct: rgba(99, 102, 241, 0.1);
  --color-bg-pm: rgba(16, 185, 129, 0.1);
  --color-bg-calc: rgba(245, 158, 11, 0.08);
  
  --border-acct: #6366f1;
  --border-pm: #10b981;
  --border-calc: #f59e0b;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.3), 0 2px 10px -3px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
  
  --glass-bg: rgba(19, 26, 44, 0.7);
  --glass-border: rgba(39, 54, 92, 0.4);
  --glass-blur: blur(12px);
  
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
.light-theme {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --border-color: #e2e8f0;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --color-primary: #4f46e5;
  --color-primary-hover: #3730a3;
  --color-bg-acct: rgba(79, 70, 229, 0.05);
  --color-bg-pm: rgba(16, 185, 129, 0.05);
  --color-bg-calc: rgba(245, 158, 11, 0.05);
  
  --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.08), 0 2px 10px -3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.05);
  
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(226, 232, 240, 0.8);
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

body.light-theme {
  background-color: var(--bg-primary);
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

/* Global Utility Classes */
.hidden {
  display: none !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Header & Navigation */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--color-accent);
}

.logo-text h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.logo-text h1 span {
  color: var(--color-primary);
}

.logo-text p {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 600;
}

.nav-tabs {
  display: flex;
  gap: 0.25rem;
  background-color: var(--bg-tertiary);
  padding: 0.25rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.03);
}

.nav-btn.active {
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--glass-border);
}

.header-actions {
  display: flex;
  align-items: center;
}

.theme-toggle-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
  background-color: var(--bg-secondary);
}

.sun-icon {
  display: none;
  width: 18px;
  height: 18px;
}

.moon-icon {
  display: block;
  width: 18px;
  height: 18px;
}

.light-theme .sun-icon {
  display: block;
}

.light-theme .moon-icon {
  display: none;
}

/* Container & Layout */
.app-container {
  max-width: 1440px;
  margin: 2rem auto;
  padding: 0 2rem;
  min-height: calc(100vh - 200px);
}

/* Hero Section */
.hero-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4rem;
  margin-bottom: 2.5rem;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
  border: 1px solid var(--border-color);
  border-radius: 1.25rem;
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.hero-section::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, rgba(0,0,0,0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-content {
  flex: 1;
  max-width: 700px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background-color: var(--color-bg-acct);
  color: var(--color-primary);
  border: 1px solid var(--glass-border);
  margin-bottom: 0.75rem;
}

.badge-accent {
  background-color: var(--color-bg-pm);
  color: var(--color-accent);
}

.hero-content h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

.hero-content p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.6;
}

.hero-card {
  display: flex;
  gap: 1.5rem;
}

.card-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1.25rem 1.75rem;
  min-width: 180px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  transition: transform var(--transition-fast);
}

.card-item:hover {
  transform: translateY(-2px);
}

.card-num {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-error);
  margin-bottom: 0.25rem;
}

.card-num.warning {
  color: var(--color-warning);
}

.card-num.success {
  color: var(--color-accent);
}

.card-lbl {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

/* Tab Panels */
.tab-pane {
  display: none;
  animation: fadeIn var(--transition-normal);
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.pane-header h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
}

.pane-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* WIP Legend */
.table-legend {
  display: flex;
  gap: 1.25rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-color.accounting {
  background-color: var(--color-bg-acct);
  border: 1px solid var(--border-acct);
}

.legend-color.pm {
  background-color: var(--color-bg-pm);
  border: 1px solid var(--border-pm);
}

.legend-color.calc {
  background-color: var(--color-bg-calc);
  border: 1px solid var(--border-calc);
}

/* Interactive Table Stylings */
.table-wrapper {
  overflow-x: auto;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
}

.wip-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.7rem;
  table-layout: fixed;
}

.wip-table th, .wip-table td {
  padding: 0.7rem 0.3rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 16-column allocation sized for actual content — PM/dates narrow,
   currency + project name wider. Sums to ~100%. */
.wip-table th:nth-child(1),  .wip-table td:nth-child(1)  { width: 2.5%; }   /* PM */
.wip-table th:nth-child(2),  .wip-table td:nth-child(2)  { width: 12%;  }   /* Customer / Project */
.wip-table th:nth-child(3),  .wip-table td:nth-child(3)  { width: 4.5%; }   /* Sage Job# */
.wip-table th:nth-child(4),  .wip-table td:nth-child(4)  { width: 7.5%; }   /* Contract Price */
.wip-table th:nth-child(5),  .wip-table td:nth-child(5)  { width: 6.5%; }   /* Estimated Costs */
.wip-table th:nth-child(6),  .wip-table td:nth-child(6)  { width: 6.5%; }   /* Total Billed */
.wip-table th:nth-child(7),  .wip-table td:nth-child(7)  { width: 6.5%; }   /* Total Cost to Date */
.wip-table th:nth-child(8),  .wip-table td:nth-child(8)  { width: 5%;   }   /* Utilization % */
.wip-table th:nth-child(9),  .wip-table td:nth-child(9)  { width: 6.5%; }   /* Costs to Complete */
.wip-table th:nth-child(10), .wip-table td:nth-child(10) { width: 6.5%; }   /* Revised Cost Estimate */
.wip-table th:nth-child(11), .wip-table td:nth-child(11) { width: 4.5%; }   /* GM % */
.wip-table th:nth-child(12), .wip-table td:nth-child(12) { width: 5%;   }   /* Start Date */
.wip-table th:nth-child(13), .wip-table td:nth-child(13) { width: 5%;   }   /* Completion Date */
.wip-table th:nth-child(14), .wip-table td:nth-child(14) { width: 6.5%; }   /* Left to Bill */
.wip-table th:nth-child(15), .wip-table td:nth-child(15) { width: 6.5%; }   /* Outstanding CORs */
.wip-table th:nth-child(16), .wip-table td:nth-child(16) { width: 8.5%; }   /* Approved CORs */

/* At narrower viewports shrink padding and font further so the same 16
   columns still fit without truncating currency values. */
@media (max-width: 1300px) {
  .wip-table { font-size: 0.62rem; }
  .wip-table th { font-size: 0.58rem; }
  .wip-table th small { font-size: 0.54rem; }
  .wip-table th, .wip-table td { padding: 0.55rem 0.2rem; }
}

@media (max-width: 1100px) {
  .wip-table { font-size: 0.56rem; }
  .wip-table th { font-size: 0.52rem; }
  .wip-table th small { font-size: 0.48rem; }
  .wip-table th, .wip-table td { padding: 0.45rem 0.15rem; }
}

.wip-table th {
  font-family: var(--font-sans);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--text-secondary);
  background-color: var(--bg-tertiary);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
  white-space: normal;
  word-break: break-word;
  font-size: 0.65rem;
  vertical-align: top;
  line-height: 1.2;
}

.wip-table th small {
  font-size: 0.6rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}

.wip-table th:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.02);
}

.wip-table tbody tr {
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.wip-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.01);
}

/* Owners styling */
.owner-acct {
  border-top: 3px solid var(--border-acct) !important;
}

.owner-pm {
  border-top: 3px solid var(--border-pm) !important;
}

.owner-contract {
  border-top: 3px solid #818cf8 !important; /* Lighter Indigo */
}

.owner-calc {
  border-top: 3px solid var(--border-calc) !important;
}

/* Highlights */
.highlight-pm {
  background-color: rgba(16, 185, 129, 0.08) !important;
}

.highlight-cell {
  background-color: rgba(16, 185, 129, 0.08) !important;
  color: var(--color-accent) !important;
  font-weight: 700 !important;
}

.font-mono {
  font-family: 'SFMono-Regular', Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-weight: 500;
}

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

.loss-text {
  color: var(--color-error) !important;
  font-weight: 700;
}

.green-text {
  color: var(--color-accent) !important;
  font-weight: 700;
}

.total-row {
  font-weight: 700;
  background-color: var(--bg-tertiary);
}

.total-row td {
  border-bottom: none;
}

.project-cell {
  font-weight: 600;
  color: var(--text-primary);
}

/* Inspector Panel */
.inspector-card {
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  max-width: 100%;
  position: relative;
  transition: transform var(--transition-normal);
  animation: slideUp var(--transition-normal);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.inspector-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.inspector-header h4 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.inspector-owner {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background-color: var(--color-bg-pm);
  color: var(--color-accent);
  border: 1px solid var(--border-pm);
}

.inspector-owner.accounting {
  background-color: var(--color-bg-acct);
  color: var(--color-primary);
  border-color: var(--border-acct);
}

.inspector-owner.calculated {
  background-color: var(--color-bg-calc);
  color: var(--color-warning);
  border-color: var(--border-calc);
}

.inspector-owner.contract {
  background-color: rgba(129, 140, 248, 0.08);
  color: #818cf8;
  border-color: #818cf8;
}

.inspector-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.inspector-body h5 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.inspector-body p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.inspector-body code {
  background-color: var(--bg-primary);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--color-warning);
  border: 1px solid var(--border-color);
  display: inline-block;
  margin-top: 0.25rem;
}

/* Highlighted Column/Cell states during hovering */
.wip-table th.active-inspect-hdr {
  background-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

.wip-table td.active-inspect-cell {
  background-color: rgba(255, 255, 255, 0.03);
}

/* STORY MODE TAB */
.story-grid {
  display: grid;
  grid-template-columns: 450px 1fr;
  gap: 2rem;
  align-items: start;
}

.story-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.story-step-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.step-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  background-color: var(--color-bg-acct);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}

.step-dots {
  display: flex;
  gap: 0.35rem;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--border-color);
  transition: all var(--transition-fast);
}

.step-dot.active {
  background-color: var(--color-primary);
  transform: scale(1.2);
}

.step-dot.completed {
  background-color: var(--color-accent);
}

.story-panel h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
}

.character-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
}

.character-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-fast);
}

.character-meta h4 {
  font-size: 0.85rem;
  font-weight: 700;
}

.character-meta span {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.speech-bubble {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 0 1rem 1rem 1rem;
  padding: 1.25rem;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
  position: relative;
  animation: popIn var(--transition-normal);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.speech-bubble strong {
  color: var(--text-primary);
}

.story-interaction-box {
  background-color: rgba(99, 102, 241, 0.05);
  border: 1px dashed var(--color-primary);
  padding: 1.25rem;
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: fadeIn var(--transition-normal);
}

.story-interaction-box.hidden {
  display: none !important;
}

.story-interaction-box label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-symbol {
  position: absolute;
  left: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.input-wrapper input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  transition: all var(--transition-fast);
}

.input-wrapper input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.input-feedback-msg {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

.input-feedback-msg.error {
  color: var(--color-error);
}

.input-feedback-msg.success {
  color: var(--color-accent);
}

.story-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.65rem 1.25rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  background-color: var(--color-primary);
  border: 1px solid var(--color-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-secondary:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-large {
  font-size: 0.95rem;
  padding: 0.85rem 1.75rem;
  border-radius: 0.75rem;
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
}

.story-visual-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.story-wip-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.card-header h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
}

.live-indicator {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background-color: rgba(244, 63, 94, 0.1);
  color: var(--color-error);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  animation: blink 1.5s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.story-wip-table-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
}

.story-wip-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.story-wip-table th, .story-wip-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.story-wip-table th {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
}

.story-wip-table td {
  color: var(--text-primary);
}

.highlight-wip-cell {
  background-color: rgba(99, 102, 241, 0.15) !important;
  color: var(--color-primary) !important;
  font-weight: 700;
  position: relative;
  animation: pulseHighlight 2s infinite;
}

@keyframes pulseHighlight {
  0%, 100% { box-shadow: inset 0 0 0 1px var(--color-primary); }
  50% { box-shadow: inset 0 0 0 1px transparent; }
}

.story-extra-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  flex: 1;
}

.story-extra-card h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.story-canvas-area {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1rem;
}

/* SANDBOX CALCULATOR TAB */
.sandbox-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 2rem;
  align-items: start;
}

.sandbox-form-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.card-header-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.card-header-with-action h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}

.section-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.sandbox-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-section {
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
}

.form-section h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-group label small {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 400;
}

.highlight-input {
  background-color: rgba(16, 185, 129, 0.03);
  border: 1px dashed rgba(16, 185, 129, 0.3);
  padding: 1rem;
  border-radius: 0.75rem;
}

.highlight-input label {
  color: var(--color-accent);
  font-weight: 700;
}

.forecast-input {
  border-color: rgba(16, 185, 129, 0.4) !important;
}

.forecast-input:focus {
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2) !important;
}

.input-tip {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 500;
}

.sandbox-dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.kpi-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 500;
}

.charts-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.charts-card h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.charts-flex {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.chart-box {
  flex: 1;
  min-width: 250px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.25rem;
  text-align: center;
}

.chart-box h5 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-weight: 700;
}

/* SVG Chart Specific styling */
.gauge-container, .scale-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.gauge-svg {
  width: 100%;
  max-width: 180px;
  height: auto;
}

.gauge-track {
  stroke: var(--border-color);
}

.gauge-section {
  opacity: 0.2;
}

.gauge-section.loss {
  stroke: var(--color-error);
}

.gauge-section.tight {
  stroke: var(--color-warning);
}

.gauge-section.profitable {
  stroke: var(--color-accent);
}

#gauge-needle {
  transition: transform 0.8s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.gauge-label, .scale-label {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-value, .scale-value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
}

.gauge-sub, .scale-sub {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.025em;
}

.scale-svg {
  width: 100%;
  max-width: 180px;
  height: auto;
}

#scale-beam {
  transition: transform 0.8s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  transform-origin: 100px 65px;
}

/* Verdict box */
.sandbox-advice {
  margin-top: 1.5rem;
  background-color: rgba(245, 158, 11, 0.05);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 0.75rem;
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: start;
}

.sandbox-advice.loss-alert {
  background-color: rgba(244, 63, 94, 0.04);
  border-color: rgba(244, 63, 94, 0.2);
  color: var(--text-primary);
}

.sandbox-advice.success-alert {
  background-color: rgba(16, 185, 129, 0.04);
  border-color: rgba(16, 185, 129, 0.2);
}

.advice-icon-wrap {
  flex-shrink: 0;
  color: var(--color-warning);
}

.sandbox-advice.loss-alert .advice-icon-wrap {
  color: var(--color-error);
}

.sandbox-advice.success-alert .advice-icon-wrap {
  color: var(--color-accent);
}

.advice-content h5 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

.advice-content p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.advice-content p strong {
  color: var(--text-primary);
}

/* QUIZ TAB */
.quiz-container {
  max-width: 650px;
  margin: 0 auto;
}

.quiz-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 1.25rem;
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: fadeIn var(--transition-normal);
}

.quiz-card.hidden {
  display: none !important;
}

.quiz-badge-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.gold-badge-svg {
  color: var(--color-warning);
}

.quiz-card h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.quiz-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.quiz-progress-bar-container {
  text-align: left;
  margin-bottom: 1.5rem;
}

.quiz-progress-lbl {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: 0.4rem;
}

.quiz-progress-track {
  height: 6px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background-color: var(--color-primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.quiz-question-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: left;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.quiz-opt-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem 1.25rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quiz-opt-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--text-primary);
  background-color: rgba(99, 102, 241, 0.02);
}

.quiz-opt-btn:disabled {
  cursor: not-allowed;
}

.quiz-opt-btn.selected {
  border-color: var(--color-primary);
  color: var(--text-primary);
  background-color: var(--color-bg-acct);
}

.quiz-opt-btn.correct {
  border-color: var(--color-accent) !important;
  color: #fff !important;
  background-color: rgba(16, 185, 129, 0.8) !important;
}

.quiz-opt-btn.incorrect {
  border-color: var(--color-error) !important;
  color: #fff !important;
  background-color: rgba(244, 63, 94, 0.8) !important;
}

.quiz-opt-num {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.quiz-opt-btn.selected .quiz-opt-num {
  background-color: var(--color-primary);
  color: white;
}

.quiz-explanation-box {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.25rem;
  text-align: left;
  margin-bottom: 1.5rem;
  animation: slideUp var(--transition-fast);
}

.quiz-explanation-box.hidden {
  display: none !important;
}

.feedback-hdr {
  margin-bottom: 0.4rem;
}

.feedback-hdr span {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.incorrect-text {
  color: var(--color-error);
}

.correct-text {
  color: var(--color-accent);
}

#quiz-feedback-explanation {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 0;
}

.quiz-actions {
  display: flex;
  justify-content: flex-end;
}

/* Certificate Layout */
.certificate-frame {
  background-color: #fff;
  color: #1e293b;
  border: 12px double #cbd5e1;
  border-radius: 0.5rem;
  padding: 2.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 0 40px rgba(0,0,0,0.15);
  position: relative;
  overflow: hidden;
}

.certificate-frame::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 2px solid #94a3b8;
  margin: 6px;
  pointer-events: none;
}

.certificate-inner {
  text-align: center;
  border: 1px solid #e2e8f0;
  padding: 2.5rem 1.5rem;
  background-image: radial-gradient(rgba(241,245,249,0.5) 1px, transparent 0);
  background-size: 12px 12px;
}

.cert-gold-star {
  margin-bottom: 1rem;
  filter: drop-shadow(0 2px 4px rgba(245,158,11,0.3));
}

.certificate-inner h2 {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #1e1b4b;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.certificate-inner p {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
}

.certificate-inner p.cert-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  text-transform: none;
  letter-spacing: 0;
  margin-top: 1.5rem;
  margin-bottom: 0;
}

.cert-body {
  max-width: 480px;
  margin: 0 auto;
}

.cert-body p {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.6;
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 1rem;
}

.cert-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: #4338ca;
  letter-spacing: 0.025em;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.5rem;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.cert-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 2.5rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.signature-block {
  text-align: center;
  width: 180px;
}

.sig-line {
  border-bottom: 1.5px solid #94a3b8;
  padding-bottom: 0.25rem;
  font-size: 0.9rem;
  color: #334155;
  margin-bottom: 0.4rem;
}

.font-script {
  font-family: 'Georgia', cursive, serif;
  font-style: italic;
  font-weight: 500;
}

.sig-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-summary-text {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1.5rem !important;
}

.result-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.btn-group {
  display: flex;
  gap: 0.75rem;
}

/* Footer styling */
.app-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--border-color);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

/* Keyframe Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Screen Print Styles */
@media print {
  body {
    background-color: #fff !important;
    color: #000 !important;
  }
  .app-header, .hero-section, .pane-header, .table-wrapper, .inspector-card, .no-print, .app-footer, .nav-tabs {
    display: none !important;
  }
  .app-container {
    padding: 0 !important;
    margin: 0 !important;
  }
  .quiz-container {
    max-width: 100% !important;
  }
  /* Certificate print: keep cert centered and readable regardless of orientation */
  .certificate-frame {
    box-shadow: none !important;
    border-color: #000 !important;
    page-break-inside: avoid;
    max-width: 900px !important;
    width: 90% !important;
    margin: 0 auto !important;
  }
}

/* Saved Reports panel — shown at the top of the WIP Wizard tab. */
.saved-reports-panel {
  max-width: 1320px;
  margin: 0 auto 2rem auto;
  padding: 1.5rem 1.75rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  box-shadow: var(--shadow-sm);
}

.saved-reports-panel.hidden {
  display: none !important;
}

.saved-reports-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.saved-reports-header h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.saved-reports-header .section-desc {
  margin-bottom: 0;
}

.saved-reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
}

.saved-report-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 1.1rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  transition: border-color var(--transition-fast);
}

.saved-report-card:hover {
  border-color: var(--color-primary);
}

.saved-report-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.saved-report-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.saved-report-meta strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.saved-report-stats {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border-color);
}

.saved-report-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.saved-report-actions .btn {
  flex: 1;
  padding: 0.45rem 0.65rem;
  font-size: 0.72rem;
}

.saved-report-actions .btn-danger {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.saved-report-actions .btn-danger:hover {
  background-color: rgba(244, 63, 94, 0.08);
  border-color: var(--color-error);
  color: var(--color-error);
}

/* WIP Wizard Specifics */
.wizard-input-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Pill on the step indicator showing how many projects are already saved */
.wizard-projects-saved-pill:not(:empty) {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  font-size: 0.6rem;
  font-weight: 700;
  background-color: var(--color-bg-pm);
  color: var(--color-accent);
  border: 1px solid var(--border-pm);
  letter-spacing: 0.02em;
}

/* Between-projects summary list */
.wizard-projects-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.25rem 0;
  text-align: left;
  max-height: 280px;
  overflow-y: auto;
}

.wizard-project-chip {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.wizard-project-chip:hover {
  border-color: var(--color-primary);
  background-color: var(--color-bg-acct);
}

.wizard-project-chip[data-editing="true"] {
  border-color: var(--color-accent);
  background-color: var(--color-bg-pm);
}

.wizard-project-chip-edit-hint {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.1rem;
}

.wizard-project-chip-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--color-primary);
  color: white;
  font-weight: 700;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wizard-project-chip-name {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wizard-project-chip-name small {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.wizard-project-chip-amount {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.wizard-project-chip-remove {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  padding: 0;
}

.wizard-project-chip-remove:hover {
  color: var(--color-error);
  border-color: var(--color-error);
  background-color: rgba(244, 63, 94, 0.08);
}

.wizard-input-box label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.wizard-input-box input {
  max-width: 400px;
  width: 100%;
}

.wizard-input-box .input-tip {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 400px;
  text-align: center;
}

/* Printable WIP Sheet Layout */
.print-report-container {
  animation: fadeIn var(--transition-normal);
}

/* On screen the wizard report preview renders as a landscape "page" so
   every one of the 15 columns is visible without horizontal scroll.
   Lives outside .quiz-container in the HTML so it can use the full app
   width up to the landscape paper aspect ratio. */
#wizard-report-preview {
  max-width: 1320px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

#wizard-report-preview .report-sheet-card {
  padding: 1.75rem 1.5rem;
}

#wizard-report-preview .report-sheet-table-wrap {
  overflow: visible;
}

#wizard-report-preview .report-sheet-table {
  table-layout: fixed;
  font-size: 0.72rem;
}

#wizard-report-preview .report-sheet-table th,
#wizard-report-preview .report-sheet-table td {
  padding: 0.55rem 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.72rem;
}

#wizard-report-preview .report-sheet-table th {
  font-size: 0.62rem;
  white-space: normal;
  word-break: break-word;
  letter-spacing: 0;
  vertical-align: top;
  line-height: 1.2;
}

#wizard-report-preview .report-sheet-table th small {
  font-size: 0.55rem;
}

/* Tighten PM column padding and shrink the "TOTAL" label so the narrow
   PM column doesn't truncate. Same allocation as the printed page. */
#wizard-report-preview .report-sheet-table th:nth-child(1),
#wizard-report-preview .report-sheet-table td:nth-child(1) {
  padding-left: 0.15rem;
  padding-right: 0.15rem;
}
#wizard-report-preview .report-sheet-table .total-row td:first-child {
  font-size: 0.6rem;
}

/* Screen-preview column allocation — slightly wider than print for the
   narrow columns since real data has 3-char PMs and 6-digit Job#s. */
#wizard-report-preview .report-sheet-table th:nth-child(1),
#wizard-report-preview .report-sheet-table td:nth-child(1)  { width: 3.2%; }   /* PM */
#wizard-report-preview .report-sheet-table th:nth-child(2),
#wizard-report-preview .report-sheet-table td:nth-child(2)  { width: 12%;  }   /* Customer/Project */
#wizard-report-preview .report-sheet-table th:nth-child(3),
#wizard-report-preview .report-sheet-table td:nth-child(3)  { width: 5%;   }   /* Sage Job# */
#wizard-report-preview .report-sheet-table th:nth-child(4),
#wizard-report-preview .report-sheet-table td:nth-child(4)  { width: 8.5%; }   /* Contract Price */
#wizard-report-preview .report-sheet-table th:nth-child(5),
#wizard-report-preview .report-sheet-table td:nth-child(5)  { width: 7%;   }   /* Estimated Costs */
#wizard-report-preview .report-sheet-table th:nth-child(6),
#wizard-report-preview .report-sheet-table td:nth-child(6)  { width: 7%;   }   /* Total Billed */
#wizard-report-preview .report-sheet-table th:nth-child(7),
#wizard-report-preview .report-sheet-table td:nth-child(7)  { width: 7%;   }   /* Total Cost to Date */
#wizard-report-preview .report-sheet-table th:nth-child(8),
#wizard-report-preview .report-sheet-table td:nth-child(8)  { width: 4.3%; }   /* Utilization */
#wizard-report-preview .report-sheet-table th:nth-child(9),
#wizard-report-preview .report-sheet-table td:nth-child(9)  { width: 7%;   }   /* Costs to Complete */
#wizard-report-preview .report-sheet-table th:nth-child(10),
#wizard-report-preview .report-sheet-table td:nth-child(10) { width: 7%;   }   /* Revised Cost Estimate */
#wizard-report-preview .report-sheet-table th:nth-child(11),
#wizard-report-preview .report-sheet-table td:nth-child(11) { width: 4.3%; }   /* GM % */
#wizard-report-preview .report-sheet-table th:nth-child(12),
#wizard-report-preview .report-sheet-table td:nth-child(12) { width: 5.5%; }   /* Start Date */
#wizard-report-preview .report-sheet-table th:nth-child(13),
#wizard-report-preview .report-sheet-table td:nth-child(13) { width: 5.5%; }   /* Completion Date */
#wizard-report-preview .report-sheet-table th:nth-child(14),
#wizard-report-preview .report-sheet-table td:nth-child(14) { width: 8%;   }   /* Left to Bill */
#wizard-report-preview .report-sheet-table th:nth-child(15),
#wizard-report-preview .report-sheet-table td:nth-child(15) { width: 8.7%; }   /* Approved CORs */

.report-sheet-card {
  background-color: white;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  max-width: 100%;
  margin: 0 auto;
  text-align: left;
}

.report-sheet-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
}

.company-brand h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.025em;
  color: #0f172a;
  margin: 0;
}

.company-brand .report-date {
  font-size: 0.85rem;
  color: #475569;
  font-weight: 600;
  margin-top: 0.15rem;
}

.job-meta-lines {
  text-align: right;
  font-size: 0.8rem;
  color: #475569;
  font-weight: 500;
  line-height: 1.4;
}

.report-sheet-table-wrap {
  overflow-x: auto;
  margin-bottom: 1.75rem;
}

.report-sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.report-sheet-table th, .report-sheet-table td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid #e2e8f0;
  color: #0f172a !important;
  white-space: nowrap;
}

.report-sheet-table th {
  background-color: #f8fafc;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  border-top: 1px solid #cbd5e1;
  border-bottom: 2px solid #94a3b8;
}

.report-sheet-table td {
  font-weight: 500;
}

.report-sheet-table .total-row {
  font-weight: 700;
  background-color: #f1f5f9;
}

.report-sheet-table .total-row td {
  border-top: 2px solid #0f172a !important;
  border-bottom: 2.5px double #0f172a !important;
}

.report-reconciliation-area {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2.5rem;
  margin-top: 2rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 1.5rem;
}

.recon-col h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.recon-table {
  width: 100%;
  font-size: 0.8rem;
}

.recon-table td {
  padding: 0.4rem 0;
  color: #475569;
  font-weight: 500;
}

.recon-table td:last-child {
  color: #0f172a;
  font-weight: 700;
}

.sheet-sig-lines {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1rem;
}

.sheet-sig-item {
  display: flex;
  flex-direction: column;
}

.sheet-line {
  border-bottom: 1px solid #94a3b8;
  height: 24px;
  width: 100%;
  margin-bottom: 0.25rem;
}

.sheet-sig-item span {
  font-size: 0.65rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
}

.report-footer-note {
  margin-top: 2rem;
  background-color: rgba(99, 102, 241, 0.04);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 0.5rem;
  padding: 1rem;
}

.report-footer-note p {
  font-size: 0.75rem;
  color: #4f46e5;
  margin-bottom: 0 !important;
}

/* Print Overrides — WIP Wizard Report (only when body.printing-wip is set) */
@media print {
  /* Page orientation: landscape applies broadly; cert print is centered/contained so it still looks fine. */
  @page {
    size: landscape;
    margin: 0.4in 0.3in;
  }

  body.printing-wip {
    background-color: white !important;
    color: black !important;
    background-image: none !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body.printing-wip .app-header,
  body.printing-wip .hero-section,
  body.printing-wip .pane-header,
  body.printing-wip .table-wrapper,
  body.printing-wip .inspector-card,
  body.printing-wip .nav-tabs,
  body.printing-wip .app-footer,
  body.printing-wip #interactive-wip,
  body.printing-wip #story-mode,
  body.printing-wip #sandbox,
  body.printing-wip #quiz,
  body.printing-wip #wizard-step-card,
  body.printing-wip .no-print {
    display: none !important;
  }

  body.printing-wip .app-container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  body.printing-wip #wip-wizard {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }

  body.printing-wip .quiz-container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.printing-wip .print-report-container {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: white !important;
    color: black !important;
  }

  body.printing-wip .report-sheet-card {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    background: white !important;
    color: black !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  body.printing-wip .report-sheet-header {
    margin-bottom: 0.75rem !important;
    padding-bottom: 0.5rem !important;
  }

  body.printing-wip .company-brand h2 {
    font-size: 1.4rem !important;
  }

  body.printing-wip .report-sheet-table-wrap {
    overflow: visible !important;
    margin-bottom: 1rem !important;
  }

  /* Scale table to fit all 15 columns on one landscape page */
  body.printing-wip .report-sheet-table {
    width: 100% !important;
    table-layout: fixed !important;
    font-size: 0.55rem !important;
  }

  /* Allocate column widths so every value fits at landscape page width.
     Sums to 100% across 15 cols. Wider for $ values + long project names,
     narrower for percentages, dates, and short IDs. */
  body.printing-wip .report-sheet-table th:nth-child(1),
  body.printing-wip .report-sheet-table td:nth-child(1)  { width: 2.5%;  }  /* PM */
  body.printing-wip .report-sheet-table th:nth-child(2),
  body.printing-wip .report-sheet-table td:nth-child(2)  { width: 13%;   }  /* Customer/Project */
  body.printing-wip .report-sheet-table th:nth-child(3),
  body.printing-wip .report-sheet-table td:nth-child(3)  { width: 4%;    }  /* Sage Job# */
  body.printing-wip .report-sheet-table th:nth-child(4),
  body.printing-wip .report-sheet-table td:nth-child(4)  { width: 9%;    }  /* Contract Price */
  body.printing-wip .report-sheet-table th:nth-child(5),
  body.printing-wip .report-sheet-table td:nth-child(5)  { width: 7%;    }  /* Estimated Costs */
  body.printing-wip .report-sheet-table th:nth-child(6),
  body.printing-wip .report-sheet-table td:nth-child(6)  { width: 7%;    }  /* Total Billed */
  body.printing-wip .report-sheet-table th:nth-child(7),
  body.printing-wip .report-sheet-table td:nth-child(7)  { width: 7%;    }  /* Total Cost to Date */
  body.printing-wip .report-sheet-table th:nth-child(8),
  body.printing-wip .report-sheet-table td:nth-child(8)  { width: 4.5%;  }  /* Utilization */
  body.printing-wip .report-sheet-table th:nth-child(9),
  body.printing-wip .report-sheet-table td:nth-child(9)  { width: 7%;    }  /* Costs to Complete */
  body.printing-wip .report-sheet-table th:nth-child(10),
  body.printing-wip .report-sheet-table td:nth-child(10) { width: 7%;    }  /* Revised Cost Estimate */
  body.printing-wip .report-sheet-table th:nth-child(11),
  body.printing-wip .report-sheet-table td:nth-child(11) { width: 4.5%;  }  /* GM % */
  body.printing-wip .report-sheet-table th:nth-child(12),
  body.printing-wip .report-sheet-table td:nth-child(12) { width: 5%;    }  /* Start Date */
  body.printing-wip .report-sheet-table th:nth-child(13),
  body.printing-wip .report-sheet-table td:nth-child(13) { width: 5%;    }  /* Completion Date */
  body.printing-wip .report-sheet-table th:nth-child(14),
  body.printing-wip .report-sheet-table td:nth-child(14) { width: 8.5%;  }  /* Left to Bill */
  body.printing-wip .report-sheet-table th:nth-child(15),
  body.printing-wip .report-sheet-table td:nth-child(15) { width: 9%;    }  /* Approved CORs */

  body.printing-wip .report-sheet-table th,
  body.printing-wip .report-sheet-table td {
    padding: 0.35rem 0.2rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 0.55rem !important;
    line-height: 1.2 !important;
  }

  /* Headers run a touch smaller and may wrap so single-word labels
     like "Utilization" don't get truncated. */
  body.printing-wip .report-sheet-table th {
    font-size: 0.45rem !important;
    letter-spacing: 0 !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  body.printing-wip .report-sheet-table th small {
    font-size: 0.4rem !important;
  }

  body.printing-wip .report-sheet-table .font-mono {
    font-size: 0.55rem !important;
  }

  /* Tighten padding on the narrow PM column and shrink the bold "TOTAL"
     label so it fits in the 2.5%-wide PM column. */
  body.printing-wip .report-sheet-table th:nth-child(1),
  body.printing-wip .report-sheet-table td:nth-child(1) {
    padding-left: 0.1rem !important;
    padding-right: 0.1rem !important;
  }
  body.printing-wip .report-sheet-table .total-row td:first-child {
    font-size: 0.45rem !important;
  }

  /* Reconciliation area compact print layout */
  body.printing-wip .report-reconciliation-area {
    margin-top: 1rem !important;
    padding-top: 0.75rem !important;
    gap: 1.5rem !important;
  }

  body.printing-wip .recon-col h4 {
    font-size: 0.7rem !important;
    margin-bottom: 0.4rem !important;
  }

  body.printing-wip .recon-table {
    font-size: 0.6rem !important;
  }

  body.printing-wip .recon-table td {
    padding: 0.2rem 0 !important;
  }

  body.printing-wip .sheet-sig-lines {
    gap: 0.75rem !important;
    margin-top: 0.5rem !important;
  }

  body.printing-wip .sheet-sig-item span {
    font-size: 0.5rem !important;
  }

  /* Force sheet signature borders on paper */
  body.printing-wip .sheet-line {
    border-bottom: 1.5px solid #000 !important;
    height: 18px !important;
  }

  /* Prevent page breaks inside the report */
  body.printing-wip .print-report-container,
  body.printing-wip .report-sheet-card,
  body.printing-wip .report-sheet-table-wrap,
  body.printing-wip .report-reconciliation-area {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
}


/* Responsive layout adjustments */
@media (max-width: 1024px) {
  .story-grid, .sandbox-grid {
    grid-template-columns: 1fr;
  }
  .hero-section {
    flex-direction: column;
    gap: 1.5rem;
    padding: 2rem;
  }
  .hero-card {
    width: 100%;
    justify-content: center;
  }
  .header-container {
    padding: 1rem;
  }
}

@media (max-width: 768px) {
  .nav-tabs {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    padding: 0.15rem;
  }
  .nav-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
  }
  .hero-card {
    flex-direction: column;
    gap: 0.75rem;
  }
  .card-item {
    width: 100%;
  }
  .app-container {
    padding: 0 1rem;
    margin: 1rem auto;
  }
  .charts-flex {
    flex-direction: column;
  }
}

