:root {
  --forest: #013B2E; --emerald: #005436; --gold: #B38B4E; --sand: #DCC6A1; --ivory: #F7F5F2; --ink: #1C1E20;
  --bg: var(--ivory); --surface: #FFFFFF; --line: #E4DED3; --muted: #5E625F; --soft: #EFEBE3; --good: #1F7A4D; --warn: #9A6A12; --bad: #A33A2B;
  --r: 10px; --sh: 0 1px 2px rgba(1,59,46,.06), 0 4px 16px rgba(1,59,46,.05);
  --mono: "IBM Plex Mono", ui-monospace, monospace; --sans: "Nunito Sans", "Avenir Next", system-ui, sans-serif; --ar: "IBM Plex Sans Arabic", "Nunito Sans", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
[dir=rtl] body, [dir=rtl] input, [dir=rtl] textarea, [dir=rtl] button, [dir=rtl] select { font-family: var(--ar); }
h1, h2, h3 { font-family: var(--mono); font-weight: 600; letter-spacing: -.01em; line-height: 1.2; margin: 0 0 .5em; }
[dir=rtl] h1, [dir=rtl] h2, [dir=rtl] h3 { font-family: var(--ar); font-weight: 700; letter-spacing: 0; }
h1 { font-size: 28px; } h2 { font-size: 19px; } h3 { font-size: 15px; }
a { color: var(--emerald); }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
button, .btn { font: inherit; font-weight: 700; border: 1px solid var(--forest); background: var(--forest); color: #fff; border-radius: 8px; padding: 9px 16px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; }
button:hover, .btn:hover { background: var(--emerald); }
button.ghost, .btn.ghost { background: transparent; color: var(--forest); }
button.ghost:hover { background: var(--soft); }
button.link { background: none; border: 0; color: var(--emerald); padding: 0; min-height: 0; font-weight: 600; text-decoration: underline; }
button.danger { background: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
input, textarea, select { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid #CFC7B8; border-radius: 8px; background: #fff; color: var(--ink); }
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 14px; margin: 10px 0; }
label.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; }

/* top bar */
.top { background: var(--forest); color: #fff; }
.top .in { max-width: 1180px; margin: 0 auto; padding: 0 16px; height: 60px; display: flex; align-items: center; gap: 16px; }
.top img { height: 26px; display: block; }
.top .tag { font-family: var(--mono); font-size: 12px; color: var(--sand); letter-spacing: .04em; text-transform: uppercase; }
[dir=rtl] .top .tag { font-family: var(--ar); text-transform: none; }
.top .sp { flex: 1; }
.top button { background: transparent; border-color: rgba(255,255,255,.35); min-height: 34px; padding: 5px 12px; font-size: 13px; }
.top button:hover { background: rgba(255,255,255,.1); }
.banner { background: var(--gold); color: #fff; text-align: center; font-size: 13px; padding: 6px 16px; font-weight: 600; }
.banner a { color: #fff; }

/* layout */
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 700; white-space: nowrap; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--forest); border-color: var(--gold); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, 1fr); }
.c12 { grid-column: span 12; } .c8 { grid-column: span 8; } .c7 { grid-column: span 7; } .c6 { grid-column: span 6; } .c5 { grid-column: span 5; } .c4 { grid-column: span 4; }
@media (max-width: 900px) { .c8, .c7, .c6, .c5, .c4 { grid-column: span 12; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--sh); min-width: 0; }
.card > h2 { display: flex; align-items: center; gap: 8px; }
.card > h2 .sp { flex: 1; }
.card > h2 button { font-size: 13px; min-height: 30px; padding: 4px 10px; }
.empty { border: 1px dashed #CFC7B8; border-radius: 8px; padding: 14px; color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--forest); }
.pill.gold { background: #F3E9D7; color: #7A5A27; } .pill.bad { background: #F6E1DD; color: var(--bad); } .pill.good { background: #DDEFE5; color: var(--good); }

/* landing */
.hero { background: var(--forest); color: #fff; }
.hero .in { max-width: 1180px; margin: 0 auto; padding: 48px 16px 56px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: 38px; color: #fff; } .hero p { color: #E7E1D6; font-size: 17px; max-width: 560px; }
.hero .eyebrow { color: var(--sand); font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.hero .btn.gold { background: var(--gold); border-color: var(--gold); }
.hero .btn.ghost { color: #fff; border-color: rgba(255,255,255,.5); }
.auth { background: #fff; color: var(--ink); border-radius: 12px; padding: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.auth h2 { margin-bottom: 4px; }
.hero .auth p { color: var(--ink); font-size: 14px; } .hero .auth p.muted { color: var(--muted); } .hero .auth p.ok { color: var(--good); }
[dir=rtl] .hero .eyebrow { font-family: var(--ar); letter-spacing: 0; }
.points { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 28px 0; }
.points .card h3 { color: var(--forest); }
@media (max-width: 900px) { .hero .in { grid-template-columns: 1fr; padding: 32px 16px; } .hero h1 { font-size: 29px; } .points { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .points { grid-template-columns: 1fr; } }
.err { color: var(--bad); font-size: 14px; margin-top: 8px; min-height: 1em; }
.ok { color: var(--good); font-size: 14px; }
.keybox { font-family: var(--mono); font-size: 20px; letter-spacing: .06em; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 14px; text-align: center; direction: ltr; word-break: break-all; }

/* dashboard */
.idcard { display: flex; gap: 18px; align-items: center; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--forest); color: var(--sand); display: grid; place-items: center; font-family: var(--mono); font-size: 22px; font-weight: 600; flex: none; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--muted); }
.facts b { color: var(--ink); font-weight: 700; }
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kpi .v { font-family: var(--mono); font-size: 26px; font-weight: 600; color: var(--forest); font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
[dir=rtl] .kpi .l { text-transform: none; letter-spacing: 0; }
@media (max-width: 700px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.meter { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; } .meter i { display: block; height: 100%; background: var(--gold); }
#map { height: 300px; border-radius: 8px; border: 1px solid var(--line); z-index: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--line); }
[dir=rtl] th { text-transform: none; }
td { padding: 7px 8px; border-bottom: 1px solid var(--soft); vertical-align: top; }
td.n, th.n { text-align: end; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--soft); }
.list li .grow { flex: 1; min-width: 0; }
.list li:last-child { border: 0; }
.iconbtn { background: none; border: 0; color: var(--muted); padding: 2px 6px; min-height: 0; font-weight: 600; font-size: 13px; }
.iconbtn:hover { background: var(--soft); color: var(--forest); }
.tl svg { width: 100%; height: auto; display: block; }

/* chat */
.chat { display: flex; flex-direction: column; height: min(72vh, 720px); }
.msgs { flex: 1; overflow-y: auto; padding: 4px 2px 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--forest); color: #fff; border-end-end-radius: 3px; }
.msg.bot { align-self: flex-start; background: var(--soft); border-end-start-radius: 3px; }
.msg.found { background: #fff; border: 1px solid var(--gold); white-space: normal; max-width: 100%; align-self: stretch; }
.compose { border-top: 1px solid var(--line); padding-top: 10px; }
.compose textarea { min-height: 56px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 99px; border: 1px solid #CFC7B8; background: #fff; color: var(--forest); cursor: pointer; min-height: 0; }
.chip.on, .chip:hover { background: var(--forest); color: #fff; border-color: var(--forest); }
.item { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 8px 0; }
.item .head { display: flex; gap: 8px; align-items: center; }
.item .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 10px; }
.item .fields label { margin: 6px 0 2px; font-size: 12px; } .item .fields input { padding: 6px 8px; font-size: 14px; }
.quote { font-size: 12px; color: var(--muted); border-inline-start: 3px solid var(--sand); padding-inline-start: 8px; margin-top: 6px; }
.drop { border: 2px dashed #CFC7B8; border-radius: 10px; padding: 12px; text-align: center; color: var(--muted); font-size: 13px; }
.drop.over { border-color: var(--gold); background: #FBF6EC; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(1,59,46,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal .box { background: #fff; border-radius: 12px; padding: 20px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 60; max-width: calc(100% - 32px); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
footer { max-width: 1180px; margin: 0 auto; padding: 0 16px 40px; color: var(--muted); font-size: 12px; }

/* print: the player CV */
#print { display: none; }
@media print {
  body.portal > *:not(#print), body.portal #app { display: none !important; }
  #print { display: block; }
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
}
.cv h1 { font-size: 24pt; color: var(--forest); margin: 0; }
.cv .bar { height: 4px; background: var(--gold); margin: 8px 0 14px; }
.cv h2 { font-size: 12pt; color: var(--forest); border-bottom: 1px solid var(--line); padding-bottom: 3px; margin-top: 16px; }
.cv table { font-size: 10pt; } .cv td, .cv th { padding: 3px 5px; }
.cv .foot { margin-top: 18px; font-size: 8pt; color: var(--muted); }
