/* ============================================================
   LOPANexus — Main Stylesheet
   InstruNexus Process Safety Suite
   ============================================================ */

/* ── Variables ────────────────────────────────────────────── */
:root {
  --navy:      #182D46;
  --slate:     #414F5E;
  --offwhite:  #F6F5F2;
  --grey:      #C8C2C2;
  --white:     #ffffff;

  --sil1:      #27ae60;
  --sil2:      #f39c12;
  --sil3:      #e67e22;
  --sil4:      #e74c3c;
  --intol:     #c0392b;
  --alarp:     #f39c12;
  --tolerable: #27ae60;

  --success:   #27ae60;
  --warning:   #f39c12;
  --danger:    #e74c3c;
  --info:      #2980b9;

  --sidebar-w: 256px;
  --topbar-h:  60px;
  --radius:    8px;
  --radius-sm: 4px;
  --shadow:    0 1px 4px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --base-size: 14px;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: var(--base-size); }
body { font-family: var(--font); background: var(--offwhite); color: var(--slate); line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }
img { max-width: 100%; }

/* ── Layout ───────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--navy); display: flex; flex-direction: column; z-index: 200;
  overflow-y: auto; transition: transform .2s;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-logo {
  width: 38px; height: 38px; background: rgba(255,255,255,.15); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; font-weight: 700; flex-shrink: 0;
}
.brand-name { color: #fff; font-size: 16px; font-weight: 700; display: block; }
.brand-tag  { color: rgba(255,255,255,.5); font-size: 11px; display: block; }

.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.35); padding: 12px 20px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: rgba(255,255,255,.7); font-size: 13.5px;
  transition: background .15s, color .15s; border-radius: 0;
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,.12); color: #fff;
}
.nav-item.active { border-left: 3px solid rgba(255,255,255,.7); }
.nav-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-logout { margin-top: auto; color: rgba(255,100,100,.8); }
.nav-logout:hover { color: #ff6b6b; background: rgba(255,100,100,.1); }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.sidebar-user-name { color: #fff; font-size: 13px; font-weight: 600; }
.sidebar-user-plan { color: rgba(255,255,255,.5); font-size: 11px; }

.main-wrapper { margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  height: var(--topbar-h); background: #fff; border-bottom: 1px solid #e8e8e8;
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.sidebar-toggle {
  display: none; background: none; border: none; font-size: 20px;
  color: var(--slate); padding: 4px 8px; border-radius: 6px;
}
.sidebar-toggle:hover { background: var(--offwhite); }
.topbar-title { font-size: 16px; font-weight: 600; color: var(--navy); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--navy); color: #fff; font-weight: 700; font-size: 14px;
  border: none; display: flex; align-items: center; justify-content: center; position: relative;
}
.topbar-user-menu { position: relative; }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: #fff; border: 1px solid #e8e8e8; border-radius: var(--radius);
  box-shadow: var(--shadow-md); min-width: 200px; display: none; z-index: 300;
}
.user-dropdown.open { display: block; }
.user-dropdown-header { padding: 12px 16px; border-bottom: 1px solid #f0f0f0; }
.user-dropdown-header strong { display: block; font-size: 13px; color: var(--navy); }
.user-dropdown-header small { color: #888; font-size: 12px; }
.user-dropdown a { display: block; padding: 9px 16px; color: var(--slate); font-size: 13.5px; }
.user-dropdown a:hover { background: var(--offwhite); }
.user-dropdown-divider { border-top: 1px solid #f0f0f0; margin: 4px 0; }
.logout-link { color: var(--danger) !important; }

.content { padding: 24px; flex: 1; max-width: 1400px; }

/* ── Typography ───────────────────────────────────────────── */
h1 { font-size: 24px; font-weight: 700; color: var(--navy); }
h2 { font-size: 20px; font-weight: 700; color: var(--navy); }
h3 { font-size: 16px; font-weight: 600; color: var(--navy); }
h4 { font-size: 14px; font-weight: 600; color: var(--navy); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: #fff; border-radius: var(--radius); border: 1px solid #e8e8e8;
  box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid #f0f0f0;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--navy); }
.card-body { padding: 20px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; border: 1px solid transparent;
  transition: all .15s; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--navy); color: #fff; }
.btn-primary:hover   { background: #1e3a5a; }
.btn-secondary { background: #fff; color: var(--slate); border-color: #d0d0d0; }
.btn-secondary:hover { background: var(--offwhite); }
.btn-ghost     { background: transparent; color: var(--slate); }
.btn-ghost:hover     { background: var(--offwhite); }
.btn-light     { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.3); }
.btn-light:hover     { background: rgba(255,255,255,.25); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover    { background: #c0392b; }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-danger-hover:hover { color: var(--danger); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; margin-bottom: 5px; font-size: 13px; font-weight: 500; color: var(--navy);
}
.form-control {
  width: 100%; padding: 8px 12px; border: 1px solid #d0d0d0; border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--slate); background: #fff; transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(24,45,70,.1); }
.form-control:disabled { background: var(--offwhite); color: #999; cursor: not-allowed; }
.form-control-sm { padding: 5px 8px; font-size: 12.5px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%23666'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-addon { padding: 8px 12px; background: var(--offwhite); border: 1px solid #d0d0d0; border-left: none; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 13px; color: #888; white-space: nowrap; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.span-2 { grid-column: span 2; }
.form-actions-bar { display: flex; gap: 12px; align-items: center; padding: 16px 0; margin-top: 8px; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px;
}
.alert-icon { font-weight: 700; font-size: 16px; flex-shrink: 0; }
.alert-success { background: #e8f8f0; color: #1e6b4a; border-left: 4px solid var(--success); }
.alert-error   { background: #fdecea; color: #8b2020; border-left: 4px solid var(--danger); }
.alert-warning { background: #fff8e0; color: #7a5a00; border-left: 4px solid var(--warning); }
.alert-info    { background: #e8f0fe; color: #1a4a7a; border-left: 4px solid var(--info); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 12px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-success   { background: #e8f8f0; color: #1e6b4a; }
.badge-warning   { background: #fff8e0; color: #7a5a00; }
.badge-danger    { background: #fdecea; color: #8b2020; }
.badge-info      { background: #e8f0fe; color: #1a4a7a; }
.badge-secondary { background: #f0f0f0; color: #555; }
.badge-dark      { background: #333; color: #fff; }
.badge-lg        { font-size: 13px; padding: 4px 12px; }
.badge-sil1      { background: #e8f8f0; color: #1e6b4a; }
.badge-sil2      { background: #fff8e0; color: #7a5a00; }
.badge-sil3      { background: #ffe8d0; color: #7a3a00; }
.badge-sil4      { background: #fdecea; color: #8b2020; }
.badge-nosil     { background: #f0f0f0; color: #555; }
.badge-na        { background: #c0392b; color: #fff; }

/* ── Tables ───────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  background: var(--offwhite); color: var(--navy); font-weight: 600; font-size: 12px;
  padding: 10px 14px; text-align: left; white-space: nowrap; border-bottom: 2px solid #e0e0e0;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; color: var(--slate); vertical-align: middle; }
.data-table tbody tr:hover { background: #fafafa; }
.data-table tbody tr:last-child td { border-bottom: none; }
.td-primary { font-weight: 500; color: var(--navy); }
.td-secondary { font-size: 12px; color: #888; margin-top: 2px; }
.td-link { color: var(--navy); font-weight: 500; }
.td-link:hover { text-decoration: underline; }
.text-mono { font-family: 'Courier New', monospace; font-size: 13px; }
.text-center { text-align: center; }
.text-muted { color: #aaa; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.action-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Dashboard ────────────────────────────────────────────── */
.welcome-banner {
  background: linear-gradient(135deg, var(--navy) 0%, #2a4a70 100%);
  border-radius: var(--radius); padding: 24px 28px; margin-bottom: 24px; color: #fff;
}
.welcome-content { display: flex; justify-content: space-between; align-items: center; }
.welcome-banner h2 { color: #fff; font-size: 20px; margin-bottom: 4px; }
.welcome-banner p  { color: rgba(255,255,255,.7); font-size: 13.5px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.stat-card { background: #fff; border-radius: var(--radius); border: 1px solid #e8e8e8; padding: 16px; display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow); }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1; }
.stat-label { font-size: 12px; color: #888; margin-top: 4px; }

.quick-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px; }
.quick-link { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 12px; border: 1px solid #e8e8e8; border-radius: var(--radius-sm); transition: all .15s; text-align: center; }
.quick-link:hover { border-color: var(--navy); background: #f0f4ff; }
.ql-icon { font-size: 22px; }
.ql-label { font-size: 12px; font-weight: 500; color: var(--slate); }

.two-col-layout { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }

.rec-item { padding: 12px 20px; border-bottom: 1px solid #f5f5f5; }
.rec-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.rec-id { font-family: monospace; font-size: 12px; background: #f0f0f0; padding: 1px 6px; border-radius: 3px; }
.rec-desc { font-size: 13px; color: var(--slate); }
.rec-study { font-size: 11px; color: #888; margin-top: 2px; }

.upgrade-card { padding: 24px; text-align: center; border: 2px solid #e8f0ff; }
.upgrade-card .upgrade-icon { font-size: 36px; margin-bottom: 12px; }
.upgrade-card h4 { margin-bottom: 8px; }
.upgrade-card p { color: #666; font-size: 13px; margin-bottom: 16px; }

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px;
}
.page-title    { font-size: 20px; margin-bottom: 4px; }
.page-subtitle { font-size: 13px; color: #888; }

.filter-bar { margin-bottom: 16px; }
.filter-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; padding: 16px 20px; border-top: 1px solid #f0f0f0; }
.page-btn { padding: 5px 10px; border: 1px solid #d0d0d0; border-radius: var(--radius-sm); background: #fff; color: var(--slate); font-size: 13px; transition: all .15s; }
.page-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.page-btn:hover:not(.active) { background: var(--offwhite); }

/* ── Scenarios List ───────────────────────────────────────── */
.study-header-bar { background: #fff; border: 1px solid #e8e8e8; border-radius: var(--radius); padding: 14px 20px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.study-breadcrumb { font-size: 12px; color: #888; margin-bottom: 4px; }
.study-breadcrumb a { color: var(--navy); }
.study-meta-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--slate); flex-wrap: wrap; }

.sil-summary-bar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.sil-summary-item { background: #fff; border: 1px solid #e8e8e8; border-radius: var(--radius-sm); padding: 10px 16px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 80px; }
.sil-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #888; }
.sil-count { font-size: 22px; font-weight: 700; color: var(--navy); }
.sil-sil1 .sil-count { color: var(--sil1); }
.sil-sil2 .sil-count { color: var(--sil2); }
.sil-sil3 .sil-count { color: var(--sil3); }
.sil-sil4 .sil-count { color: var(--sil4); }
.sil-intol .sil-count { color: var(--danger); }

.scenario-id  { background: #f0f4ff; padding: 2px 8px; border-radius: 4px; font-family: monospace; font-size: 13px; color: var(--navy); font-weight: 600; }
.row-intolerable { background: #fff5f5; }
.row-alarp { background: #fffbf0; }

/* ── LOPA Worksheet ───────────────────────────────────────── */
.scenario-breadcrumb { font-size: 12.5px; color: #888; margin-bottom: 12px; }
.scenario-breadcrumb a { color: var(--navy); }
.scenario-status-bar { background: #fff; border: 1px solid #e8e8e8; border-radius: var(--radius); padding: 12px 18px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.scenario-id-lg { font-family: monospace; font-size: 18px; font-weight: 700; color: var(--navy); background: #f0f4ff; padding: 4px 12px; border-radius: 6px; }

.ws-card { margin-bottom: 0; }
.ws-card-header { display: flex; align-items: center; justify-content: space-between; padding: 11px 18px; background: var(--offwhite); border-bottom: 1px solid #e8e8e8; font-weight: 600; font-size: 14px; color: var(--navy); }
.ws-step { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; background: var(--navy); color: #fff; border-radius: 50%; font-size: 11px; font-weight: 700; margin-right: 8px; flex-shrink: 0; }
.ws-empty-note { padding: 16px 20px; color: #aaa; font-size: 13px; font-style: italic; }

/* IPL List */
.ipl-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid #f5f5f5; }
.ipl-row:last-child { border-bottom: none; }
.ipl-row.ipl-invalid { background: #fff5f5; }
.ipl-icon { font-size: 20px; flex-shrink: 0; }
.ipl-info { flex: 1; min-width: 0; }
.ipl-name { font-weight: 500; color: var(--navy); font-size: 13.5px; }
.ipl-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.ipl-type-badge { font-size: 11px; background: #e8f0fe; color: #1a4a7a; padding: 1px 7px; border-radius: 10px; font-weight: 500; }
.ipl-type-pill { font-size: 12px; background: #e8f0fe; color: #1a4a7a; padding: 3px 10px; border-radius: 12px; font-weight: 500; }
.ipl-tag { font-size: 11px; background: #f0f0f0; color: #555; padding: 1px 7px; border-radius: 10px; font-family: monospace; }
.ipl-pfd { text-align: center; flex-shrink: 0; }
.ipl-pfd-value code { font-size: 14px; color: var(--navy); font-weight: 600; }
.ipl-pfd-label { font-size: 10px; color: #888; }
.ipl-actions { display: flex; gap: 4px; }

/* Modifier List */
.modifier-row { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid #f5f5f5; }
.modifier-info { flex: 1; }
.modifier-name { font-weight: 500; color: var(--navy); font-size: 13.5px; }
.modifier-type { font-size: 11.5px; color: #888; margin-top: 2px; }
.modifier-pfd code { font-size: 13px; color: var(--navy); }
.modifier-actions { display: flex; gap: 4px; }

/* Calculation Panel */
.calc-panel { position: sticky; top: 80px; }
.calc-body { padding: 16px 18px; }
.calc-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid #f5f5f5; font-size: 13px; }
.calc-row:last-child { border-bottom: none; }
.calc-label { flex: 1; color: var(--slate); }
.calc-value { font-family: monospace; font-size: 14px; font-weight: 600; color: var(--navy); }
.calc-unit  { font-size: 11px; color: #aaa; min-width: 30px; }
.calc-row-highlight .calc-label { font-weight: 600; }
.calc-row-result .calc-value { font-size: 16px; }
.calc-divider { border-top: 2px solid #e8e8e8; margin: 10px 0; }

.calc-sil-result { background: var(--offwhite); border-radius: var(--radius-sm); padding: 14px; margin: 12px 0; }
.sil-determination, .risk-determination { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sil-det-label, .risk-det-label { font-size: 12px; font-weight: 600; color: var(--slate); text-transform: uppercase; letter-spacing: .04em; }
.sil-det-value, .risk-det-value { font-size: 16px; font-weight: 700; padding: 4px 14px; border-radius: 20px; }
.badge-sil1.sil-det-value, .badge-sil1.risk-det-value { background: #e8f8f0; color: #1e6b4a; }
.badge-sil2.sil-det-value, .badge-sil2.risk-det-value { background: #fff8e0; color: #7a5a00; }
.badge-sil3.sil-det-value, .badge-sil3.risk-det-value { background: #ffe8d0; color: #7a3a00; }
.badge-sil4.sil-det-value, .badge-sil4.risk-det-value { background: #fdecea; color: #8b2020; }
.badge-success.sil-det-value, .badge-success.risk-det-value { background: #e8f8f0; color: #1e6b4a; }
.badge-warning.sil-det-value, .badge-warning.risk-det-value { background: #fff8e0; color: #7a5a00; }
.badge-danger.sil-det-value, .badge-danger.risk-det-value { background: #fdecea; color: #8b2020; }
.calc-note { font-size: 12px; color: #888; text-align: center; }

.sil-ref-table { margin-top: 12px; }
.sil-ref-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #888; margin-bottom: 8px; }
.sil-ref-table table { font-size: 12px; }
.sil-ref-table th { background: #f0f4ff; color: var(--navy); padding: 5px 8px; }
.sil-ref-table td { padding: 5px 8px; border-bottom: 1px solid #f0f0f0; }
.sil-ref-active { background: #fff3cd; font-weight: 700; }

/* Validation Section */
.validation-section { background: var(--offwhite); border-radius: var(--radius-sm); padding: 14px; margin-top: 12px; }
.vs-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #888; margin-bottom: 10px; }
.vs-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vs-check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.vs-check input { width: 15px; height: 15px; }

/* AI Modal */
.ai-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.ai-option-btn { padding: 12px; background: var(--offwhite); border: 1px solid #e0e0e0; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: var(--navy); transition: all .15s; }
.ai-option-btn:hover { background: #e8f0fe; border-color: var(--navy); }
.ai-result { background: #fafafa; border: 1px solid #e8e8e8; border-radius: var(--radius-sm); padding: 16px; font-size: 13.5px; max-height: 400px; overflow-y: auto; }
.ai-spinner { width: 36px; height: 36px; border: 3px solid #e0e0e0; border-top-color: var(--navy); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tabs ─────────────────────────────────────────────────── */
.tab-nav { display: flex; gap: 0; border-bottom: 2px solid #e0e0e0; margin-bottom: 20px; }
.tab-btn { padding: 10px 20px; background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; font-size: 13.5px; font-weight: 500; color: #888; transition: all .15s; }
.tab-btn.active { color: var(--navy); border-bottom-color: var(--navy); }
.tab-btn:hover { color: var(--navy); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-md);
  width: 100%; max-height: 90vh; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #f0f0f0;
}
.modal-header h3 { font-size: 16px; color: var(--navy); }
.modal-close { background: none; border: none; font-size: 18px; color: #888; padding: 2px; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid #f0f0f0; display: flex; gap: 10px; justify-content: flex-end; }

/* ── Empty States ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 32px; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h4 { color: var(--navy); margin-bottom: 8px; }
.empty-state p  { color: #888; font-size: 13.5px; margin-bottom: 20px; }

/* ── Risk Criteria ────────────────────────────────────────── */
.alarp-diagram { display: flex; flex-direction: column; gap: 4px; max-width: 500px; }
.alarp-zone { padding: 14px 18px; border-radius: var(--radius-sm); }
.az-label { font-weight: 700; font-size: 14px; }
.az-freq  { font-family: monospace; font-size: 13px; margin: 4px 0; }
.az-desc  { font-size: 12.5px; }
.alarp-intolerable { background: #fdecea; border-left: 5px solid var(--danger); }
.alarp-alarp       { background: #fff8e0; border-left: 5px solid var(--warning); }
.alarp-tolerable   { background: #e8f8f0; border-left: 5px solid var(--success); }

/* ── Reports ──────────────────────────────────────────────── */
.report-types { display: flex; flex-direction: column; gap: 8px; }
.report-type-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid #e8e8e8; border-radius: var(--radius-sm); cursor: pointer; transition: all .15s; }
.report-type-card:hover { border-color: var(--navy); background: #f0f4ff; }
.rtc-icon { font-size: 28px; flex-shrink: 0; }
.rtc-body { flex: 1; }
.rtc-title { font-weight: 600; color: var(--navy); font-size: 14px; }
.rtc-desc  { font-size: 12.5px; color: #888; margin-top: 2px; }
.rtc-arrow { font-size: 18px; color: #ccc; }
.export-format-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.export-format-option { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px; border: 2px solid #e8e8e8; border-radius: var(--radius-sm); cursor: pointer; transition: all .15s; }
.export-format-option:hover { border-color: var(--navy); }
.export-format-option input:checked + .efo-icon + .efo-label { font-weight: 700; }
.export-format-option:has(input:checked) { border-color: var(--navy); background: #f0f4ff; }
.export-format-option.disabled { opacity: .5; cursor: not-allowed; }
.efo-icon { font-size: 24px; }
.efo-label { font-size: 12px; text-align: center; color: var(--slate); line-height: 1.3; }
.export-format-option input { display: none; }
.study-info-box { background: var(--offwhite); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 12px; }
.sib-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; border-bottom: 1px solid #eee; }
.sib-row:last-child { border-bottom: none; }
.report-history-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f5f5f5; }

/* ── Subscription ─────────────────────────────────────────── */
.current-plan-banner { background: linear-gradient(135deg, var(--navy), #2a4a70); color: #fff; border-radius: var(--radius); padding: 20px 24px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; }
.cpb-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: rgba(255,255,255,.6); margin-bottom: 4px; }
.cpb-name  { font-size: 22px; font-weight: 700; }
.cpb-expires { font-size: 13px; color: rgba(255,255,255,.6); margin-top: 4px; }
.cpb-badge { background: rgba(255,255,255,.15); padding: 8px 18px; border-radius: 20px; font-weight: 600; font-size: 14px; }

.billing-toggle { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 24px; }
.toggle-switch { position: relative; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #ccc; border-radius: 24px; transition: .3s; cursor: pointer; }
.toggle-slider::before { content: ''; position: absolute; left: 3px; bottom: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: .3s; }
input:checked + .toggle-slider { background: var(--navy); }
input:checked + .toggle-slider::before { transform: translateX(20px); }
.bt-label { font-size: 14px; font-weight: 500; }
.save-badge { background: #e8f8f0; color: #1e6b4a; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }

.plans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; margin-bottom: 32px; }
.plan-card { background: #fff; border: 2px solid #e8e8e8; border-radius: var(--radius); padding: 28px 24px; position: relative; transition: all .2s; }
.plan-card.plan-featured { border-color: var(--navy); box-shadow: 0 4px 24px rgba(24,45,70,.15); }
.plan-card.plan-current  { border-color: var(--success); }
.plan-badge-popular, .plan-badge-current { position: absolute; top: -13px; left: 50%; transform: translateX(-50%); padding: 3px 14px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.plan-badge-popular { background: var(--navy); color: #fff; }
.plan-badge-current { background: var(--success); color: #fff; }
.plan-name  { font-size: 18px; font-weight: 700; color: var(--navy); margin-bottom: 12px; }
.plan-price { font-size: 32px; font-weight: 700; color: var(--navy); margin-bottom: 12px; }
.price-period { font-size: 14px; font-weight: 400; color: #888; }
.plan-limits { font-size: 13px; color: #888; margin-bottom: 16px; }
.plan-limits div { margin-bottom: 2px; }
.plan-features { list-style: none; margin-bottom: 24px; }
.plan-features li { padding: 6px 0; font-size: 13.5px; border-bottom: 1px solid #f5f5f5; display: flex; gap: 8px; align-items: center; }
.feat-yes { color: var(--slate); }
.feat-yes::before { content: '✓'; color: var(--success); font-weight: 700; }
.feat-no  { color: #ccc; text-decoration: line-through; }
.feat-no::before  { content: '✗'; color: #ccc; }

.faq-list { display: flex; flex-direction: column; gap: 0; }
.faq-item { padding: 16px 0; border-bottom: 1px solid #f0f0f0; }
.faq-item:last-child { border-bottom: none; }
.faq-q { font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.faq-a { font-size: 13.5px; color: var(--slate); line-height: 1.6; }

/* ── Profile ──────────────────────────────────────────────── */
.account-avatar { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 28px; font-weight: 700; margin: 0 auto 16px; }
.account-info-rows { }
.air-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f5f5f5; font-size: 13.5px; }
.air-row span:first-child { color: #888; }

/* ── IPL Library ──────────────────────────────────────────── */
.ipl-type-pill { display: inline-block; }

/* ── Scenarios Table ──────────────────────────────────────── */
.scenarios-table .ipl-type-badge { margin-right: 2px; }

/* ── Admin Sidebar Fix ────────────────────────────────────── */
.admin-page .sidebar { }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .two-col-layout { grid-template-columns: 1fr; }
  .lopa-worksheet { grid-template-columns: 1fr !important; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-256px); }
  .sidebar.sidebar-open { transform: translateX(0); width: 256px; }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .content { padding: 16px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .plans-grid { grid-template-columns: 1fr; }
  .vs-checks { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; gap: 12px; }
  .welcome-content { flex-direction: column; gap: 16px; }
  .study-header-bar { flex-direction: column; gap: 12px; align-items: flex-start; }
  .sil-summary-bar { gap: 8px; }
  .sil-summary-item { min-width: 60px; }
  .ai-options { grid-template-columns: 1fr; }
  .export-format-grid { grid-template-columns: 1fr; }
  .scenarios-table th:nth-child(3), .scenarios-table td:nth-child(3),
  .scenarios-table th:nth-child(5), .scenarios-table td:nth-child(5) { display: none; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, .filter-bar, .pagination, .modal-overlay { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
