:root {
  --navy: #16323F; --red: #E31E24; --red-d: #b8161b; --orange: #E8833A; --gray: #6E6E6E;
  --bg: #F4F6F8; --card: #fff; --line: #E3E8ED; --text: #16323F; --muted: #5d6b75;
  --ok: #1E7B34; --warn: #b45309; --bad: #b91c1c;
  --radius: 14px; --shadow: 0 1px 2px rgba(22,50,63,.06), 0 4px 16px rgba(22,50,63,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--navy); }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; }
.top .in { max-width: 1040px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { color: #fff; text-decoration: none; font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand small { font-weight: 500; opacity: .7; font-size: 12px; }
.top nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.top nav a, .top nav button { color: #dbe6ec; text-decoration: none; background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.top nav a.active, .top nav a:hover, .top nav button:hover { background: rgba(255,255,255,.1); color: #fff; }
.lang-sw { border: 1px solid rgba(255,255,255,.3) !important; }
@media (max-width: 640px) { .top nav .nl { display: none; } }

/* Bottom tab bar on phones */
.tabs { display: none; }
@media (max-width: 640px) {
  .tabs { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabs a { flex: 1; text-align: center; padding: 8px 4px 10px; font-size: 11px; color: var(--muted); text-decoration: none; }
  .tabs a span { display: block; font-size: 20px; line-height: 1.2; }
  .tabs a.active { color: var(--red); font-weight: 700; }
  main { padding-bottom: 84px !important; }
}

main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { font-size: clamp(22px, 4vw, 30px); line-height: 1.2; margin: 6px 0 6px; letter-spacing: -.02em; }
h2 { font-size: 19px; margin: 24px 0 10px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 700; cursor: pointer; text-decoration: none; min-height: 44px; transition: transform .05s, background .15s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-d); }
.btn-dark { background: var(--navy); color: #fff; }
.btn-ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #eef2f5; color: var(--navy); }
.pill.red { background: #fde8e8; color: var(--red-d); }
.pill.orange { background: #fdf0e6; color: #9a4d12; }
.pill.green { background: #e6f4ea; color: var(--ok); }

.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.banner.info { background: #eef5fb; border: 1px solid #cfe3f3; }
.banner.warn { background: #fff6e8; border: 1px solid #f6d7a8; }
.banner.bad { background: #fdecec; border: 1px solid #f5c2c2; }

/* Scenario cards */
.sc { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; }
.sc .ic { font-size: 28px; }
.sc p { margin: 0; color: var(--muted); font-size: 14px; }
.sc .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.lvl-tabs { display: flex; background: #e9eef2; border-radius: 10px; padding: 3px; gap: 3px; }
.lvl-tabs button { flex: 1; border: 0; background: none; padding: 9px 6px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 14px; }
.lvl-tabs button.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }

/* Lesson */
.lesson ol, .lesson ul { padding-left: 20px; margin: 6px 0 0; }
.lesson li { margin: 4px 0; }
.phrase { background: #f6f8fa; border-left: 3px solid var(--orange); padding: 8px 10px; border-radius: 6px; margin: 6px 0; font-size: 15px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

/* Practice room */
.room { display: flex; flex-direction: column; height: calc(100dvh - 60px); max-width: 760px; margin: 0 auto; }
@media (max-width: 640px) { .room { height: calc(100dvh - 56px); } }
.room-head { padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.room-head .who { font-weight: 700; }
.room-head .muted { color: var(--muted); font-size: 13px; }
.chat { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 16px; font-size: 15px; white-space: pre-wrap; }
.msg.owner { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.agent { background: var(--navy); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.interim { opacity: .6; font-style: italic; }
.msg .lbl { display: block; font-size: 11px; font-weight: 700; opacity: .65; margin-bottom: 2px; text-transform: uppercase; letter-spacing: .04em; }
.outcome { align-self: center; font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px; }
.composer { background: #fff; border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 44px; max-height: 140px; font-size: 16px; }
.mic { width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--red); color: #fff; font-size: 26px; cursor: pointer; box-shadow: 0 6px 18px rgba(227,30,36,.35); flex: none; }
.mic.listening { animation: pulse 1.2s infinite; background: var(--red-d); }
.mic.speaking { background: var(--navy); box-shadow: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(227,30,36,.5); } 70% { box-shadow: 0 0 0 16px rgba(227,30,36,0); } 100% { box-shadow: 0 0 0 0 rgba(227,30,36,0); } }
.voice-bar { flex-direction: column; align-items: center; gap: 6px; }
.voice-bar .hint { font-size: 13px; color: var(--muted); text-align: center; }
.typing { display: inline-flex; gap: 3px; } .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--gray); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }

/* Results */
.score-ring { width: 128px; height: 128px; border-radius: 50%; display: grid; place-items: center; font-size: 38px; font-weight: 800; margin: 0 auto; }
.bars { display: grid; gap: 10px; }
.bar .top-line { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; }
.bar .track { height: 10px; background: #e9eef2; border-radius: 999px; overflow: hidden; margin-top: 4px; }
.bar .fill { height: 100%; border-radius: 999px; }
.bar .note { font-size: 13px; color: var(--muted); margin-top: 3px; }
.better { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.better .no { color: var(--bad); text-decoration: line-through; font-size: 14px; }
.better .yes { color: var(--ok); font-weight: 600; margin-top: 4px; }

/* Plans */
.plans { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.plan { text-align: center; }
.plan .price { font-size: 36px; font-weight: 800; margin: 6px 0; }
.plan .price small { font-size: 15px; font-weight: 600; color: var(--muted); }
.plan.best { border: 2px solid var(--red); }
.fine { font-size: 13px; color: var(--muted); }

/* Forms */
.form { max-width: 420px; margin: 24px auto; }
label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff; font-size: 16px; min-height: 44px; }
input:focus, textarea:focus, select:focus { outline: 2px solid #9cc3dd; border-color: #9cc3dd; }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; min-height: 1em; }
.okmsg { color: var(--ok); font-size: 14px; margin-top: 10px; }

/* Tables (admin, history) */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #f6f8fa; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.kpi .v { font-size: 26px; font-weight: 800; }
.kpi .k { font-size: 13px; color: var(--muted); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.spark div { flex: 1; background: var(--orange); border-radius: 3px 3px 0 0; min-height: 2px; }

.loading { text-align: center; color: var(--muted); padding: 40px 0; }
footer.f { text-align: center; font-size: 12px; color: var(--muted); padding: 24px 16px; }
footer.f a { color: var(--muted); }
