/* CSS portal: sign-in, panorama and administration. Same design tokens as the engines (central/static/styles.css). */
:root {
  --bg: #F3F5F9;
  --panel: #FFFFFF;
  --ink: #15202B;
  --muted: #5B6675;
  --line: #E1E5EC;
  --navy: #0F2C4C;
  --navy-2: #173F6B;
  --accent: #1F5FAD;
  --sky: #4FA3E0;
  --teal: #12A39A;
  --green: #1E8E3E;
  --amber: #E8A100;
  --red: #D93025;
  --grey: #8C96A3;
  --green-bg: #E6F4EA;
  --amber-bg: #FEF5DC;
  --red-bg: #FCE8E6;
  --blue-bg: #E8F0FB;
  --grey-bg: #EEF1F5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0; color: var(--navy); }
h2 { font-size: 15px; margin: 0; color: var(--navy); }
h3 { font-size: 12px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- top bar */
.topbar { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; padding: 10px 24px; background: var(--navy); color: #C9D6E8; position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; min-width: 0; }
.brand img { height: 40px; width: 40px; }            /* the CSS seal (square) */
.brand .product { border-left: 3px solid var(--sky); padding-left: 9px; display: flex; flex-direction: column; }
.brand .product strong { color: #fff; font-size: 14.5px; white-space: nowrap; }
.brand .product span { font-size: 11px; color: #8FA6C4; white-space: nowrap; }
/* the tabs keep one row: when it does not fit beside the brand the strip moves to a line of its own (basis auto, not
   0), and only a line narrower than the row (a phone) wraps it; it never shrinks into a column */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; flex: 1 1 auto; min-width: 0; }
.tabs a { color: #C9D6E8; text-decoration: none; padding: 7px 11px; border-radius: 7px; font-size: 13.5px; white-space: nowrap; flex: none; }
.tabs a:hover { background: rgba(255,255,255,.06); color: #fff; }
.tabs a.active { background: var(--navy-2); color: #fff; box-shadow: inset 0 -3px 0 var(--sky); }
.session { display: flex; align-items: center; gap: 12px; font-size: 12.5px; margin-left: auto; }
.session .who { color: #fff; font-weight: 600; }
.session .logout { color: #8FA6C4; }
.session .logout:hover { color: #fff; }
.lang-switch { display: inline-flex; }
.lang-switch a { font-size: 12px; font-weight: 600; border: 1px solid rgba(143,166,196,.5); color: #8FA6C4; padding: 3px 9px; text-decoration: none; }
.lang-switch a:first-child { border-radius: 6px 0 0 6px; }
.lang-switch a:last-child { border-radius: 0 6px 6px 0; border-left: none; }
.lang-switch a:hover { color: #fff; }
.lang-switch a.on { background: var(--sky); color: var(--navy); border-color: var(--sky); }

/* ---------- page */
.view { padding: 22px 24px 36px; max-width: 1440px; width: 100%; margin: 0 auto; flex: 1; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.badge-synth { font-size: 11px; font-weight: 600; color: #7A5B00; background: var(--amber-bg); border: 1px solid #F3D98A; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 14px 18px 0; }
.card-head .src { font-size: 11.5px; color: var(--muted); }
.card-body { padding: 12px 18px 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card { margin-bottom: 16px; }
.error-text { color: var(--red); background: var(--red-bg); border-radius: 7px; padding: 8px 10px; margin: 0; }
.banner { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }
.banner.warn { background: var(--amber-bg); border: 1px solid #F3D98A; color: #5C4400; }

/* ---------- totals and stats */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; border-top: 4px solid var(--grey); }
.tile .l, .stat .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 28px; font-weight: 700; color: var(--navy); margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile .s, .stat .s { font-size: 12px; color: var(--muted); }
.area-sub { margin: 0 0 12px; color: var(--muted); font-size: 12.5px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { border: 1px solid var(--line); border-top: 3px solid var(--grey); border-radius: 8px; padding: 9px 11px; min-width: 0; }
.stat .v { font-size: 19px; font-weight: 700; color: var(--ink); margin: 3px 0 1px; font-variant-numeric: tabular-nums; }
.st-green { border-top-color: var(--green); } .st-amber { border-top-color: var(--amber); } .st-red { border-top-color: var(--red); }
.tile.st-none { border-top-color: var(--sky); }    /* after .tile and .stat: the status colour wins */
.area-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- buttons, tags */
.btn { font: inherit; font-size: 13px; border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 7px 13px; border-radius: 7px; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-block; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: #fff; color: var(--accent); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn[disabled] { opacity: .5; cursor: default; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 10px; padding: 1px 8px; background: var(--grey-bg); color: var(--muted); white-space: nowrap; }
.tag.central { background: var(--blue-bg); color: var(--accent); }
.tag.hosp { background: #E3F5F3; color: #0B6E68; }
.pill { background: var(--red); color: #fff; border-radius: 10px; font-size: 11.5px; padding: 1px 8px; font-weight: 600; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank td { vertical-align: middle; }
.rank a { font-weight: 600; text-decoration: none; }
.rank a:hover { text-decoration: underline; }
.rank-n { color: var(--muted); width: 32px; }
.bar { width: 110px; height: 8px; background: var(--grey-bg); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), var(--red)); border-radius: 4px; }
.rank-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-top: 10px; }
.rank-foot p { margin: 0; max-width: 900px; }
tr.invalid td { background: #FFF7F6; }
.flag { color: var(--red); font-size: 12px; font-weight: 600; margin-top: 3px; }
.codes .actions { text-align: right; white-space: nowrap; }

/* ---------- public context */
.ctx + .ctx { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.ctx ul { margin: 0; padding-left: 18px; }
.ctx li { margin: 0 0 6px; line-height: 1.45; }
.ctx .sources { font-size: 12px; color: var(--muted); margin: 8px 0 0; line-height: 1.6; }

/* ---------- administration */
.grid-admin { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.form { display: flex; flex-direction: column; gap: 11px; }
.form label { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.form input, .form select { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid #C9D1DD; border-radius: 7px; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
.form input:focus, .form select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form .error { color: var(--red); background: var(--red-bg); border-radius: 7px; padding: 8px 10px; font-size: 13px; }
.links { margin: 6px 0 0; padding-left: 18px; line-height: 1.9; }
.modal { position: fixed; inset: 0; background: rgba(15,44,76,.55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-box { background: var(--panel); border-radius: 12px; padding: 22px 24px; width: min(480px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal-box h2 { margin-bottom: 10px; }
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--grey-bg); border-radius: 8px; padding: 12px 14px; margin: 12px 0; }
.code-box code { font-size: 20px; font-weight: 700; letter-spacing: .06em; color: var(--navy); user-select: all; }
.warn-text { color: #7A5B00; }
.modal-actions { display: flex; justify-content: flex-end; }

/* ---------- footer */
.foot { display: flex; align-items: center; gap: 18px; padding: 16px 24px 22px; border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 11.5px; }
.foot img { height: 26px; width: auto; flex-shrink: 0; }
.foot p { margin: 0; max-width: 1000px; line-height: 1.5; }

/* ---------- sign-in */
body.login-page { display: grid; place-items: center; background: var(--navy); padding: 16px; }
.login { position: relative; width: min(420px, 100%); background: var(--panel); border-radius: 14px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-head { background: var(--navy-2); padding: 46px 28px 20px; position: relative; }
.login-head .partner { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto 20px; }
.login-head .app { border-left: 3px solid var(--sky); padding-left: 9px; color: #fff; }
.login-head .app strong { display: block; font-size: 17px; }
.login-head .app span { font-size: 12px; color: #8FA6C4; }
.login-head .lang-switch { position: absolute; top: 12px; right: 14px; }
.login-mark { padding: 18px 28px 0; }
.login-mark img { display: block; width: 132px; height: 132px; margin: 0 auto; }
.login form { padding: 18px 28px 22px; display: flex; flex-direction: column; gap: 12px; }
.login label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.login input { font: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid #C9D1DD; border-radius: 8px; letter-spacing: .04em; }
.login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.login .btn { padding: 10px 14px; font-size: 14px; }
.login .error { color: var(--red); background: var(--red-bg); border-radius: 7px; padding: 8px 10px; font-size: 13px; }
.login .note { font-size: 11.5px; color: var(--muted); text-align: center; padding: 0 28px 20px; margin: 0; line-height: 1.5; }
.login .lead { margin: 0; font-size: 15px; color: var(--ink); }
.login .back { text-align: center; font-size: 13px; }

/* ---------- narrow screens */
@media (max-width: 1100px) {
  .grid-2, .grid-admin { grid-template-columns: minmax(0, 1fr); }      /* minmax: a long option never widens the page */
}
@media (max-width: 860px) {
  .topbar { position: static; }         /* as in both engines: a two-line bar does not follow the scroll */
}
@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .brand img { height: 32px; width: 32px; }
  .brand .product span { display: none; }
  .view { padding: 16px 16px 28px; }
  .tiles, .stats { grid-template-columns: 1fr 1fr; }
  .tile .v { font-size: 22px; }
  .page-head { flex-direction: column; }
  .rank-foot { flex-direction: column; }
  .foot { flex-direction: column; align-items: flex-start; padding: 16px; }
}
@media (max-width: 460px) {
  .tiles, .stats { grid-template-columns: 1fr; }
  .brand .product { display: none; }        /* the page title names the screen */
}
