/* Tema comună (alb/negru) + layout-ul cu meniu lateral. */
:root {
  color-scheme: dark;
  --bg: #111315; --surface: #191c1f; --surface-raised: #1e2226; --surface-soft: #22262a;
  --border: #2b3035; --border-strong: #383e44;
  --text: #f1f3f4; --text-soft: #c3c8cd; --muted: #8c949c; --muted-2: #68717a;
  --accent: #f1f3f4; --accent-contrast: #17191b;
  --success: #91c9a5; --error: #f1a5a5;
  --shadow: 0 22px 60px rgb(0 0 0 / 12%);
  --vh: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f5; --surface: #ffffff; --surface-raised: #f8f9fa; --surface-soft: #eef0f2;
  --border: #e3e6e8; --border-strong: #d4d9dd;
  --text: #17191b; --text-soft: #42494f; --muted: #717a82; --muted-2: #929aa1;
  --accent: #17191b; --accent-contrast: #ffffff;
  --success: #287a46; --error: #aa3333;
  --shadow: 0 18px 48px rgb(20 25 30 / 6%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); transition: background-color .18s, color .18s; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--text-soft); outline-offset: 3px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, p { margin-top: 0; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 10px; color: var(--muted); font-size: 10px; font-weight: 760; letter-spacing: .12em; }

/* Butoane */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 0 16px; border-radius: 10px; font-size: 13px; font-weight: 660; cursor: pointer; transition: transform .14s, filter .15s; }
.button:active { transform: translateY(1px); }
.button svg { width: 16px; height: 16px; }
.button-primary { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-contrast); }
@media (hover: hover) { .button-primary:hover { filter: brightness(.92); } }
.button:disabled { border-color: var(--border-strong); background: var(--surface-soft); color: var(--muted); cursor: wait; filter: none; }

