:root {
  /* vikO Palette adaptation — Deep Plum to Salmon */
  --vik-deep: #301a2b;
  --vik-mid: #b8625e;
  --vik-light: #f5b08e;
  --vik-bg: #121217;
  
  --md-sys-color-surface: #1a1a20;
  --md-sys-color-on-surface: #ffffff;
  --md-sys-color-primary: #f5b08e;
  --md-sys-color-on-primary: #301a2b;
  --md-sys-color-secondary: #3b3b4d;
  --md-sys-color-outline: #414152;
  
  --status-green: #4ade80;
  --status-green-bg: rgba(74, 222, 128, 0.1);
  --status-amber: #fbbf24;
  --status-amber-bg: rgba(251, 191, 36, 0.1);
  --status-red: #ef4444;
  --status-red-bg: rgba(239, 68, 68, 0.1);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--vik-bg);
  color: var(--md-sys-color-on-surface);
  line-height: 1.5;
  padding: 20px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'Outfit', sans-serif; font-weight: 700; }

.container { max-width: 1200px; margin: 0 auto; }

.main-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 32px; border-bottom: 2px solid var(--md-sys-color-outline);
  padding-bottom: 16px;
}

.header-left { display: flex; flex-direction: column; gap: 4px; }
.header-right { display: flex; align-items: flex-end; }

.protocol-badge {
  font-size: 10px; font-weight: 800; letter-spacing: 0.1em;
  color: var(--vik-light); background: rgba(245, 176, 142, 0.1);
  padding: 4px 10px; border-radius: 20px; width: fit-content;
  border: 1px solid rgba(245, 176, 142, 0.2); margin-bottom: 8px;
}

.main-header h1 {
  font-size: 32px; letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--vik-light), var(--vik-mid));
  background-clip: text;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  line-height: 1;
}

.main-header p { font-size: 14px; opacity: 0.6; font-weight: 500; }

.alert-banner {
  display: flex; align-items: center; gap: 16px;
  background: var(--status-amber-bg);
  border: 1px solid rgba(251, 191, 36, 0.2);
  padding: 16px 20px; border-radius: 12px; margin-bottom: 24px;
}
.alert-banner i { color: var(--status-amber); flex-shrink: 0; }
.alert-banner p { font-size: 13px; margin: 0; line-height: 1.4; color: var(--md-sys-color-on-surface); }

/* Bento Layout */
.bento-grid { display: flex; gap: 24px; align-items: flex-start; }
.col-8 { flex: 8; }
.col-4 { flex: 4; }

.bento-item {
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: 16px; padding: 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stepper Navigation */
.stepper-nav {
  display: flex; gap: 8px; margin-bottom: 16px;
  background: var(--md-sys-color-secondary);
  padding: 6px; border-radius: 12px;
}

.step-tab {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 14px; border-radius: 12px;
  cursor: pointer; font-family: 'Outfit', sans-serif; font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 14px; opacity: 0.5; color: white;
  border: 1px solid transparent;
  background: transparent;
}

.step-tab:hover { opacity: 0.8; background: rgba(255,255,255,0.05); }

.step-tab.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  opacity: 1;
  box-shadow: 0 4px 12px rgba(245, 176, 142, 0.2);
}

.step-tab .step-num {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid currentColor; display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 800;
}

.step-page { display: none; animation: fadeIn 0.4s ease forwards; }
.step-page.active { display: block; }

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

@media (max-width: 900px) {
  .step-page { animation: fadeInMobile 0.3s ease forwards; }
  @keyframes fadeInMobile { from { opacity: 0; } to { opacity: 1; } }
}

.section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; color: var(--vik-light); }
.section-header i { width: 20px; height: 20px; stroke-width: 2.5; }

.form-row { display: flex; gap: 16px; margin-bottom: 16px; }
.input-group { flex: 1; display: flex; flex-direction: column; gap: 8px; }

label { font-size: 12px; font-weight: 700; opacity: 0.7; letter-spacing: 0.05em; text-transform: uppercase; }

input, select {
  background: var(--md-sys-color-secondary);
  border: 1.5px solid var(--md-sys-color-outline);
  color: white; padding: 12px 16px; border-radius: 8px;
  font-family: inherit; font-size: 15px; width: 100%;
}

