* { box-sizing: border-box; }

:root {
  --bg: #0b1220;
  --bg-soft: #121a2b;
  --card: rgba(18, 26, 43, 0.88);
  --card-2: rgba(255, 255, 255, 0.04);
  --text: #e8eefc;
  --muted: #a8b4d1;
  --line: rgba(255, 255, 255, 0.08);
  --brand: #66b3ff;
  --brand-2: #8ef0c0;
  --accent: #f7c66b;
  --danger: #fca5a5;
  --danger-2: #7f1d1d;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  --radius: 22px;
  --max: 1360px;

  --doc-bg: #ffffff;
  --doc-text: #111827;
  --doc-muted: #64748b;
  --doc-line: #dbe3ef;
  --amber-bg: #fffbeb;
  --amber-line: #fde68a;
  --amber-text: #92400e;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(102, 179, 255, 0.16), transparent 32%),
    linear-gradient(180deg, #f8fafc 0%, #eef4fb 44%, #f8fafc 100%);
  color: #111827;
  line-height: 1.6;
}

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

.app-shell { min-height: 100vh; }

/* =========================
   TOP BAR - PORTFOLIO THEME
========================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 28px;
  backdrop-filter: blur(16px);
  background: rgba(8, 16, 29, 0.78);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
}

.brand-wrap {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  border: 1px solid rgba(102, 179, 255, 0.22);
  background:
    radial-gradient(circle at top right, rgba(102, 179, 255, 0.24), transparent 55%),
    linear-gradient(135deg, rgba(102, 179, 255, 0.16), rgba(142, 240, 192, 0.09));
  color: var(--brand-2);
  font-size: 24px;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
}

.brand-title {
  font-size: 1.45rem;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.04em;
  background: linear-gradient(90deg, #ffffff 0%, #8ef0c0 48%, #66b3ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

.brand-subtitle {
  margin-top: 3px;
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.version-badge,
.portfolio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

.version-badge {
  border: 1px solid rgba(102,179,255,.25);
  background: linear-gradient(135deg, rgba(102,179,255,.14), rgba(142,240,192,.08));
  color: #dce9ff;
}

.portfolio-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: #0f172a;
  transition: .25s ease;
}

.portfolio-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(102,179,255,.35);
  background: rgba(102,179,255,.12);
}

/* =========================
   LAYOUT
========================= */

.page-layout {
  width: min(calc(100% - 32px), var(--max));
  margin: 0 auto;
  padding: 26px 0 42px;
}

.panel-title {
  margin-bottom: 16px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-title h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2vw, 2rem);
  letter-spacing: -0.035em;
}

.panel-title p,
.section-desc {
  margin: 4px 0 14px;
  color: #64748b;
  font-size: 0.95rem;
}

h2 { margin-top: 0; font-size: 20px; }
h3 { margin: 18px 0 8px; color: var(--text); }

label {
  display: block;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 800;
  color: #334155;
}

.hint {
  display: block;
  margin-top: 6px;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
}

.mt-16 { margin-top: 16px; }

input,
textarea,
select {
  width: 100%;
  margin-top: 7px;
  padding: 11px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font-size: 13px;
  color: #111827;
  background: #ffffff;
  outline: none;
  transition: .2s ease;
}

select option { color: #0f172a; background: #ffffff; }

input::placeholder,
textarea::placeholder { color: rgba(168, 180, 209, 0.72); }

input.incomplete,
select.incomplete {
  border-color: rgba(248, 113, 113, .75);
  background: rgba(248,113,113,.08);
}

select { cursor: pointer; }

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(102, 179, 255, 0.58);
  box-shadow: 0 0 0 3px rgba(102, 179, 255, 0.13);
  background: #ffffff;
}

textarea { resize: vertical; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* =========================
   CARDS + INPUTS
========================= */

.section-card {
  background: #ffffff;
  border: 1px solid #dbe3ef;
  border-radius: var(--radius);
  padding: 18px 18px;
  margin-bottom: 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.section-card summary {
  cursor: pointer;
  font-weight: 900;
  color: #0f172a;
  margin: 2px 0 16px;
  letter-spacing: -0.01em;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 12px;
}

.section-header p { margin: 4px 0 0; font-size: 12px; color: #64748b; }

.secondary-btn,
.ghost-btn,
.secondary-dark-btn,
.generate-btn,
.proposal-action-btn {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 800;
  font-family: inherit;
  transition: .25s ease;
}

.secondary-btn {
  color: #1e3a8a;
  background: linear-gradient(135deg, rgba(102,179,255,.16), rgba(142,240,192,.12));
  border-color: rgba(102,179,255,.22);
}

.secondary-btn:hover,
.ghost-btn:hover,
.secondary-dark-btn:hover,
.proposal-action-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255,255,255,.08);
}

.secondary-dark-btn:disabled,
.proposal-action-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

.checkbox-grid,
.challenge-grid,
.challenge-flat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  background: #ffffff;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  padding: 11px 12px;
  margin-bottom: 0;
  color: #334155;
  transition: .2s ease;
}

.checkbox-line:hover {
  border-color: rgba(102,179,255,.22);
  background: #f8fafc;
}

.checkbox-line input { width: auto; margin: 0; accent-color: var(--brand); }

.inference-note {
  margin: 8px 0 0;
  padding: 13px 15px;
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  background: #eff6ff;
  color: #64748b;
  font-size: 13px;
}

/* =========================
   WORKLOAD TABLE
========================= */

.table-scroll { overflow-x: auto; }

.input-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0 8px;
  table-layout: fixed;
}

