/* FIT – sistem vizual
   Paletă: ceață de dimineață (gri-salvie rece) + petrol adânc. Calm pentru clienți, clar pentru terapeuți.
   Date: ORS = albastru, SRS = portocaliu (paletă categorială validată). Statusuri: verde/galben/coral/roșu, mereu cu simbol. */
:root {
  --bg: #edf1f0;
  --surface: #ffffff;
  --surface-2: #f6f8f8;
  --ink: #16252a;
  --ink-2: #4a5b60;
  --muted: #6c7c80;
  --line: #dbe3e2;
  --petrol: #1d4c51;
  --petrol-2: #276168;
  --petrol-ink: #e6f1ef;
  --mint: #cfe6e1;
  --accent: #1d4c51;
  --accent-soft: #e0eeeb;
  --warn: #b0452f;
  --warn-soft: #fbe7e1;
  --ors: #2a78d6;
  --srs: #eb6834;
  --st-good: #0ca30c;
  --st-warning: #fab219;
  --st-serious: #ec835a;
  --st-critical: #d03b3b;
  --st-neutral: #a9b6b8;
  --grid: #e7eded;
  --axis: #7d8c90;
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 9px;
  --display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  --sans: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
a { color: var(--petrol-2); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--display); font-weight: 650; line-height: 1.15; letter-spacing: -0.015em; }
h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); margin: 0 0 .6rem; }
h2 { font-size: 1.35rem; margin: 0 0 .7rem; }
h3 { font-size: 1.05rem; margin: 0 0 .4rem; }
p { margin: 0 0 .9rem; }
:focus-visible { outline: 3px solid var(--ors); outline-offset: 2px; border-radius: 6px; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 20px 20px 72px; }
.wrap.narrow { max-width: 460px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 22px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 220px; }