input:focus, select:focus { outline: none; border-color: var(--vik-light); background: #2a2a35; }

.btn {
  border: none; border-radius: 12px; padding: 12px 24px;
  font-family: 'Outfit', sans-serif; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; transition: all 0.2s;
}

.btn-primary { background: var(--vik-light); color: var(--vik-deep); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 16px rgba(245, 176, 142, 0.2); }

.btn-secondary { background: var(--md-sys-color-secondary); color: white; border: 1.5px solid var(--md-sys-color-outline); }
.btn-secondary:hover { background: var(--md-sys-color-outline); }

.btn-secondary-outline { background: transparent; border: 1.5px solid var(--md-sys-color-outline); color: white; font-size: 11px; }

.btn-danger { background: rgba(239, 68, 68, 0.1); color: #ef4444; font-size: 12px; border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-danger-outline {
  background: transparent; border: 1.5px solid rgba(239, 68, 68, 0.3);
  color: #ef4444; font-size: 11px;
}
.btn-danger-outline:hover { background: var(--status-red-bg); }

.step-actions { display: flex; gap: 12px; margin-top: 16px; }

/* Result Card Enhancement */
.result-card { border: 2px solid var(--md-sys-color-outline); }

.global-status-banner {
  padding: 32px 16px; border-radius: 12px; text-align: center;
  margin-bottom: 16px; transition: background 0.5s ease;
}

.status-text { font-family: 'Outfit', sans-serif; font-size: 32px; font-weight: 800; letter-spacing: 0.1em; }

.status-text.green { color: var(--status-green); }
.status-text.amber { color: var(--status-amber); }
.status-text.red { color: var(--status-red); }

.domain-item {
  padding: 12px; border-radius: 8px; margin-bottom: 8px;
  border-left: 4px solid var(--md-sys-color-outline);
  background: rgba(255,255,255,0.03);
}
.domain-item.amber { border-left-color: var(--status-amber); }
.domain-item.red { border-left-color: var(--status-red); }

.summary-box {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  background: #000; padding: 12px; border-radius: 8px;
  white-space: pre-wrap; margin-bottom: 16px; border: 1.5px solid var(--md-sys-color-outline);
}

.rec-box { padding: 12px; border-radius: 8px; font-size: 13px; font-weight: 500; border: 1.5px dashed var(--md-sys-color-outline); }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }

/* Mobile Sticky Triage */
@media (max-width: 900px) {
  .bento-grid { flex-direction: column; display: flex; }
  .col-8 { order: 2; width: 100%; }
  .col-4 {
    order: 1; width: 100%;
    position: sticky; top: 0; z-index: 2000;
    margin: 0 0 16px 0; padding: 12px;
    background: var(--vik-deep) !important;
    border-bottom: 2px solid var(--md-sys-color-primary);
    box-shadow: 0 4px 20px rgba(0,0,0,0.8);
  }
  .global-status-banner { padding: 8px !important; margin-bottom: 4px !important; }
  .status-text { font-size: 20px !important; }
  .action-grid { display: none; }
  #domainList, #summary, #recommendation, .section-header:has(#summary) { display: none; }
}

@media (min-width: 901px) {
  .col-4 { position: sticky; top: 20px; }
}

/* Modal */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.85); z-index: 1000; justify-content: center; align-items: center;
  backdrop-filter: blur(8px);
}

.modal-content {
  background: var(--md-sys-color-surface); width: 95%; max-width: 600px;
  padding: 32px; border-radius: 20px; position: relative; border: 1px solid var(--md-sys-color-outline);
}

.referral-letter { color: white; line-height: 1.6; }

/* Print Overrides */
@media print {
  @page { margin: 1.5cm; }
  body { background: white !important; color: black !important; padding: 0; }
  .container { max-width: 100%; width: 100%; margin: 0; padding: 0; display: block !important; }
  
  /* Referral Letter Professional Look */
  body.modal-open #referralModal { display: block !important; position: absolute !important; top: 0; left: 0; background: white !important; width: 100%; height: auto; }
  body.modal-open .modal-content { width: 100%; border: none; padding: 0; background: white !important; }
  body.modal-open .modal-actions, body.modal-open .close-modal { display: none !important; }
  
  .referral-letter {
    color: black !important; font-size: 12pt; font-family: 'Inter', serif;
    line-height: 1.5; border: none; padding: 0;
  }
  
  /* Standard Print Layout (non-referral) */
  body:not(.modal-open) header, 
  body:not(.modal-open) .stepper-nav, 
  body:not(.modal-open) .step-actions, 
  body:not(.modal-open) .btn, 
  body:not(.modal-open) footer { display: none !important; }
  
  body:not(.modal-open) .bento-grid { display: block !important; }
  body:not(.modal-open) .step-page { display: block !important; border: 1px solid #eee; padding: 10px; margin-bottom: 15px; page-break-inside: avoid; }
  body:not(.modal-open) .col-4 { position: static; display: block; border: 1px solid #eee; margin-top: 20px; }
  body:not(.modal-open) .summary-box { background: #f9f9f9 !important; border: 1px solid #ccc !important; }
}

@media (max-width: 768px) {
  .container { padding: 12px; }
  .main-header { flex-direction: column; align-items: flex-start; gap: 16px; }
  .header-right { width: 100%; }
  .header-right button { width: 100%; justify-content: center; }
  
  .stepper-nav { gap: 4px; padding: 4px; }
  .step-tab { padding: 10px; min-width: 60px; }
  .step-tab span:not(.step-num) { display: none; } /* Hide text on small screens if any */
  
  .form-row { flex-direction: column; gap: 12px; }
  .logo-title h1 { font-size: 24px; }
}
