/* Train Operational Simulation System. Developed by DreamEDGE Sdn Bhd. KTMB colour theme. */
:root {
  --ktm-blue: #0268B3;
  --ktm-blue-dark: #02508A;
  --ktm-blue-light: #E6F0F9;
  --ktm-yellow: #FFD000;
  --ktm-yellow-light: #FFF7CC;
  --ktm-black: #0A0905;
  --navy: #0B1F3A;
  --navy-2: #12294A;
  --ink: #0B1F3A;
  --ink-soft: #3A4A5C;
  --muted: #5B6B7F;
  --line: #D6DEE8;
  --bg: #F3F6FA;
  --panel: #FFFFFF;
  --ok: #1E8E3E;
  --warn: #C77700;
  --bad: #C62828;
  --radius: 12px;
  --shadow: 0 6px 20px rgba(11, 31, 58, 0.08);
  --sidebar-w: 260px;
  font-family: 'Segoe UI', 'IBM Plex Sans', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-size: 15px; }
button, input, select, textarea { font: inherit; }
a { color: var(--ktm-blue); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }

/* ---------- Login page ---------- */
.login-page { min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: linear-gradient(160deg, var(--navy) 0%, var(--ktm-blue-dark) 100%); color: #F6F8FB; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-hero::before { content: ''; position: absolute; left: 0; top: 0; width: 100%; height: 14px; background: var(--ktm-yellow); }
.login-hero .eyebrow { color: var(--ktm-yellow); font-weight: 600; letter-spacing: 3px; text-transform: uppercase; font-size: 13px; }
.login-hero h1 { font-size: 40px; margin-top: 14px; max-width: 560px; }
.login-hero p.lead { margin-top: 16px; color: #BFD3E6; max-width: 520px; line-height: 1.5; }
.hero-features { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 32px; }
.hero-feature { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14); border-radius: var(--radius); padding: 14px 16px; }
.hero-feature b { display: block; color: var(--ktm-yellow); margin-bottom: 4px; }
.hero-feature span { color: #BFD3E6; font-size: 13.5px; }
.login-brand { display: flex; align-items: center; gap: 18px; }
.login-brand img { height: 56px; background: #fff; border-radius: 8px; padding: 6px 10px; }
.login-card-wrap { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: 100%; max-width: 440px; background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); padding: 36px; }
.login-card h2 { font-size: 24px; }
.login-card .sub { color: var(--muted); margin-top: 6px; margin-bottom: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--ktm-blue); outline-offset: 0; border-color: var(--ktm-blue); }
.btn { border: none; border-radius: 10px; padding: 11px 18px; font-weight: 600; cursor: pointer; background: var(--ktm-blue); color: #fff; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: var(--ktm-blue-dark); }
a.btn { text-decoration: none; }
.btn.full { width: 100%; justify-content: center; }
.btn.secondary { background: var(--ktm-blue-light); color: var(--ktm-blue-dark); }
.btn.secondary:hover { background: #D5E5F4; }
.btn.yellow { background: var(--ktm-yellow); color: var(--navy); }
.btn.yellow:hover { background: #E6BC00; }
.btn.danger { background: #FDECEC; color: var(--bad); }
.btn.ghost { background: transparent; color: var(--ktm-blue); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn.active { outline: 2px solid var(--ktm-yellow); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.demo-accounts { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 14px; font-size: 13px; color: var(--muted); }
.demo-accounts table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.demo-accounts td { padding: 4px 0; }
.demo-accounts code { background: var(--bg); padding: 2px 6px; border-radius: 6px; color: var(--ink); }
.login-footer { font-size: 12px; color: #8FA6BF; }
.error { color: var(--bad); font-size: 13px; margin-bottom: 10px; min-height: 18px; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #DCE6F2; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; gap: 12px; align-items: center; }
.sidebar .brand img { height: 40px; background: #fff; border-radius: 6px; padding: 4px 8px; }
.sidebar .brand b { display: block; font-size: 14px; color: #fff; }
.sidebar .brand span { font-size: 11.5px; color: #8FA6BF; }
.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav .nav-label { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: #6E87A3; padding: 12px 10px 6px; }
.nav a { color: #DCE6F2; text-decoration: none; padding: 10px 12px; border-radius: 10px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,0.08); }
.nav a.active { background: var(--ktm-blue); color: #fff; box-shadow: inset 4px 0 0 var(--ktm-yellow); }
.nav a .ico { width: 22px; text-align: center; }
.sidebar .user-box { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 13px; }
.sidebar .user-box b { color: #fff; display: block; }
.sidebar .user-box .role { display: inline-block; background: var(--ktm-yellow); color: var(--navy); font-weight: 700; font-size: 11px; padding: 2px 8px; border-radius: 999px; margin-top: 4px; text-transform: uppercase; }
.sidebar .version { padding: 10px 16px 14px; font-size: 11.5px; color: #6E87A3; line-height: 1.5; }
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { background: #fff; border-bottom: 3px solid var(--ktm-yellow); box-shadow: inset 0 -4px 0 var(--ktm-blue); padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar h1 { font-size: 21px; line-height: 1.15; letter-spacing: -0.2px; }
.topbar .crumb { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase; background: var(--ktm-yellow); color: var(--navy); padding: 3px 10px; border-radius: 999px; margin-bottom: 5px; }
.topbar .crumb:empty { display: none; }
.page-head { display: flex; align-items: center; gap: 14px; }
.page-text { display: flex; flex-direction: column; align-items: flex-start; }
.page-mark { width: 44px; height: 44px; border-radius: 12px; flex: none; background: linear-gradient(135deg, var(--ktm-blue) 0%, var(--ktm-blue-dark) 100%); position: relative; overflow: hidden; box-shadow: 0 4px 10px rgba(2, 104, 179, 0.25); }
.page-mark::before { content: ''; position: absolute; left: -10px; right: -10px; top: 50%; height: 7px; background: var(--ktm-yellow); transform: rotate(-35deg); }
.page-mark::after { content: ''; position: absolute; left: 0; bottom: 0; width: 100%; height: 5px; background: var(--ktm-yellow); }
.topbar .right { display: flex; gap: 10px; align-items: center; }
.content { padding: 24px 28px 40px; }

/* ---------- Components ---------- */
.grid { display: grid; gap: 18px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h3 { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.card h3::before { content: ''; width: 6px; height: 18px; border-radius: 3px; background: linear-gradient(180deg, var(--ktm-yellow) 0 50%, var(--ktm-blue) 50% 100%); flex: none; }
.card .hint { color: var(--muted); font-size: 13px; }
.kpi { position: relative; overflow: hidden; background: linear-gradient(135deg, var(--ktm-blue) 0%, var(--ktm-blue-dark) 100%); color: #fff; border-radius: var(--radius); padding: 18px 20px; }
.kpi::after { content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 999px; background: rgba(255, 208, 0, 0.18); }
.kpi .n { font-size: 32px; font-weight: 700; color: var(--ktm-yellow); position: relative; }
.kpi .l { color: #fff; font-size: 13px; margin-top: 2px; font-weight: 600; position: relative; }
.kpi .hint { color: #BFD3E6; position: relative; }
.kpi.yellow { background: linear-gradient(135deg, #FFD000 0%, #F2B800 100%); color: var(--navy); }
.kpi.yellow::after { background: rgba(2, 104, 179, 0.18); }
.kpi.yellow .n { color: var(--navy); } .kpi.yellow .l { color: var(--navy); } .kpi.yellow .hint { color: #5C4300; }
.kpi.navy { background: linear-gradient(135deg, var(--navy) 0%, #12294A 100%); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; background: var(--ktm-blue); color: #fff; border-bottom: 3px solid var(--ktm-yellow); padding: 10px 12px; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.5px; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #E3F4E8; color: var(--ok); }
.badge.warn { background: var(--ktm-yellow-light); color: #7A5200; }
.badge.bad { background: #FDECEC; color: var(--bad); }
.badge.blue { background: var(--ktm-blue-light); color: var(--ktm-blue-dark); }
.badge.grey { background: #EEF1F5; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.progress { height: 8px; background: #E8EDF3; border-radius: 999px; overflow: hidden; display: block; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--ktm-blue), #3B8FD1); }
.progress.ok > span { background: linear-gradient(90deg, #1E8E3E, #43B35F); }
.progress.bad > span { background: linear-gradient(90deg, #C62828, #E25353); }
.progress.warn > span { background: linear-gradient(90deg, #E6BC00, var(--ktm-yellow)); }
.progress.grey > span { background: #C9D3DF; }
.module-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.module-card .thumb { height: 120px; background: linear-gradient(135deg, var(--navy) 0%, var(--ktm-blue) 100%); display: flex; align-items: flex-end; padding: 14px 18px; color: #fff; font-weight: 700; font-size: 18px; position: relative; }
.module-card .thumb::after { content: ''; position: absolute; left: 0; bottom: 0; width: 100%; height: 6px; background: var(--ktm-yellow); }
.module-card .body { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.module-card .body p { color: var(--ink-soft); font-size: 13.5px; line-height: 1.5; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.toolbar .sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.toolbar label { font-size: 13px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.toolbar label.btn { color: #fff; font-size: 13px; }
.toolbar label.btn.secondary { color: var(--ktm-blue-dark); }
.toolbar input[type=range] { width: 130px; }
.notice { background: var(--ktm-yellow-light); border: 1px solid #F2D45C; border-radius: 10px; padding: 10px 14px; font-size: 13.5px; color: #5C4300; }
.notice.blue { background: var(--ktm-blue-light); border-color: #B9D4EC; color: var(--ktm-blue-dark); }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: none; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs button.active { color: var(--ktm-blue-dark); border-bottom-color: var(--ktm-yellow); }
.modal-bg { position: fixed; inset: 0; background: rgba(11,31,58,0.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 16px; padding: 26px; width: 100%; max-width: 520px; box-shadow: var(--shadow); }
.modal h3 { margin-bottom: 14px; }
.toast { position: fixed; right: 24px; bottom: 24px; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 60; font-size: 14px; border-left: 6px solid var(--ktm-yellow); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.mono { font-family: 'Consolas', 'Menlo', monospace; font-size: 12.5px; }
.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.list li { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; display: flex; gap: 10px; align-items: center; }
.list li.active { background: var(--ktm-blue-light); outline: 2px solid var(--ktm-blue); }
.list li.done { color: var(--muted); text-decoration: line-through; }
.list li .num { background: var(--ktm-blue); color: #fff; font-weight: 700; width: 26px; height: 26px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.list li.done .num { background: var(--ok); }

/* ---------- 3D viewer ---------- */
.viewer-wrap { display: grid; grid-template-columns: 1fr 320px; gap: 18px; }
.viewer-wrap.full { grid-template-columns: 1fr; }
.viewer-box { position: relative; background: #0f1b2d; border-radius: var(--radius); overflow: hidden; height: 620px; border: 1px solid var(--line); }
.viewer-box canvas { display: block; width: 100%; height: 100%; }
.viewer-box video.ar-feed { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.viewer-box .overlay { position: absolute; left: 12px; top: 12px; background: rgba(11,31,58,0.75); color: #fff; padding: 8px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.5; pointer-events: none; max-width: 320px; }
.viewer-box .overlay b { color: var(--ktm-yellow); }
.viewer-box .status { position: absolute; right: 12px; top: 12px; background: rgba(11,31,58,0.75); color: #fff; padding: 8px 12px; border-radius: 10px; font-size: 12.5px; }
.viewer-box .annot { position: absolute; transform: translate(-50%, -100%); background: var(--ktm-yellow); color: var(--navy); font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 8px; pointer-events: auto; white-space: nowrap; cursor: pointer; }
.viewer-box .annot::after { content: ''; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--ktm-yellow); border-bottom: 0; }
.viewer-box .measure-label { position: absolute; transform: translate(-50%, -50%); background: #fff; color: var(--navy); font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 8px; border: 2px solid var(--ktm-blue); pointer-events: none; white-space: nowrap; }
.viewer-box .drop-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #8FA6BF; font-size: 15px; pointer-events: none; text-align: center; }
.viewer-box .legend { position: absolute; left: 12px; bottom: 12px; background: rgba(11,31,58,0.75); color: #fff; padding: 8px 12px; border-radius: 10px; font-size: 12px; }
.side-panel { display: flex; flex-direction: column; gap: 14px; max-height: 620px; overflow: auto; }
.gauge { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gauge .g { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.gauge .g .v { font-size: 22px; font-weight: 700; color: var(--ktm-blue-dark); }
.gauge .g .k { font-size: 12px; color: var(--muted); }
.gauge .g.alert .v { color: var(--bad); }
.file-drop { border: 2px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; font-size: 13.5px; color: var(--muted); cursor: pointer; background: #fff; }
.file-drop:hover { border-color: var(--ktm-blue); color: var(--ktm-blue-dark); }
.format-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.format-chips span { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--ktm-blue-light); color: var(--ktm-blue-dark); }
.format-chips span.convert { background: var(--ktm-yellow-light); color: #7A5200; }

/* ---------- Schematic ---------- */
.schem-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 18px; }
.schem-box { position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; height: 640px; }
.schem-box svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.schem-box svg:active { cursor: grabbing; }
.schem-box .schem-overlay { position: absolute; left: 12px; top: 12px; display: flex; gap: 6px; }
.schem-box .schem-status { position: absolute; right: 12px; top: 12px; background: var(--navy); color: #fff; padding: 6px 12px; border-radius: 10px; font-size: 12.5px; }
.schem-box .schem-legend { position: absolute; left: 12px; bottom: 12px; background: rgba(255,255,255,0.92); border: 1px solid var(--line); padding: 8px 12px; border-radius: 10px; font-size: 12px; display: flex; gap: 14px; }
.schem-legend i { display: inline-block; width: 22px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.comp { cursor: pointer; }
.comp .body { fill: #fff; stroke: var(--navy); stroke-width: 2; }
.comp.on .body { fill: #E3F4E8; stroke: var(--ok); }
.comp.off .body { fill: #F3F6FA; stroke: #8FA6BF; }
.comp.fault .body { fill: #FDECEC; stroke: var(--bad); stroke-width: 3; }
.comp.selected .body { stroke: var(--ktm-yellow); stroke-width: 4; }
.comp text { font-size: 11px; font-weight: 600; fill: var(--ink); pointer-events: none; font-family: inherit; }
.comp .state { font-size: 10px; fill: var(--muted); font-weight: 500; }
.wire { fill: none; stroke: #9AA9BA; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.wire.live { stroke: var(--ktm-blue); stroke-dasharray: 10 8; animation: flow 0.9s linear infinite; }
.wire.live.pneu { stroke: #1E8E3E; }
.wire.live.mech { stroke: #C77700; }
.wire.dead { stroke: #C9D3DF; }
.wire.faulted { stroke: var(--bad); stroke-dasharray: 4 6; }
@keyframes flow { to { stroke-dashoffset: -18; } }
.status-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.status-list li { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 6px 10px; border-radius: 8px; background: var(--bg); cursor: pointer; }
.status-list li:hover { background: var(--ktm-blue-light); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 999px; margin-right: 8px; }
.dot.on { background: var(--ok); } .dot.off { background: #8FA6BF; } .dot.fault { background: var(--bad); }
.log { background: var(--navy); color: #BFD3E6; border-radius: 10px; padding: 10px 12px; font-family: Consolas, Menlo, monospace; font-size: 12px; height: 150px; overflow: auto; }
.log .t { color: var(--ktm-yellow); }

/* ---------- Print / small ---------- */
@media (max-width: 1100px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .viewer-wrap, .schem-wrap { grid-template-columns: 1fr; }
  .grid.c3, .grid.c4 { grid-template-columns: 1fr 1fr; }
}

/* ---------- Training module rows (dashboard) ---------- */
.mod-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 14px; background: linear-gradient(90deg, #F6F9FD 0%, #FFFFFF 100%); border: 1px solid var(--line); text-decoration: none; color: var(--ink); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.mod-row:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(11, 31, 58, 0.10); border-color: var(--ktm-blue); }
.mod-ico { width: 56px; height: 56px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; color: var(--ktm-yellow); background: linear-gradient(135deg, var(--ktm-blue) 0%, var(--ktm-blue-dark) 100%); box-shadow: inset 0 -4px 0 rgba(255, 208, 0, 0.9); }
.mod-row.sc .mod-ico { background: linear-gradient(135deg, var(--navy) 0%, var(--ktm-blue) 100%); }
.mod-ico svg { width: 30px; height: 30px; }
.mod-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.mod-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mod-type { font-size: 10.5px; font-weight: 800; letter-spacing: 1px; padding: 2px 8px; border-radius: 999px; background: var(--ktm-yellow); color: var(--navy); }
.mod-row.sc .mod-type { background: var(--ktm-blue-light); color: var(--ktm-blue-dark); }
.mod-meta { font-size: 12.5px; color: var(--muted); }
.mod-side { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 96px; }
.mod-ring { --p: 0; width: 46px; height: 46px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; background: conic-gradient(var(--ktm-blue) calc(var(--p) * 1%), #E8EDF3 0); position: relative; }
.mod-ring::before { content: ''; position: absolute; inset: 5px; border-radius: 999px; background: #fff; }
.mod-ring b { position: relative; font-size: 11.5px; color: var(--ink); }
.mod-ring.ok { background: conic-gradient(#1E8E3E calc(var(--p) * 1%), #E8EDF3 0); }
.mod-ring.bad { background: conic-gradient(#C62828 calc(var(--p) * 1%), #FDECEC 0); }
.mod-ring.warn { background: conic-gradient(var(--ktm-yellow) calc(var(--p) * 1%), #E8EDF3 0); }
.mod-ring.grey { background: conic-gradient(#C9D3DF calc(var(--p) * 1%), #E8EDF3 0); }
.brand-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--navy); color: #fff; font-weight: 800; border-radius: 999px; padding: 6px 14px 6px 6px; font-size: 13px; margin-bottom: 14px; letter-spacing: .3px; }
.brand-chip span { background: var(--ktm-yellow); color: var(--navy); border-radius: 999px; padding: 3px 9px; font-size: 11.5px; }

/* ---------- User menu (topbar) ---------- */
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; }
.user-btn:hover { border-color: var(--ktm-blue); }
.avatar { width: 34px; height: 34px; border-radius: 999px; background: linear-gradient(135deg, var(--ktm-blue), var(--ktm-blue-dark)); color: var(--ktm-yellow); font-weight: 800; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; box-shadow: inset 0 -3px 0 var(--ktm-yellow); }
.um-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; text-align: left; }
.um-text b { font-size: 13.5px; color: var(--ink); } .um-text small { font-size: 11px; color: var(--ktm-blue-dark); font-weight: 700; text-transform: uppercase; letter-spacing: .8px; }
.user-btn .caret { color: var(--muted); font-size: 13px; }
.user-drop { position: absolute; right: 0; top: calc(100% + 8px); width: 250px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 30px rgba(11, 31, 58, 0.16); padding: 8px; display: none; z-index: 40; }
.user-menu.open .user-drop { display: block; }
.ud-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: flex; flex-direction: column; }
.ud-head b { font-size: 14px; } .ud-head small { color: var(--muted); font-size: 12px; }
.user-drop > button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 9px 12px; border-radius: 9px; font-weight: 600; color: var(--ink); cursor: pointer; }
.user-drop > button:hover { background: var(--ktm-blue-light); color: var(--ktm-blue-dark); }
.user-drop > button.danger { color: var(--bad); } .user-drop > button.danger:hover { background: #FDECEC; }
.ud-sep { height: 1px; background: var(--line); margin: 6px 0; }

/* ---------- Ranking and achievements ---------- */
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 34px 34px 1fr auto auto; gap: 12px; align-items: center; padding: 9px 12px; border-radius: 12px; background: var(--bg); border: 1px solid transparent; }
.rank-row.me { background: var(--ktm-blue-light); border-color: var(--ktm-blue); }
.rank-no { width: 30px; height: 30px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; background: #E8EDF3; color: var(--ink-soft); }
.rank-no.gold { background: linear-gradient(135deg, #FFD000, #F2B800); color: var(--navy); box-shadow: 0 2px 6px rgba(242, 184, 0, .5); }
.rank-no.silver { background: linear-gradient(135deg, #D9DEE5, #B8C0CC); color: var(--navy); }
.rank-no.bronze { background: linear-gradient(135deg, #E3A469, #C77C3C); color: #fff; }
.avatar.small { width: 30px; height: 30px; font-size: 11.5px; box-shadow: inset 0 -2px 0 var(--ktm-yellow); }
.rank-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.rank-main b { font-size: 13.5px; } .rank-main small { font-size: 12px; color: var(--muted); }
.rank-stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; min-width: 60px; }
.rank-stat b { font-size: 15px; color: var(--ktm-blue-dark); } .rank-stat small { font-size: 11px; color: var(--muted); }
.rank-stat b.good { color: var(--ok); } .rank-stat b.poor { color: var(--bad); }
.ach-head { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.ach-stat { background: linear-gradient(135deg, var(--ktm-blue), var(--ktm-blue-dark)); color: #fff; border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; line-height: 1.1; box-shadow: inset 0 -4px 0 var(--ktm-yellow); }
.ach-stat b { font-size: 20px; color: var(--ktm-yellow); } .ach-stat small { font-size: 11px; color: #DCEAF7; margin-top: 3px; }
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge-tile { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.badge-tile.earned { background: #FFFBE6; border-color: var(--ktm-yellow); }
.badge-tile.locked { opacity: .65; filter: grayscale(.6); }
.badge-ico { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--ktm-blue), var(--ktm-blue-dark)); color: var(--ktm-yellow); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 4px; }
.badge-tile.earned .badge-ico { background: linear-gradient(135deg, #FFD000, #F2B800); color: var(--navy); }
.badge-tile b { font-size: 13px; } .badge-tile small { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.badge-count { font-size: 11.5px; color: var(--ink-soft); font-weight: 600; margin-top: 2px; }
.badge-tile .progress { width: 100%; height: 6px; margin-top: 4px; }
@media (max-width: 1100px) { .badge-grid { grid-template-columns: 1fr 1fr; } }
