/* style.css — Cap Table Commander */

:root {
  --bg-primary: #f5f2ed;
  --bg-secondary: #ffffff;
  --bg-tertiary: #edeae4;
  --text-primary: #1a1a1a;
  --text-secondary: #5a5a5a;
  --text-tertiary: #8a8a8a;
  --accent-green: #2d5a3d;
  --accent-green-light: #3d7a52;
  --accent-blue: #4a6fa5;
  --accent-blue-light: #5a80b5;
  --accent-gold: #8b6914;
  --accent-gold-light: #a67c1a;
  --accent-red: #8b2d2d;
  --accent-red-light: #a63d3d;
  --border-color: #d4d0c8;
  --border-light: #e8e5de;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  --font-display: Georgia, 'Times New Roman', Times, serif;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #242424;
  --bg-tertiary: #2e2e2e;
  --text-primary: #e8e5e0;
  --text-secondary: #a09a90;
  --text-tertiary: #6a6560;
  --accent-green: #4a9a6a;
  --accent-green-light: #5ab07a;
  --accent-blue: #6a8fc5;
  --accent-blue-light: #7aa0d5;
  --accent-gold: #b08a20;
  --accent-gold-light: #c09a30;
  --accent-red: #b04040;
  --accent-red-light: #c05050;
  --border-color: #3a3a3a;
  --border-light: #333333;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-tertiary: #2e2e2e;
    --text-primary: #e8e5e0;
    --text-secondary: #a09a90;
    --text-tertiary: #6a6560;
    --accent-green: #4a9a6a;
    --accent-green-light: #5ab07a;
    --accent-blue: #6a8fc5;
    --accent-blue-light: #7aa0d5;
    --accent-gold: #b08a20;
    --accent-gold-light: #c09a30;
    --accent-red: #b04040;
    --accent-red-light: #c05050;
    --border-color: #3a3a3a;
    --border-light: #333333;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
    color-scheme: dark;
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px;
  gap: 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.stage-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  background: var(--accent-green);
  color: #fff;
  border-radius: 20px;
}

.header-right {
  display: flex;
  gap: 8px;
}

.metric-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  min-width: 70px;
}