/* ---------- Butoane și câmpuri ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px solid var(--petrol); background: var(--petrol); color: #fff;
  border-radius: 999px; padding: 10px 20px; font: 600 .95rem var(--sans);
  cursor: pointer; text-decoration: none; min-height: 44px; transition: background .15s, color .15s;
}
.btn:hover { background: var(--petrol-2); border-color: var(--petrol-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--petrol); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.sm { padding: 6px 14px; min-height: 36px; font-size: .86rem; }
.btn.danger { border-color: #e2b4a8; color: var(--warn); background: transparent; }
.btn.danger:hover { background: var(--warn-soft); }
.btn.block { width: 100%; }
input[type=text], input[type=email], input[type=password], textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  font: inherit; background: var(--surface); color: var(--ink);
}
input:focus, textarea:focus { border-color: var(--petrol-2); outline: none; box-shadow: 0 0 0 3px var(--mint); }
label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.msg { padding: 11px 14px; border-radius: var(--r-sm); margin: 12px 0; font-size: .92rem; }
.msg.err { background: var(--warn-soft); color: var(--warn); }
.msg.ok { background: var(--accent-soft); color: var(--petrol); }

/* ---------- Bara de sus ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 1.2rem; color: var(--ink); text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.nav { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); padding: 4px; border-radius: 999px; }
.nav a, .nav button { border: 0; background: transparent; font: 600 .9rem var(--sans); color: var(--ink-2); padding: 7px 16px; border-radius: 999px; text-decoration: none; cursor: pointer; }
.nav a[aria-current=page] { background: var(--petrol); color: #fff; }
.nav a:hover:not([aria-current]), .nav button:hover { background: var(--surface-2); }
.who { font-size: .82rem; color: var(--muted); }

/* ---------- Taburi ORS/SRS ---------- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: rgba(255,255,255,.1); padding: 4px; border-radius: 999px; margin-bottom: 20px; }
.tabs button { border: 0; background: transparent; padding: 8px 10px; border-radius: 999px; font: 600 .95rem var(--sans); color: inherit; opacity: .75; cursor: pointer; min-height: 48px; line-height: 1.2; }
.tabs button[aria-selected=true] { background: #fff; color: var(--petrol); opacity: 1; }
.tabs small { display: block; font-weight: 400; font-size: .74rem; }

/* ---------- Scale vizuale (VAS) ---------- */
.scale { padding: 10px 0 12px; border-bottom: 1px solid rgba(255,255,255,.12); }
.scale:last-of-type { border-bottom: 0; }
.scale h3 { font-size: 1.12rem; margin: 0 0 2px; }
.scale .desc { font-size: .88rem; opacity: .75; margin-bottom: 2px; }
.vas { padding: 2px 0; }
.vas input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 40px; background: transparent; margin: 0; touch-action: pan-y; cursor: pointer; }
.vas input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: linear-gradient(90deg, #f0b9a3, #f4e3a8 50%, #9fd9c7); }
.vas input[type=range]::-moz-range-track { height: 8px; border-radius: 4px; background: linear-gradient(90deg, #f0b9a3, #f4e3a8 50%, #9fd9c7); }
.vas input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 32px; height: 32px; margin-top: -12px; border-radius: 50%; background: #fff; border: 4px solid var(--petrol-2); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.vas input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 4px solid var(--petrol-2); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.vas.untouched input[type=range]::-webkit-slider-thumb { border-color: #9aa9ab; background: #dfe7e7; }
.vas.untouched input[type=range]::-moz-range-thumb { border-color: #9aa9ab; background: #dfe7e7; }
.anchors { display: flex; justify-content: space-between; gap: 18px; font-size: .78rem; opacity: .75; }
.anchors span:last-child { text-align: right; }
.hint { font-size: .78rem; color: #ffd08a; margin-top: 4px; }

/* ---------- Pagina clientului ---------- */
.client { display: grid; gap: 20px; grid-template-columns: 1fr; align-items: start; }
.formpanel { background: var(--petrol); color: var(--petrol-ink); border-radius: var(--r-lg); padding: 22px 22px 24px; }
.formpanel h2 { color: #fff; font-size: 1.55rem; }
.formpanel .intro { opacity: .8; font-size: .95rem; }
.formpanel .btn { background: #fff; color: var(--petrol); border-color: #fff; margin-top: 8px; }
.formpanel .btn:hover { background: var(--mint); border-color: var(--mint); }
.formpanel .msg.ok { background: rgba(255,255,255,.14); color: #fff; }
.formpanel .msg.err { background: #fbe7e1; }
.formpanel .remaining { text-align: center; font-size: .82rem; opacity: .7; margin: 10px 0 0; }
.charts { display: grid; gap: 14px; grid-template-columns: 1fr; }
.chartcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 16px 10px; }
.chartcard h3 { font-family: var(--sans); font-weight: 600; font-size: .95rem; color: var(--ink-2); margin: 0 0 4px; display: flex; justify-content: space-between; gap: 10px; }
.chartcard h3 b { font-family: var(--display); font-size: 1.35rem; color: var(--ink); font-weight: 650; }
.chartcard.total h3 b { font-size: 1.9rem; }
.charts-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.charts-head h2 { margin: 0; }
@media (min-width: 980px) {
  .client { grid-template-columns: 430px 1fr; gap: 28px; }
  .formpanel { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
  .charts { grid-template-columns: 1fr 1fr; }
  .charts .total { grid-column: 1 / -1; }
}

/* ---------- Grafice comune ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: .78rem; line-height: 1.35; padding: 6px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -118%); z-index: 3; }

/* ---------- Dashboard: linkuri ---------- */
.split { display: grid; gap: 20px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 980px) { .split { grid-template-columns: 340px 1fr; } .split > aside { position: sticky; top: 20px; } }
.create { background: var(--petrol); color: var(--petrol-ink); border-radius: var(--r-lg); padding: 22px; }
.create h2 { color: #fff; }
.create input[type=text] { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.25); color: #fff; }
.create input::placeholder { color: rgba(255,255,255,.55); }
.create .btn { background: #fff; color: var(--petrol); border-color: #fff; }
.create .msg.ok { background: rgba(255,255,255,.14); color: #fff; word-break: break-all; }
.create .muted { color: rgba(230,241,239,.7); }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.list-head h2 { margin: 0; }
.link-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; margin-bottom: 10px; }
.link-item.inactive { opacity: .6; }
.link-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.link-label { font-family: var(--display); font-weight: 650; font-size: 1.12rem; }
.link-body { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 8px; }
@media (min-width: 700px) { .link-body { grid-template-columns: 1fr 170px; align-items: center; } }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--petrol); }
.badge.alert { background: var(--warn-soft); color: var(--warn); }
.badge.neutral { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.url-box { font-size: .76rem; word-break: break-all; color: var(--muted); margin: 8px 0 12px; }
.details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
table.entries { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.entries th, table.entries td { padding: 7px 5px; border-bottom: 1px solid var(--line); text-align: left; }
table.entries th { font-size: .76rem; color: var(--muted); font-weight: 600; }
table.entries td.num, table.entries th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--ink-2); margin: 4px 0 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

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

/* ---------- Bara aplicației terapeutului ---------- */
.topbar.app { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px 16px; }
.topbar.app .nav { justify-self: center; }
.tb-actions { display: flex; align-items: center; gap: 8px; }
.newlink-btn { box-shadow: 0 4px 14px rgba(29,76,81,.25); }
.newlink-btn .plus { font-size: 1.2rem; line-height: 1; margin-top: -2px; }
@media (max-width: 760px) {
  .topbar.app { grid-template-columns: 1fr auto; }
  .topbar.app .nav { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; display: grid; grid-template-columns: repeat(3, 1fr); }
  .topbar.app .nav a { padding: 7px 6px; }
  .topbar.app .nav a { text-align: center; }
  .tb-actions .who { display: none; }
  .newlink-btn { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 50; min-height: 52px; padding: 12px 22px; font-size: 1rem; box-shadow: 0 8px 24px rgba(22,37,42,.3); }
  body.has-fab main { padding-bottom: 110px; }
}

/* ---------- Fereastra „Link nou” ---------- */
.nl-dialog { border: 0; border-radius: var(--r-lg); padding: 26px; width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(22,37,42,.3); }
.nl-dialog::backdrop { background: rgba(22,37,42,.45); }
.nl-dialog h2 { margin-right: 36px; }
.nl-close-form { position: absolute; top: 14px; right: 14px; margin: 0; }
.nl-x { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface-2); font-size: 1.4rem; line-height: 1; color: var(--ink-2); cursor: pointer; }
.nl-url { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; font-size: .82rem; word-break: break-all; margin: 4px 0 14px; color: var(--ink-2); }
.brand-mark { width: 30px !important; height: 30px !important; }
