* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, sans-serif; background: #f4f8fc; color: #0f172a; }
.shell { display: grid; grid-template-columns: 300px 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, #0b3d60, #0a2943); color: white; padding: 24px; }
.brand-block { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: start; margin-bottom: 18px; }
.brand-logo-card { width: 72px; height: 72px; border-radius: 18px; background: rgba(255,255,255,0.96); display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(35,61,184,0.12); }
.brand-logo { width: 58px; height: 58px; object-fit: contain; }
.sidebar h1 { margin: 0 0 6px; font-size: 24px; }
.sidebar p { margin: 0; line-height: 1.6; color: #dbeafe; }
.mobile-nav-select-wrap { display:none; margin-top: 18px; }
.mobile-nav-label { display:block; margin-bottom:8px; color:#dbeafe; font-size:12px; font-weight:700; text-transform:uppercase; }
.mobile-nav-select { width:100%; padding:12px; border-radius:12px; border:1px solid rgba(255,255,255,0.28); background:white; color:#0b3d60; font-weight:700; }
.nav-list { margin-top: 18px; }
.nav-btn { width: 100%; margin-bottom: 10px; padding: 12px 14px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 700; background: rgba(255,255,255,0.12); color: white; text-align: left; }
.nav-btn.active { background: white; color: #0b3d60; }
.content { padding: 28px; }
.page-section { display: none; }
.page-section.active { display: block; }
.hero { background: linear-gradient(135deg, #ffffff, #eef6ff); }
.card { background: white; border-radius: 20px; padding: 20px; box-shadow: 0 12px 24px rgba(15,23,42,0.08); margin-bottom: 18px; }
.compact-card { padding: 16px; }
.badge { display: inline-block; margin-bottom: 10px; padding: 6px 10px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; font-weight: 700; font-size: 12px; }
.grid { display: grid; gap: 16px; }
.grid.two-col { grid-template-columns: 1fr 1fr; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.primary-btn, .ghost-btn { padding: 10px 14px; border-radius: 10px; border: 0; cursor: pointer; font-weight: 700; transition: all 0.25s ease; }
.primary-btn { background: #2563eb; color: white; }
.ghost-btn { background: #dbeafe; color: #1d4ed8; }
.workflow-btn-pending { background: #fde68a !important; color: #92400e !important; box-shadow: 0 0 0 3px rgba(251,191,36,0.22), 0 10px 18px rgba(251,191,36,0.18); }
.workflow-btn-active { background: #2563eb !important; color: white !important; box-shadow: 0 0 0 3px rgba(37,99,235,0.20), 0 12px 20px rgba(37,99,235,0.24); transform: translateY(-1px); }
.workflow-btn-done { background: #dcfce7 !important; color: #166534 !important; box-shadow: inset 0 0 0 1px rgba(22,101,52,0.10); }
.status-box { padding: 14px; border-radius: 14px; background: #f8fbff; border: 1px solid #dbeafe; line-height: 1.6; }
.status-box-dark { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.2); color: white; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { border-bottom: 1px solid #e2e8f0; text-align: left; padding: 10px; vertical-align: top; }
input, select { padding: 10px; border-radius: 10px; border: 1px solid #cbd5e1; width: 100%; }
.form-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.project-intake-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 12px; }
.intake-note { margin-bottom: 16px; }
.b1-input-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.factor-card { background: #f8fbff; border: 1px solid #dbeafe; border-radius: 16px; padding: 18px; }
.factor-card h3 { margin-top: 0; color: #0b3d60; }
.factor-field { display: grid; gap: 6px; margin-bottom: 14px; }
.factor-field label { font-weight: 700; color: #0f172a; }
.factor-field label span { color: #64748b; font-weight: 600; }
.factor-field small { color: #64748b; }
.risk-output-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.progress-shell { margin-top: 12px; height: 12px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress-bar { width: 0%; height: 100%; background: linear-gradient(90deg, #2563eb, #38bdf8); transition: width 0.3s ease; }
.progress-text { margin-top: 8px; font-size: 13px; color: #475569; font-weight: 700; }
.subtle-text { color: #64748b; font-weight: 600; }
.muted { color: #64748b; text-align: center; }
.step-status-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.step-chip { padding: 8px 12px; border-radius: 999px; background: #e2e8f0; color: #475569; font-size: 12px; font-weight: 700; }
.step-chip.done { background: #dcfce7; color: #166534; }
.step-chip.active { background: #dbeafe; color: #1d4ed8; }
.overview-hero { display: grid; grid-template-columns: 260px 1fr; gap: 20px; margin-bottom: 18px; }
.overview-logo-card, .overview-main-card { background: white; border-radius: 24px; padding: 24px; box-shadow: 0 12px 24px rgba(15,23,42,0.08); }
.overview-logo-card { display: grid; place-items: center; text-align: center; background: linear-gradient(180deg, #ffffff, #eef6ff); }
.overview-logo-circle { width: 164px; height: 164px; border-radius: 999px; display: grid; place-items: center; background: radial-gradient(circle at 30% 30%, #ffffff, #eff6ff); box-shadow: inset 0 0 0 10px rgba(255,255,255,0.9), 0 12px 24px rgba(37,99,235,0.12); }
.overview-logo-image { width: 124px; height: 124px; object-fit: contain; }
.overview-logo-caption { margin-top: 16px; font-size: 20px; font-weight: 800; color: #0b3d60; }
.overview-main-card h2 { margin: 0 0 12px; font-size: 36px; color: #0b3d60; }
.overview-subtitle { margin: 0 0 18px; color: #334155; font-size: 16px; line-height: 1.7; }
.overview-meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.info-tile { padding: 16px; border-radius: 16px; background: #f8fbff; border: 1px solid #dbeafe; }
.info-label { display: block; margin-bottom: 8px; color: #64748b; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.pipeline-grid { display: grid; gap: 12px; }
.pipeline-step { padding: 14px 16px; border-radius: 16px; background: #f8fbff; border: 1px solid #dbeafe; display: grid; gap: 4px; }
.module-map { display: grid; gap: 14px; }
.module-block { padding: 16px; border-radius: 16px; background: #f8fbff; border: 1px solid #dbeafe; }
.module-title { font-weight: 800; color: #0b3d60; margin-bottom: 8px; }
.prediction-layout { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; }
.prediction-form-card, .prediction-summary-card { background: #f8fbff; border: 1px solid #dbeafe; border-radius: 16px; padding: 16px; }
.prediction-form-card h3, .prediction-summary-card h3 { margin-top: 0; color: #0b3d60; }
@media (max-width: 1100px) { .overview-hero { grid-template-columns: 1fr; } .overview-meta-grid { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } .grid.two-col, .prediction-layout, .b1-input-grid, .risk-output-grid { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  .sidebar { padding: 16px; }
  .brand-block { grid-template-columns: 56px 1fr; gap: 12px; }
  .brand-logo-card { width: 56px; height: 56px; border-radius: 14px; }
  .brand-logo { width: 44px; height: 44px; }
  .sidebar h1 { font-size: 20px; }
  .mobile-nav-select-wrap { display:block; }
  .nav-list { display: none; }
  .nav-btn { width: auto; min-width: max-content; margin-bottom: 0; white-space: nowrap; padding: 10px 12px; font-size: 13px; }
  .content { padding: 14px; }
  .card { padding: 14px; border-radius: 16px; }
  .compact-card { padding: 12px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar > * { width: 100% !important; max-width: 100% !important; }
  .form-grid, .project-intake-grid, .dataset-modal-grid { grid-template-columns: 1fr; }
  .factor-card { padding: 14px; }
  .overview-logo-circle { width: 112px; height: 112px; }
  .overview-logo-image { width: 82px; height: 82px; }
  .overview-main-card h2 { font-size: 28px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 640px; }
  .chart-box { min-height: 240px; padding: 12px; gap: 8px; }
  .chart-box::before { inset: 12px 12px 34px 12px; }
  .chart-bar { max-width: 36px; }
  .chart-label, .chart-value { font-size: 11px; }
  .modal-panel { width: calc(100vw - 16px); max-height: calc(100vh - 16px); margin: 8px auto; padding: 14px; border-radius: 16px; }
  .modal-header, .modal-footer { flex-direction: column; align-items: stretch; }
  .anfis-diagram { padding-bottom: 8px; }
  .anfis-node, .anfis-terminal { min-width: 180px; max-width: 180px; }
  .membership-curve-card { overflow-x: auto; }
}
@media (max-width: 480px) {
  .sidebar { padding: 12px; }
  .content { padding: 10px; }
  .card { padding: 12px; border-radius: 14px; }
  .badge { font-size: 11px; padding: 5px 8px; }
  .overview-main-card h2 { font-size: 24px; }
  .overview-subtitle { font-size: 14px; }
  .step-chip { font-size: 11px; padding: 7px 10px; }
  .primary-btn, .ghost-btn { padding: 11px 12px; font-size: 14px; }
  input, select { padding: 11px; font-size: 14px; }
  .chart-box { min-height: 220px; }
  .chart-bar { max-width: 28px; }
}
.modal.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 1000; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.modal-panel { position: relative; width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; margin: 20px auto; background: white; border-radius: 20px; padding: 20px; box-shadow: 0 24px 60px rgba(15,23,42,0.25); }
.large-modal { width: min(1180px, calc(100vw - 32px)); }
.modal-header, .modal-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-body { margin: 16px 0; }
.dataset-modal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-box { min-height: 320px; border: 1px solid #dbeafe; border-radius: 16px; background: linear-gradient(180deg, #fbfdff, #f4f9ff); padding: 16px; display: flex; align-items: end; gap: 12px; position: relative; }
.chart-box::before { content: ''; position: absolute; inset: 16px 16px 40px 16px; background: repeating-linear-gradient(to top, rgba(148,163,184,0.15) 0, rgba(148,163,184,0.15) 1px, transparent 1px, transparent 48px); pointer-events: none; }
.chart-bar-col { flex: 1; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 8px; position: relative; z-index: 1; }
.chart-bar { width: 100%; max-width: 52px; border-radius: 12px 12px 0 0; background: linear-gradient(180deg, #60a5fa, #1d4ed8); box-shadow: 0 8px 18px rgba(37,99,235,0.18); }
.train-bar { background: linear-gradient(180deg, #60a5fa, #2563eb); }
.val-bar { background: linear-gradient(180deg, #34d399, #059669); }
.test-bar { background: linear-gradient(180deg, #fdba74, #ea580c); }
.gap-bar { background: linear-gradient(180deg, #c084fc, #7c3aed); }
.improve-bar { background: linear-gradient(180deg, #4ade80, #16a34a); }
.worse-bar { background: linear-gradient(180deg, #fda4af, #e11d48); }
.chart-label { font-size: 12px; font-weight: 700; color: #334155; }
.chart-value { font-size: 12px; color: #1d4ed8; font-weight: 700; }
.radar-wrap { width: 100%; display: grid; place-items: center; }
.radar-svg { max-width: 100%; height: auto; }
.anfis-diagram { display:flex; align-items:stretch; gap:14px; overflow-x:auto; padding:10px 0; }
.anfis-node { min-width: 220px; max-width: 220px; border-radius: 18px; background: linear-gradient(180deg, #ffffff, #eff6ff); border: 1px solid #bfdbfe; box-shadow: 0 12px 24px rgba(37,99,235,0.10); padding: 0; overflow: hidden; display:flex; flex-direction:column; }
.anfis-node-head { background: linear-gradient(90deg, #1d4ed8, #2563eb); color: white; font-size: 12px; font-weight: 800; letter-spacing: 1px; padding: 10px 14px; text-align:center; }
.anfis-node-title { font-size: 16px; font-weight: 800; color: #0f172a; text-align:center; padding: 16px 14px 6px; }
.anfis-node-sub { font-size: 13px; font-weight: 700; color: #1d4ed8; text-align:center; padding: 0 14px 8px; }
.anfis-node-formula { margin: 0 14px 16px; padding: 12px; border-radius: 12px; background: #f8fbff; border: 1px dashed #93c5fd; color: #334155; text-align:center; font-weight: 700; }
.anfis-node-emphasis { border-color: #60a5fa; box-shadow: 0 16px 30px rgba(37,99,235,0.16); }
.anfis-link { min-width: 44px; position: relative; display:flex; align-items:center; justify-content:center; }
.anfis-link::before { content: ''; width: 100%; height: 3px; background: linear-gradient(90deg, #60a5fa, #2563eb); border-radius: 999px; }
.anfis-link::after { content: ''; position: absolute; right: 0; width: 0; height: 0; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 12px solid #2563eb; }
.anfis-terminal { min-width: 200px; max-width: 200px; border-radius: 18px; padding: 0; overflow: hidden; display:flex; flex-direction:column; box-shadow: 0 12px 24px rgba(15,23,42,0.10); }
.anfis-terminal-head { color: white; font-size: 12px; font-weight: 800; letter-spacing: 1px; padding: 10px 14px; text-align:center; }
.anfis-terminal-title { font-size: 16px; font-weight: 800; text-align:center; padding: 16px 14px 6px; }
.anfis-terminal-sub { font-size: 13px; font-weight: 700; text-align:center; padding: 0 14px 16px; }
.anfis-terminal-input { background: linear-gradient(180deg, #ecfeff, #cffafe); border:1px solid #67e8f9; }
.anfis-terminal-input .anfis-terminal-head { background: linear-gradient(90deg, #0891b2, #06b6d4); }
.anfis-terminal-input .anfis-terminal-title, .anfis-terminal-input .anfis-terminal-sub { color:#164e63; }
.anfis-terminal-output { background: linear-gradient(180deg, #eff6ff, #dbeafe); border:1px solid #93c5fd; }
.anfis-terminal-output .anfis-terminal-head { background: linear-gradient(90deg, #1d4ed8, #2563eb); }
.anfis-terminal-output .anfis-terminal-title, .anfis-terminal-output .anfis-terminal-sub { color:#1e3a8a; }
.timeline-wrap { display:grid; gap:12px; }
.timeline-card { border:1px solid #dbeafe; border-radius:16px; background:linear-gradient(180deg,#ffffff,#f8fbff); padding:14px; box-shadow:0 8px 18px rgba(37,99,235,0.06); }
.timeline-title { font-weight:800; color:#1d4ed8; margin-bottom:8px; }
.timeline-meta { color:#475569; line-height:1.6; font-size:13px; }
.membership-curve-wrap { display:grid; gap:14px; }
.membership-curve-card { border:1px solid #dbeafe; border-radius:16px; background:linear-gradient(180deg,#ffffff,#f8fbff); padding:14px; }
.membership-curve-title { font-weight:800; color:#1d4ed8; margin-bottom:8px; }
.membership-curve-svg { width:100%; max-width:540px; height:auto; display:block; }
.history-card-list { display:none; gap:12px; }
.history-mobile-card { border:1px solid #dbeafe; border-radius:16px; background:linear-gradient(180deg,#ffffff,#f8fbff); padding:14px; box-shadow:0 8px 18px rgba(37,99,235,0.06); }
.history-mobile-check { display:block; margin-bottom:10px; color:#0f172a; }
.history-mobile-meta { font-size:13px; color:#334155; line-height:1.6; margin-bottom:6px; }
.mobile-collapse-card { display:block; margin-top:16px; }
.mobile-collapse-card summary { cursor:pointer; list-style:none; padding:14px 16px; border-radius:16px; background:linear-gradient(180deg,#ffffff,#eef6ff); border:1px solid #dbeafe; font-weight:800; color:#0b3d60; box-shadow:0 10px 20px rgba(15,23,42,0.06); }
.mobile-collapse-card summary::-webkit-details-marker { display:none; }
.mobile-collapse-card[open] summary { border-bottom-left-radius:12px; border-bottom-right-radius:12px; }

/* Mobile polish phase 2: place final overrides at end so they win over later base rules */
@media (max-width: 768px) {
  .modal-panel { width: calc(100vw - 16px) !important; max-height: calc(100vh - 16px) !important; margin: 8px auto !important; padding: 14px !important; border-radius: 16px !important; }
  .chart-box { min-height: 240px !important; padding: 12px !important; gap: 8px !important; }
  .chart-box::before { inset: 12px 12px 34px 12px !important; }
  .chart-bar { max-width: 36px !important; }
  .anfis-node, .anfis-terminal { min-width: 180px !important; max-width: 180px !important; }
}
@media (max-width: 480px) {
  .chart-box { min-height: 220px !important; }
  .chart-bar { max-width: 28px !important; }
  .history-table-wrap table { display:none; }
  .history-card-list { display:grid; }
}