.metric-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Dashboard Grid */
.dashboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.cap-table-panel { grid-column: 1; grid-row: 1; }
.control-panel { grid-column: 2; grid-row: 1; }
.market-panel { grid-column: 1; grid-row: 2; }
.action-panel { grid-column: 2; grid-row: 2; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

.panel-subtitle {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.panel-title-sm {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Cap Table Panel */
.cap-table-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.donut-container {
  position: relative;
  width: 160px;
  min-width: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.donut-chart {
  width: 100%;
  height: auto;
  max-height: 100%;
}

.donut-center {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.donut-percent {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.donut-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.cap-table-legend {
  flex: 1;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.legend-row:hover {
  background: var(--bg-tertiary);
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-name {
  flex: 1;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.legend-pct {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Control Panel */
.control-bar-container {
  padding: 16px;
}

.control-bar-track {
  position: relative;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 8px;
}

.control-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-green), var(--accent-green-light));
  border-radius: 12px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.control-threshold {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--text-tertiary);
  opacity: 0.4;
}

.threshold-label {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.control-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.control-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-tertiary);
}

.control-status {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-green);
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin: 0 16px 12px;
}

.milestone-tracker {
  padding: 0 16px 16px;
  flex: 1;
  overflow-y: auto;
}

.milestone-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.milestone-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.milestone-item:hover {
  background: var(--bg-tertiary);
}

.milestone-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  flex-shrink: 0;
  transition: all 0.3s;
}

.milestone-icon.completed {
  background: var(--accent-green);
  border-color: var(--accent-green);
}

.milestone-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Market Panel */
.sentiment-meter {
  padding: 16px;
}

.sentiment-track {
  height: 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.sentiment-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background 0.6s;
}

.sentiment-labels {
  display: flex;
  justify-content: space-between;
}

.sentiment-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sentiment-label.cold { color: var(--accent-blue); }
.sentiment-label.warm { color: var(--accent-gold); }
.sentiment-label.hot { color: var(--accent-red); }

.market-factors {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.factor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.factor-icon {
  font-size: 0.85rem;
}

.factor-name {
  flex: 1;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.factor-impact {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
}

.factor-impact.favorable {
  color: var(--accent-green);
  background: rgba(45, 90, 61, 0.1);
}

.factor-impact.headwind {
  color: var(--accent-red);
  background: rgba(139, 45, 45, 0.1);
}

.factor-impact.neutral {
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
}

.burn-rate-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin: 0 16px 12px;
}

.burn-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.burn-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Action Panel */
.instrument-selector {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.instrument-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.instrument-btn:hover {
  background: var(--border-light);
  transform: translateY(-1px);
}

.instrument-btn.active {
  border-color: var(--accent-green);
  background: rgba(45, 90, 61, 0.08);
}

.inst-icon {
  font-size: 1.2rem;
}

.inst-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.inst-desc {
  font-size: 0.6rem;
  color: var(--text-tertiary);
}

.terms-form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-label {
  width: 140px;
  min-width: 140px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.form-input-group {
  display: flex;
  align-items: center;
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s;
}

.form-input-group:focus-within {
  border-color: var(--accent-green);
}

.currency-symbol, .currency-unit {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 0 8px;
  background: var(--bg-secondary);
  height: 36px;
  display: flex;
  align-items: center;
}

.form-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 4px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  outline: none;
  min-width: 0;
}

.form-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

.term-sheet-preview {
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.ts-title {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.ts-content {
  white-space: normal;
}

.action-buttons {
  display: flex;
  gap: 8px;
  padding-top: 8px;
}

.btn {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-green);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-green-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

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

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

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

.btn-lg {
  padding: 14px 32px;
  font-size: 0.9rem;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.end-screen {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  text-align: center;
  max-width: 480px;
  width: 90%;
  animation: slideUp 0.3s ease;
}

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

.end-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.end-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.end-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.end-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.end-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.end-stat-value {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.end-stat-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.event-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  max-width: 440px;
  width: 90%;
  animation: slideUp 0.3s ease;
}

.event-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.event-icon {
  font-size: 1.5rem;
}

.event-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.event-body {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 20px;
}

.event-choices {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.event-choices .btn {
  flex: 1;
  min-width: 120px;
}

/* SVG Donut Chart */
.donut-segment {
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive */
@media (max-width: 768px) {
  #app {
    padding: 8px;
    gap: 8px;
    overflow-y: auto;
  }

  .app-header {
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }

  .header-right {
    width: 100%;
    justify-content: space-around;
  }

  .metric-pill {
    min-width: 60px;
    padding: 4px 10px;
  }

  .dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .cap-table-panel,
  .control-panel,
  .market-panel,
  .action-panel {
    grid-column: 1;
    grid-row: auto;
    min-height: 200px;
  }

  .instrument-selector {
    flex-direction: column;
  }

  .form-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .form-label {
    width: auto;
    min-width: auto;
  }

  .form-input-group {
    width: 100%;
  }

  .cap-table-body {
    flex-direction: column;
  }

  .donut-container {
    width: 120px;
    min-width: 120px;
    padding: 8px;
  }

  .donut-percent {
    font-size: 1.1rem;
  }

  .end-screen {
    padding: 24px;
  }

  .end-stats {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .app-title {
    font-size: 1rem;
  }

  .metric-pill {
    min-width: 50px;
    padding: 3px 8px;
  }

  .metric-value {
    font-size: 0.8rem;
  }

  .btn {
    padding: 8px 14px;
    font-size: 0.7rem;
  }

  .instrument-btn {
    padding: 8px 6px;
  }

  .inst-name {
    font-size: 0.65rem;
  }

  .inst-desc {
    font-size: 0.55rem;
  }
}

/* Focus styles for accessibility */
.btn:focus-visible,
.form-input:focus-visible,
.instrument-btn:focus-visible {
  outline: 2px solid var(--accent-green);
  outline-offset: 2px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}
