:root {
  --bg: #f2eee6;
  --surface: rgba(255, 252, 247, 0.94);
  --surface-strong: #fffdf8;
  --surface-dark: #1f2321;
  --border: rgba(60, 49, 36, 0.12);
  --border-strong: rgba(60, 49, 36, 0.2);
  --ink: #231f1a;
  --muted: #6e665b;
  --accent: #b5482f;
  --accent-dark: #8f331e;
  --success: #2f8f64;
  --warning: #b67900;
  --error: #c94141;
  --shadow: 0 20px 60px rgba(52, 37, 18, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(181, 72, 47, 0.16), transparent 28%),
    radial-gradient(circle at 85% 12%, rgba(242, 180, 92, 0.2), transparent 22%),
    linear-gradient(180deg, #f7f0e5 0%, #efe7db 100%);
}

body.modal-open {
  overflow: hidden;
}

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

.screen-login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px;
}

.login-card {
  width: min(420px, 100%);
  padding: 40px;
  border-radius: 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-kicker,
.eyebrow,
.detail-kicker,
.panel-title,
.metric-label,
.micro-label,
.field-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 700;
}

.login-kicker,
.eyebrow,
.detail-kicker,
.panel-title {
  color: var(--accent);
}

.login-card h1,
.detail-header h1,
.empty-state h2,
.brand {
  margin: 0;
  font-family: "DM Serif Display", serif;
  letter-spacing: -0.03em;
}

.login-card h1 {
  margin-top: 10px;
  font-size: 42px;
}

.login-card p {
  margin: 14px 0 24px;
  line-height: 1.6;
  color: var(--muted);
}

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

.login-form input,
.search-input,
.filter-select,
.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  outline: none;
}

.login-form input:focus,
.search-input:focus,
.filter-select:focus,
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(181, 72, 47, 0.12);
}

.login-error {
  margin-top: 14px;
  color: var(--error);
  font-size: 14px;
}

.screen-app {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  display: flex;
  flex-direction: column;
  background: rgba(28, 30, 29, 0.94);
  color: #f7f4ef;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden;
  z-index: 20;
}

.sidebar-top {
  display: grid;
  gap: 16px;
}

.brand {
  font-size: 30px;
  color: #fff6ef;
}

.brand-sub {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 13px;
}

.brand-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.toolbar {
  display: grid;
  gap: 10px;
}

.filter-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.search-input,
.filter-select {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.search-input::placeholder,
.filter-select::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.list-header {
  margin-top: 22px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.55);
}

.opportunity-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
}

.sidebar-empty {
  padding: 18px 14px;
  border-radius: 16px;
  color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.04);
}

.opportunity-card {
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.opportunity-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.opportunity-card.active {
  border-color: rgba(242, 180, 92, 0.5);
  background: linear-gradient(180deg, rgba(181, 72, 47, 0.24), rgba(255, 255, 255, 0.08));
}

.opportunity-title-row,
.meta-row,
.card-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.opportunity-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.opportunity-company {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
}

.meta-row {
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-top: 10px;
}

.card-footer {
  margin-top: 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.52);
}

.pill,
.mini-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.86);
}

.mini-status.ready {
  background: rgba(47, 143, 100, 0.18);
  color: #9ce1bf;
}

.pill.stage-proposal,
.pill.stage-analysis {
  background: rgba(242, 180, 92, 0.18);
  color: #ffd483;
}

.pill.stage-negotiation,
.pill.stage-contract {
  background: rgba(90, 150, 255, 0.18);
  color: #b7d0ff;
}

.pill.stage-won {
  background: rgba(47, 143, 100, 0.18);
  color: #97e0bc;
}

.pill.stage-lost {
  background: rgba(201, 65, 65, 0.2);
  color: #ffb4b4;
}

.main-panel {
  padding: 32px;
  height: 100vh;
  overflow-y: auto;
}

.empty-state {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  text-align: center;
}

.empty-mark {
  display: inline-grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 24px;
  margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--accent), #efb562);
  color: white;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.empty-state p {
  max-width: 560px;
  color: var(--muted);
  line-height: 1.7;
}

.detail-view {
  display: grid;
  gap: 18px;
}

.feedback-banner,
.detail-header,
.panel,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.feedback-banner {
  padding: 16px 18px;
  border-radius: 18px;
  font-weight: 600;
}

.feedback-banner.success {
  color: #1e6345;
  background: rgba(235, 249, 241, 0.96);
  border-color: rgba(47, 143, 100, 0.25);
}

.feedback-banner.error {
  color: #8e2d2d;
  background: rgba(254, 239, 239, 0.98);
  border-color: rgba(201, 65, 65, 0.24);
}

