:root {
  --puce-blue: #164284;
  --puce-sky: #00a0dd;
  --puce-gray: #575756;
  --ink: #17233d;
  --muted: #667085;
  --line: #d8e2ee;
  --page: #f4f8fc;
  --white: #ffffff;
  --success: #247a57;
  --warning: #a15c00;
  --danger: #a33a3a;
  --purple: #6f5bd3;
  --radius: 18px;
  --shadow: 0 14px 40px rgba(22, 66, 132, .10);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-rounded, "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.skip-link {
  position: fixed;
  left: 16px;
  top: -60px;
  z-index: 999;
  padding: 10px 16px;
  color: white;
  background: var(--puce-blue);
  border-radius: 0 0 8px 8px;
}
.skip-link:focus { top: 0; }

.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(20px, 4vw, 64px);
  color: white;
  background: var(--puce-blue);
}

.brand { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand img { width: 148px; height: auto; filter: brightness(0) invert(1); }
.brand-divider { width: 1px; height: 38px; background: rgba(255,255,255,.35); }
.product-name { font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.product-name small { display: block; font-size: .72rem; font-weight: 600; opacity: .72; letter-spacing: .04em; text-transform: uppercase; }

.userbar { display: flex; align-items: center; gap: 12px; }
.userbar strong { font-size: .9rem; }
.userbar span { display: block; font-size: .76rem; opacity: .76; }
.avatar {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 50%; background: var(--puce-sky); color: white; font-weight: 900;
}

.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 78px); }
.sidebar { padding: 26px 18px; background: white; border-right: 1px solid var(--line); }
.sidebar-label { margin: 0 12px 10px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.nav-link {
  width: 100%; display: flex; align-items: center; gap: 12px; margin: 4px 0; padding: 12px 14px;
  border: 0; border-radius: 12px; color: var(--ink); background: transparent; text-align: left; font-weight: 700;
}
.nav-link:hover { background: #eef7fc; }
.nav-link.active { color: var(--puce-blue); background: #e7f5fb; }
.nav-icon { width: 24px; font-size: 1.1rem; text-align: center; }
.sidebar-footer { margin-top: 32px; padding: 16px 12px; border-top: 1px solid var(--line); }

.main { min-width: 0; padding: clamp(24px, 4vw, 52px); }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 7px; color: var(--puce-sky); font-size: .78rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3 { margin-top: 0; line-height: 1.15; letter-spacing: -.025em; }
h1 { margin-bottom: 8px; font-size: clamp(1.8rem, 4vw, 2.65rem); }
h2 { font-size: clamp(1.25rem, 2.5vw, 1.65rem); }
h3 { font-size: 1.05rem; }
.subhead { margin: 0; max-width: 760px; color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 28px; }
.metric, .panel, .mission-card {
  background: white; border: 1px solid rgba(22, 66, 132, .10); border-radius: var(--radius); box-shadow: var(--shadow);
}
.metric { position: relative; overflow: hidden; padding: 22px; }
.metric::after { content: ''; position: absolute; right: -22px; top: -22px; width: 84px; height: 84px; border-radius: 50%; background: rgba(0,160,221,.09); }
.metric-label { color: var(--muted); font-size: .82rem; font-weight: 700; }
.metric-value { margin-top: 6px; color: var(--puce-blue); font-size: 2rem; font-weight: 900; letter-spacing: -.04em; }
.metric-detail { margin-top: 4px; color: var(--muted); font-size: .78rem; }
.panel { padding: 24px; margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-head h2, .panel-head h3 { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px;
  padding: 10px 17px; border: 1px solid transparent; border-radius: 12px; font-weight: 800; text-decoration: none;
}
.btn-primary { color: white; background: var(--puce-blue); }
.btn-primary:hover { background: #0f356e; }
.btn-sky { color: #06334b; background: #cceffc; border-color: #88d6f2; }
.btn-ghost { color: var(--puce-blue); background: white; border-color: #b8cade; }
.btn-danger { color: var(--danger); background: #fff5f5; border-color: #f1c1c1; }
.btn-sm { min-height: 34px; padding: 7px 11px; font-size: .82rem; border-radius: 9px; }
.btn:focus-visible, .nav-link:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(0,160,221,.35); outline-offset: 2px;
}

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, .85fr) minmax(520px, 1.15fr); }
.login-brand {
  position: relative; overflow: hidden; padding: clamp(40px, 7vw, 90px); color: white;
  background: linear-gradient(145deg, #10376e, var(--puce-blue) 52%, #087ba9);
}
.login-brand::before, .login-brand::after { content: ''; position: absolute; border: 2px solid rgba(255,255,255,.13); border-radius: 50%; }
.login-brand::before { width: 360px; height: 360px; right: -190px; top: -70px; }
.login-brand::after { width: 520px; height: 520px; left: -320px; bottom: -310px; }
.login-brand img { position: relative; width: 230px; max-width: 70%; filter: brightness(0) invert(1); }
.login-copy { position: relative; z-index: 1; margin-top: min(18vh, 150px); max-width: 540px; }
.login-copy h1 { font-size: clamp(2.3rem, 5vw, 4.6rem); }
.login-copy p { color: rgba(255,255,255,.82); font-size: 1.08rem; }
.login-orbit { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.login-orbit span { padding: 8px 13px; border: 1px solid rgba(255,255,255,.22); border-radius: 999px; background: rgba(255,255,255,.08); font-size: .82rem; }
.login-panel { display: grid; place-items: center; padding: clamp(28px, 6vw, 90px); background: #f9fbfd; }
.login-card { width: min(100%, 500px); }
.login-card h2 { font-size: 2rem; margin-bottom: 8px; }
.login-card > p { color: var(--muted); }
.role-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 28px 0 20px; padding: 6px; background: #eaf0f6; border-radius: 14px; }
.role-tab { padding: 10px 8px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 800; }
.role-tab.active { color: var(--puce-blue); background: white; box-shadow: 0 5px 14px rgba(22,66,132,.10); }
.field { display: grid; gap: 7px; margin-bottom: 15px; }
.field label { font-size: .84rem; font-weight: 800; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; color: var(--ink); background: white; border: 1px solid #bdcad8; border-radius: 11px;
}
.field textarea { min-height: 90px; resize: vertical; }
.login-submit { width: 100%; margin-top: 6px; }
.demo-note { margin-top: 18px; padding: 14px; color: #3d5068; background: #eef7fc; border-radius: 12px; font-size: .82rem; }

.progress-track { height: 12px; overflow: hidden; background: #dce8f2; border-radius: 999px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--puce-sky), var(--puce-blue)); border-radius: inherit; transition: width .4s ease; }
.mission-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; }
.mission-card { position: relative; padding: 20px; transition: transform .18s ease, box-shadow .18s ease; }
.mission-card:not(.locked):hover { transform: translateY(-3px); box-shadow: 0 18px 42px rgba(22,66,132,.15); }
.mission-card.locked { opacity: .58; box-shadow: none; background: #f1f4f7; }
.mission-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.node-badge { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: white; background: var(--puce-blue); font-weight: 900; }
.mission-card.completed .node-badge { background: var(--success); }
.status-pill, .tag {
  display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800;
}
.status-pill { color: #36516d; background: #eaf1f7; }
.status-pill.done { color: #176044; background: #def4e8; }
.tag { color: #075475; background: #e3f6fd; }
.mission-card h3 { margin: 18px 0 7px; }
.mission-card p { min-height: 42px; margin: 0 0 16px; color: var(--muted); font-size: .88rem; }
.mission-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 17px; }

.skills { display: grid; gap: 13px; }
.skill-row { display: grid; grid-template-columns: 150px minmax(100px,1fr) 64px; align-items: center; gap: 14px; }
.skill-row strong { font-size: .86rem; }
.skill-row span { color: var(--muted); font-size: .8rem; text-align: right; }
.badge-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.badge-card { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #f7fafc; }
.badge-card.earned { border-color: #8bd0ec; background: #eaf8fd; }
.badge-mark { width: 38px; height: 38px; display: grid; place-items: center; margin-bottom: 10px; border-radius: 50%; color: white; background: #a7b2bf; font-weight: 900; }
.badge-card.earned .badge-mark { background: linear-gradient(145deg, var(--puce-sky), var(--puce-blue)); }
.badge-card h3 { margin-bottom: 5px; }
.badge-card p { margin: 0; color: var(--muted); font-size: .78rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 690px; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: #41536a; background: #eef4f9; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
td { font-size: .88rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfd; }
.state { font-size: .76rem; font-weight: 800; }
.state.on { color: var(--success); }
.state.off { color: var(--danger); }

.two-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 22px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.span-2 { grid-column: span 2; }
.empty { padding: 28px; color: var(--muted); text-align: center; border: 1px dashed #b7c7d7; border-radius: 13px; }

.activity-dialog { width: min(680px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 24px; box-shadow: 0 30px 90px rgba(15,38,73,.35); }
.activity-dialog::backdrop { background: rgba(10,28,55,.65); backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 24px 26px; color: white; background: var(--puce-blue); }
.dialog-head h2 { margin: 0; font-size: 1.35rem; }
.close-btn { width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; color: white; background: transparent; font-size: 1.35rem; }
.dialog-body { padding: 26px; }
.activity-prompt { margin: 0 0 20px; font-size: 1.2rem; font-weight: 800; }
.option-list { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 10px; padding: 13px 15px; border: 2px solid var(--line); border-radius: 13px; background: white;
}
.option:has(input:checked) { border-color: var(--puce-sky); background: #edf9fd; }
.feedback { margin-top: 18px; padding: 15px; border-radius: 12px; }
.feedback.success { color: #14553d; background: #def4e8; }
.feedback.retry { color: #714400; background: #fff0d5; }
.lsec-note { display: flex; gap: 10px; margin: 18px 0; padding: 13px; color: #405269; background: #f1f5f9; border-radius: 12px; font-size: .83rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 1000; max-width: 380px; padding: 13px 17px; color: white; background: var(--ink); border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(18px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

.mobile-nav { display: none; }

@media (max-width: 1050px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .mission-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .badge-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 330px; padding: 34px; }
  .login-copy { margin-top: 60px; }
  .login-copy h1 { font-size: 2.5rem; }
  .layout { display: block; padding-bottom: 70px; }
  .sidebar { display: none; }
  .mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; justify-content: space-around; padding: 8px; background: white; border-top: 1px solid var(--line); box-shadow: 0 -7px 24px rgba(15,38,73,.08); }
  .mobile-nav .nav-link { width: auto; flex: 1; justify-content: center; padding: 10px 6px; font-size: .75rem; }
  .nav-icon { width: auto; }
  .topbar { height: 68px; padding: 0 18px; }
  .brand img { width: 116px; }
  .brand-divider, .product-name small, .userbar > div:not(.avatar) { display: none; }
  .main { padding: 24px 17px; }
}

@media (max-width: 620px) {
  .cards, .mission-grid, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .page-head, .panel-head { align-items: flex-start; flex-direction: column; }
  .page-head .btn, .panel-head .btn { width: 100%; }
  .skill-row { grid-template-columns: 105px minmax(80px,1fr) 48px; }
  .role-tabs { font-size: .76rem; }
  .badge-grid { grid-template-columns: 1fr; }
  .login-panel { padding: 28px 20px; }
  .activity-dialog { border-radius: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