/* Aspect + limbă */
.controls { display: flex; align-items: center; gap: 8px; }
.theme-toggle, .lang { min-height: 36px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.theme-toggle { display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; color: var(--text-soft); font-size: 12px; cursor: pointer; }
@media (hover: hover) { .theme-toggle:hover { background: var(--surface-soft); border-color: var(--border-strong); } }
.theme-toggle svg { width: 15px; height: 15px; }
.theme-toggle .icon-sun, :root[data-theme="light"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
.lang { display: inline-flex; padding: 3px; gap: 2px; }
.lang button { min-width: 34px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; cursor: pointer; }
.lang button.is-active { background: var(--accent); color: var(--accent-contrast); }

/* Layout aplicație */
.shell { display: grid; grid-template-columns: 300px 1fr; min-height: var(--vh); }
.sidebar { position: sticky; top: 0; height: var(--vh); display: flex; flex-direction: column; padding: 32px 22px 22px; border-right: 1px solid var(--border); background: var(--surface); }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 0 14px 40px; font-size: 18px; font-weight: 740; letter-spacing: -.03em; }
.side-brand .muted { font-weight: 500; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1.5px solid var(--text-soft); border-radius: 11px; font-size: 22px; font-weight: 760; }
.side-label { padding: 0 14px; color: var(--muted); font-size: 10px; font-weight: 760; letter-spacing: .14em; }
.side-nav { display: grid; gap: 6px; }
.nav-item { text-transform: uppercase; letter-spacing: .02em; }
.nav-item { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 16px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--text-soft); font-size: 14px; font-weight: 560; text-align: left; cursor: pointer; }
@media (hover: hover) { .nav-item:hover { background: var(--surface-soft); } }
.nav-item.is-active { border-color: var(--border); background: var(--surface-soft); color: var(--text); font-weight: 700; }
.side-nav { overflow-y: auto; }
.nav-group { display: grid; gap: 6px; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.side-admin { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.side-admin .side-label { margin-bottom: 10px; }
.soon-card { width: 100%; max-width: 560px; padding: 36px; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.soon-card h1 { font-size: 30px; font-weight: 720; letter-spacing: -.04em; }
.side-bottom { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 12px; padding: 18px 0 0; border-top: 1px solid var(--border); }
.side-bottom .controls { flex-wrap: wrap; justify-content: center; }   /* steaua, limba, aspectul și versiunea nu mai ies din bara laterală */
.side-version { margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 52px; border-bottom: 1px solid var(--border); font-size: 14px; }
.topbar strong { font-size: 15px; letter-spacing: .08em; text-transform: uppercase; }
.top-sub { color: var(--muted); font-size: 13.5px; }
.top-act { margin-left: auto; display: flex; align-items: center; gap: 10px; }
@media (max-width: 1024px), (pointer: coarse) and (max-width: 1400px) {  }
.content { flex: 1; display: grid; place-items: center; padding: 48px 52px; }

.toast { position: fixed; z-index: 5; right: 24px; bottom: 22px; max-width: min(380px, calc(100vw - 32px)); padding: 12px 16px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-raised); box-shadow: var(--shadow); font-size: 13px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .16s, transform .16s; }
.toast.is-visible { opacity: 1; transform: none; }

/* Pe calculator (> 1024 px), pagina se scalează după lățimea ecranului (--z setat de core/app.js):
   1536px → 80%, 1920px → 100%, minim 75%, maxim 125%. Telefon și tabletă verticală (≤ 1024 px): aspect de aplicație, 100%. */
@media (min-width: 1025px) and (pointer: fine), (min-width: 1401px) {
  :root { --z: .8; --vh: calc(100vh / var(--z)); }
  body { zoom: var(--z); }
}

/* Telefon: casetele de text la 16px, altfel iPhone mărește pagina la atingere și ea „fuge” stânga-dreapta */
html { -webkit-text-size-adjust: 100%; }
@media (max-width: 1024px), (pointer: coarse) and (max-width: 1400px) {
  html, body { overflow-x: hidden; }
  @supports (overflow: clip) { html, body { overflow-x: clip; } }  /* „hidden” strica bara de sus fixă pe iPhone */
  input, select, textarea { font-size: 16px !important; }
}

/* Bara de sus pe telefon (ascunsă pe calculator) */
.m-top, .nav-scrim, .tabbar { display: none; }

/* Telefon: meniul devine sertar lateral, deschis din ☰ */
@media (max-width: 1024px), (pointer: coarse) and (max-width: 1400px) {
  .shell { grid-template-columns: 1fr; }
  .m-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
  .m-top .brand-mark { width: 36px; height: 36px; font-size: 19px; }
  .m-top strong { flex: 1; min-width: 0; font-size: 15px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-burger { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--border-strong); border-radius: 11px; background: var(--surface); cursor: pointer; }
  .sidebar { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); height: 100%; overflow-y: auto; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; z-index: 40; inset: 0; background: rgb(0 0 0 / 55%); }
  .topbar { display: none; }
  .content { padding: 20px 16px; }
  /* Aspect de aplicație: bară sus compactă + bară de navigare jos; meniul complet = foaie de jos */
  .m-top { gap: 8px; padding: 10px 14px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); }
  .m-icon { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 40px; height: 40px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 99px; background: var(--surface-raised); color: var(--text-soft); font-size: 12px; cursor: pointer; }
  .m-icon svg { width: 18px; height: 18px; }
  body.has-user .m-burger { display: none; }
  body.has-user .tabbar:not([hidden]) { position: fixed; z-index: 35; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 2px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); }
  .tab { display: flex; flex: 1 1 0; flex-direction: column; gap: 3px; align-items: center; justify-content: center; height: 50px; min-width: 0; max-width: 56px; padding: 0; border-radius: 14px !important; border: 0; border-radius: 99px; background: none; color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 750; cursor: pointer; transition: background .15s, color .15s; }
  .tab span { max-width: 100%; overflow: hidden; font-size: 9.5px; font-weight: 700; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
  .tab svg { width: 20px; height: 20px; flex: 0 0 auto; }
  .tab.is-active { background: var(--surface-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
  body.has-user .content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.has-user .sidebar { top: auto; right: 0; bottom: 0; width: 100%; height: auto; max-height: 82vh; padding: 14px 18px calc(84px + env(safe-area-inset-bottom)); border-right: 0; border-radius: 24px 24px 0 0; transform: translateY(102%); z-index: 34; }
  body.has-user .sidebar::before { content: ""; display: block; width: 44px; height: 5px; margin: 0 auto 10px; border-radius: 99px; background: var(--border-strong); }
  body.has-user.nav-open .sidebar { transform: none; }
  body.has-user .side-nav { flex-shrink: 0; overflow: visible; }
  /* în foaia „Mai mult” nu repetăm paginile care sunt deja pe bara de jos */
  body.has-user .sidebar :is([data-page="groups"], [data-page="stats"], [data-page="login"], [data-page="licenses"]) { display: none; }
  body.has-user.nav-open .nav-scrim { z-index: 33; }
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
.m-icon .icon-sun, :root[data-theme="light"] .m-icon .icon-moon { display: none; } :root[data-theme="light"] .m-icon .icon-sun { display: block; }
.tab[hidden] { display: none !important; }

/* Telefon: fără zoom cu două degete / dublu-tap; butonul de ieșire (Start) e mai îngust */
@media (max-width: 1024px), (pointer: coarse) and (max-width: 1400px) {
  html { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; }
  .tab[data-tab="home"] { flex: 0 0 34px; }
  .tab span { font-size: 9px; }
}
/* Aplicația pe ecranul principal (iPhone): conținutul nu intră sub notch */
@media (max-width: 1024px), (pointer: coarse) and (max-width: 1400px) {
  .m-top { padding-top: calc(10px + env(safe-area-inset-top)); }
  .start { padding-top: calc(20px + env(safe-area-inset-top)); }
}

/* Notificarea: invizibilă când nu are mesaj; pe telefon apare deasupra barei de jos */
.toast:not(.is-visible) { visibility: hidden; }
.toast:empty { display: none; }
@media (max-width: 1024px), (pointer: coarse) and (max-width: 1400px) { .toast { left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60; text-align: center; } }
/* Logo Runner Prime (imagine) în locul literei X */
.brand-logo { padding: 0; border: 0; border-radius: 22%; object-fit: cover; background: #000; box-shadow: 0 0 0 1px rgb(255 255 255 / 14%), 0 4px 14px rgb(0 0 0 / 35%); }

/* iPhone (aplicația pe ecran): banda de sub ceas/baterie rămâne mereu acoperită, conținutul nu mai trece pe sub ea */
@media (max-width: 1024px), (pointer: coarse) and (max-width: 1400px) {
  body::before { content: ""; position: fixed; z-index: 45; top: 0; left: 0; right: 0; height: env(safe-area-inset-top, 0px); background: var(--surface); pointer-events: none; }
  .m-top { top: 0; }
}
/* Mărimea după ecran: telefoanele mici primesc totul puțin mai compact */
@media (max-width: 389px) { html { zoom: .92; } }
@media (max-width: 375.98px) { html { zoom: .88; } }   /* iPhone SE / mini */
@media (max-width: 360.98px) { html { zoom: .84; } }   /* Android mici */
@media (min-width: 390px) and (max-width: 413px) { html { zoom: .96; } }

/* Tabletă (aspect de aplicație pe ecran lat): conținutul nu se întinde pe toată lățimea */
@media (min-width: 700px) and (max-width: 1024px), (min-width: 700px) and (pointer: coarse) and (max-width: 1400px) {
  .content > section, .content > div { width: 100%; max-width: 900px; margin-left: auto; margin-right: auto; }
}
/* Monitoare foarte late: conținutul rămâne la o lățime confortabilă */
@media (min-width: 1025px) and (pointer: fine), (min-width: 1401px) { .content > section, .content > div { width: 100%; max-width: 1680px; margin-left: auto; margin-right: auto; } }
/* tras în jos de sus → reîmprospătare (doar aplicația instalată pe ecranul telefonului) */
.ptr { position: fixed; z-index: 90; top: calc(env(safe-area-inset-top) + 6px); left: 50%; display: grid; place-items: center; width: 38px; height: 38px;
       border: 1px solid var(--border-strong); border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); opacity: 0;
       transform: translate(-50%, -60px); pointer-events: none; transition: opacity .15s; }
.ptr svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ptr.on { opacity: 1; }
.ptr.go svg { stroke: var(--text); }
.ptr.spin { opacity: 1; animation: ptr-spin .7s linear infinite; }
.ptr.spin svg { stroke: var(--text); }
@keyframes ptr-spin { from { transform: translate(-50%, 48px) rotate(0deg); } to { transform: translate(-50%, 48px) rotate(360deg); } }

/* V2.1.20: cercul de reîmprospătare — fin, pe mijlocul ecranului (arcul se umple cât tragi, apoi se învârte) */
.ptr { top: 50% !important; width: 46px !important; height: 46px !important; border: 0 !important; background: color-mix(in srgb, var(--surface) 82%, transparent) !important;
       backdrop-filter: blur(10px); box-shadow: 0 10px 30px rgb(0 0 0 / 30%) !important; transform: translate(-50%, -50%) scale(.85) !important;
       transition: opacity .15s, transform .15s !important; animation: none !important; }
.ptr.on, .ptr.spin { transform: translate(-50%, -50%) scale(1) !important; }
.ptr svg { width: 26px !important; height: 26px !important; stroke: none !important; }
.ptr .ptr-track { fill: none; stroke: var(--border-strong); stroke-width: 2.5; }
.ptr .ptr-arc { fill: none; stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 12px 12px;
                stroke-dasharray: 56.5; stroke-dashoffset: calc(56.5 - 56.5 * var(--p, 0) * .8); transition: stroke-dashoffset .08s; }
.ptr.spin .ptr-arc { stroke-dashoffset: 40; animation: ptr-turn .8s linear infinite; }
@keyframes ptr-turn { to { transform: rotate(270deg); } }

/* limba: steaguri */
.flag { width: 20px; height: 14px; flex: 0 0 auto; border-radius: 3px; box-shadow: 0 0 0 1px rgb(0 0 0 / 18%); stroke: none; stroke-width: 0; overflow: hidden; }
.m-icon .flag, [data-m-lang] .flag { width: 22px; height: 15px; }
[data-lang] { display: inline-flex; align-items: center; gap: 6px; }
[data-lang] .flag { width: 16px; height: 11px; }

/* fereastra de confirmare (Închide tot, deconectare…) */
.ask { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: rgb(0 0 0 / 0%); backdrop-filter: blur(0);
       transition: background .15s, backdrop-filter .15s; }
.ask.on { background: rgb(0 0 0 / 55%); backdrop-filter: blur(6px); }
.ask-card { width: min(380px, 100%); padding: 22px; border: 1px solid var(--border-strong); border-radius: 20px; background: var(--surface);
            box-shadow: 0 24px 60px rgb(0 0 0 / 45%); transform: translateY(10px) scale(.97); opacity: 0; transition: transform .15s, opacity .15s; }
.ask.on .ask-card { transform: none; opacity: 1; }
.ask-card p { margin: 0 0 18px; font-size: 15.5px; font-weight: 650; line-height: 1.45; }
.ask-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ask-btns .button { min-height: 46px; justify-content: center; }
.ask-danger { border: 1px solid rgb(239 68 68 / 60%) !important; background: #dc2626 !important; color: #fff !important; }

/* V2.1.23: TEMA DESCHISĂ — culorile pastel (făcute pentru fundal închis) devin nuanțe închise, ca să se citească */
:root[data-theme="light"] { --green: #15803d; --red: #b91c1c; }
:root[data-theme="light"] :is(.k-open, .k-skip, .k-msg, .g-pc-note.warn) { color: #a16207; }
:root[data-theme="light"] :is(.k-be, .tg-link, .gt .gt-name a, .gt .gt-name small) { color: #0369a1; }
:root[data-theme="light"] .st-tag.k-partial { color: #6d28d9; }
:root[data-theme="light"] :is(.tu-tip b, .pl-ref b) { color: #166534; }
:root[data-theme="light"] .tu-tip > svg { color: #15803d; }

/* caseta „nu s-a putut încărca” */
.retry-box { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.retry-box .button { min-height: 42px; padding: 0 22px; }

/* V2.1.26: reîmprospătare terminată — cercul se închide complet + ✓ */
.ptr .ptr-ok { fill: none; stroke: #22c55e; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 14; stroke-dashoffset: 14; }
.ptr.done { opacity: 1; transform: translate(-50%, -50%) scale(1) !important; }
.ptr.done .ptr-arc { stroke: #22c55e; stroke-dashoffset: 0; transition: stroke-dashoffset .3s ease; animation: none; }
.ptr.done .ptr-ok { stroke-dashoffset: 0; transition: stroke-dashoffset .25s .15s ease; }
/* versiune nouă */
.upd .upd-t { display: block; margin-bottom: 8px; font-size: 17px; }
.upd .ask-card p { font-weight: 500; color: var(--text-soft); }
.ask-btns.one { grid-template-columns: 1fr; }

/* V3.0.3: câmpul din fereastra App.prompt */
.ask-in { width: 100%; height: 42px; margin: 4px 0 14px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; }
.ask-card p { white-space: pre-line; }   /* V3.0.3: rândurile goale din mesaje se văd */

/* V3.1.0: „×” în căutări (golește caseta) */
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }
.srch-wrap { position: relative; display: block; }
.srch-wrap > input { width: 100%; padding-right: 34px !important; }
.srch-wrap > .srch-x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.srch-x { flex: 0 0 auto; display: inline-grid; place-items: center; width: 24px; height: 24px; margin-left: 2px; padding: 0; border: 1px solid var(--border-strong); border-radius: 50%;
  background: color-mix(in srgb, var(--muted) 16%, var(--surface)); color: var(--text-soft); cursor: pointer; }
.srch-x[hidden] { display: none; }
.srch-x svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
@media (hover: hover) { .srch-x:hover { background: var(--border-strong); color: var(--text); } }