.detail-header {
  position: sticky;
  top: 18px;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 22px 24px;
  border-radius: 24px;
  background: rgba(255, 252, 247, 0.98);
  box-shadow: 0 16px 40px rgba(52, 37, 18, 0.12);
  backdrop-filter: blur(12px);
}

.detail-header h1 {
  font-size: clamp(32px, 4vw, 48px);
}

.detail-title-wrap {
  min-width: 0;
}

.detail-meta-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-company {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.action-inline {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button {
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.button-primary {
  background: var(--accent);
  color: white;
}

.button-primary:hover {
  background: var(--accent-dark);
}

.button-secondary {
  background: #302821;
  color: #fff7ef;
}

.button-success {
  background: var(--success);
  color: white;
}

.button-ghost-light {
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  border: 1px solid var(--border);
}

.button-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.button-small {
  padding: 10px 12px;
}

.workspace-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1.25fr 1fr;
}

.panel {
  border-radius: 22px;
  padding: 22px;
}

.panel-overview,
.panel-full {
  grid-column: 1 / -1;
}

.overview-grid,
.form-grid,
.metrics-grid {
  display: grid;
  gap: 14px;
}

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

.micro-value {
  margin-top: 6px;
  line-height: 1.5;
  font-weight: 600;
  word-break: break-word;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}

.status-badge.stage-analysis,
.status-badge.stage-proposal {
  background: rgba(242, 180, 92, 0.18);
  color: #865300;
  border-color: rgba(242, 180, 92, 0.26);
}

.status-badge.stage-negotiation,
.status-badge.stage-contract {
  background: rgba(90, 150, 255, 0.18);
  color: #315fb6;
  border-color: rgba(90, 150, 255, 0.24);
}

.status-badge.stage-won {
  background: rgba(47, 143, 100, 0.18);
  color: #1f6d4b;
  border-color: rgba(47, 143, 100, 0.24);
}

.status-badge.stage-lost {
  background: rgba(201, 65, 65, 0.14);
  color: #9a3030;
  border-color: rgba(201, 65, 65, 0.2);
}

.summary-block,
.stack-block {
  margin-top: 18px;
}

.stack-block {
  display: grid;
  gap: 18px;
}

.panel-content {
  margin-top: 10px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.panel-content.empty {
  color: var(--muted);
  font-style: italic;
}

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

.field-group {
  display: grid;
  gap: 8px;
}

.field-group-wide {
  grid-column: 1 / -1;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.field-group textarea {
  min-height: 118px;
  resize: vertical;
}

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

.metric-card {
  border-radius: 22px;
  padding: 18px 20px;
}

.metric-value {
  display: block;
  margin-top: 10px;
  font-size: 22px;
  line-height: 1.2;
}

.transcript-actions {
  display: grid;
  gap: 14px;
}

.transcript-editor-wrap {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.transcript-editor {
  width: 100%;
  min-height: 280px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  line-height: 1.6;
  resize: vertical;
}

.transcript-full {
  margin-top: 14px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.66);
  white-space: pre-wrap;
  line-height: 1.7;
  max-height: 340px;
  overflow-y: auto;
}

.panel-secondary {
  opacity: 0.82;
}

.log-box {
  margin-top: 14px;
  padding: 18px;
  border-radius: 18px;
  background: #161716;
  color: #d6f2dd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 220px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #1d1c1b;
  color: white;
  box-shadow: var(--shadow);
}

.toast.success {
  background: #1f4733;
}

.toast.error {
  background: #5e2323;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 16, 12, 0.45);
  backdrop-filter: blur(10px);
  z-index: 1200;
}

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.modal-header,
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.modal-header h2 {
  margin: 8px 0 0;
  font-family: "DM Serif Display", serif;
  letter-spacing: -0.03em;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 4px;
}

.modal-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.suggestion-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.suggestion-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  padding: 14px 16px;
  display: grid;
  gap: 12px;
}

.suggestion-title {
  font-weight: 700;
  line-height: 1.4;
}

.suggestion-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.suggestion-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.suggestion-input {
  width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1200px) {
  .screen-app {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .opportunity-list {
    max-height: none;
  }

  .main-panel {
    height: auto;
    overflow: visible;
  }

  .workspace-grid,
  .overview-grid,
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .main-panel,
  .sidebar,
  .login-card {
    padding: 20px;
  }

  .detail-header {
    flex-direction: column;
    align-items: flex-start;
    top: 10px;
  }

  .header-actions,
  .action-inline,
  .filter-row,
  .overview-grid,
  .form-grid,
  .metrics-grid,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }
}