.input-table th {
  text-align: left;
  font-size: 11px;
  color: #64748b;
  padding: 0 7px 3px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.input-table td { padding: 4px; vertical-align: top; }
.input-table input,
.input-table select { margin: 0; padding: 9px; border-radius: 10px; font-size: 12px; }

.input-table th:nth-child(1), .input-table td:nth-child(1) { width: 110px; }
.input-table th:nth-child(2), .input-table td:nth-child(2) { width: 180px; }
.input-table th:nth-child(3), .input-table td:nth-child(3) { width: 170px; }
.input-table th:nth-child(4), .input-table td:nth-child(4),
.input-table th:nth-child(5), .input-table td:nth-child(5),
.input-table th:nth-child(6), .input-table td:nth-child(6),
.input-table th:nth-child(7), .input-table td:nth-child(7) { width: 70px; }
.input-table th:nth-child(8), .input-table td:nth-child(8) { width: 42px; }

.remove-btn {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 900;
}

/* =========================
   GENERATE SECTION
========================= */

.generate-section {
  margin: 24px 0 28px;
  padding: 30px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  border-radius: var(--radius);
  border: 1px solid #dbe3ef;
  background:
    radial-gradient(circle at top right, rgba(102, 179, 255, 0.10), transparent 38%),
    radial-gradient(circle at bottom left, rgba(142, 240, 192, 0.10), transparent 42%),
    #ffffff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.generate-btn {
  padding: 15px 30px;
  border: 0;
  background: linear-gradient(135deg, #2563eb, #14b8a6);
  color: #ffffff;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 16px 34px rgba(37, 99, 235, .28);
}

.generate-btn:hover {
  transform: translateY(-2px);

  background: linear-gradient(
    135deg,
    #1d4ed8,
    #0f766e
  );

  box-shadow:
    0 20px 40px rgba(37,99,235,.35);
}

.stale-notice {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
}

.hidden { display: none; }

.empty-state {
  max-width: 740px;
  margin: 32px auto;
  background: #ffffff;
  border: 1px dashed #94a3b8;
  border-radius: var(--radius);
  text-align: center;
  padding: 54px;
  color: #0f172a;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.empty-state p { color: #64748b; }

/* =========================
   PROPOSAL ACTIONS
========================= */

.proposal-actions {
  max-width: 1040px;
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.proposal-action-btn {
  min-height: 50px;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.primary-action {
  border-color: rgba(102,179,255,.28);
  background: linear-gradient(135deg, rgba(102,179,255,.20), rgba(142,240,192,.10));
}

.danger-action {
  border-color: rgba(248,113,113,.32);
  color: #991b1b;
  background: #fff7f7;
}

/* =========================
   PROPOSAL DOCUMENT
========================= */

.proposal-doc {
  max-width: 1040px;
  margin: 0 auto;
  background: var(--doc-bg);
  color: var(--doc-text);
  padding: 44px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  line-height: 1.55;
}

.proposal-doc h1 { margin: 0; font-size: 30px; color: #0f172a; letter-spacing: -0.8px; }
.proposal-doc .subtitle { color: var(--doc-muted); margin: 8px 0 28px; }

.proposal-meta {
  margin: -14px 0 24px;
  color: #64748b;
  font-size: 12px;
  font-style: italic;
}

.proposal-doc h2 {
  border-top: 1px solid #e5e7eb;
  padding-top: 20px;
  margin-top: 24px;
  color: #1e3a8a;
  font-size: 18px;
}

.proposal-doc h3 { color: #0f172a; }
.proposal-doc p,
.proposal-doc li { color: #334155; font-size: 14px; }

.proposal-doc table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 12px;
}

.proposal-doc th,
.proposal-doc td {
  border: 1px solid #e5e7eb;
  padding: 9px;
  text-align: left;
  vertical-align: top;
}

.proposal-doc th { background: #eff6ff; color: #1e3a8a; }

.diagram-box {
  background: #f8fafc;
  border: 1px dashed #94a3b8;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  color: #334155;
  font-family: monospace;
  white-space: pre-line;
}

.note-box {
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  border-radius: 12px;
  padding: 12px;
  color: var(--amber-text);
  font-size: 13px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 14px 0;
}

.summary-grid div {
  background: #f8fafc;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  padding: 14px;
}

.summary-grid span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.summary-grid strong { display: block; color: #0f172a; font-size: 22px; }

.capacity-card {
  background: #f8fafc;
  border-left: 4px solid #16a34a;
  padding: 12px 14px;
  border-radius: 10px;
  margin: 10px 0;
}

.capacity-card strong { display: block; color: #0f172a; margin-bottom: 6px; }
.db-card { border-left-color: #7c3aed; }

.modernization-link-box{
  margin-top:12px;
  padding:12px;
  background:#eff6ff;
  border:1px solid #bfdbfe;
  border-radius:10px;
  color:#1e3a8a;
  font-size:13px;
  line-height:1.5;
}

.modernization-link-box strong{ font-size:14px; }

.modernization-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 10px 14px;
  background: #2563eb;
  color: #ffffff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
}

.modernization-btn:hover { background: #1d4ed8; }

@media (max-width: 980px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; }
  .portfolio-btn { flex: 1; }
  .grid-2,
  .grid-3,
  .grid-4,
  .checkbox-grid,
  .challenge-grid,
  .challenge-flat-grid,
  .summary-grid { grid-template-columns: 1fr; }
  .panel-title-row { align-items: stretch; flex-direction: column; }
  .section-header { flex-direction: column; }
}

@media (max-width: 720px) {
  .topbar { padding: 14px 16px; }
  .page-layout { width: min(calc(100% - 24px), var(--max)); }
  .brand-title { font-size: 1.25rem; }
  .brand-logo { width: 40px; height: 40px; }
  .proposal-actions { grid-template-columns: 1fr; }
  .proposal-doc { padding: 24px 18px; }
}
