/* Reusable components. Flat surfaces + borders (no stacked shadows). */
.btn { white-space:nowrap; display:inline-flex; align-items:center; justify-content:center; gap:8px; height:44px; padding:0 20px; border-radius:var(--r-sm);
  border:1px solid var(--primary); background:var(--primary); color:var(--on-primary); font-weight:600; cursor:pointer; text-decoration:none; }
.btn:hover { background:var(--primary-dark); border-color:var(--primary-dark); }
.btn-ghost { background:transparent; color:var(--primary); }
.btn-ghost:hover { background:var(--soft); border-color:var(--primary); color:var(--primary-dark); }
.btn-block { width:100%; }
.btn-sm { height:36px; padding:0 14px; }
.field label { display:block; font-weight:600; margin-bottom:6px; }
.input,.select { height:44px; padding:0 12px; border:1px solid var(--line-strong); border-radius:var(--r-sm); background:#fff; }
.input { width:100%; }
.select { height:36px; padding:0 8px; max-width:150px; }
.input:focus,.select:focus { border-color:var(--primary); }
.field .err { color:var(--danger); font-size:13px; min-height:22px; padding-top:2px; } /* reserved height */
.pw { position:relative; }
.pw .btn-sm { position:absolute; right:4px; top:4px; height:36px; }
.panel { background:var(--surface); border:1px solid var(--line); border-radius:var(--r); }
.panel-h { padding:14px 20px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:baseline; gap:12px; flex-wrap:wrap; }
.panel-h h2 { font-size:16px; letter-spacing:0; }
.panel-b { padding:20px; }
.stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); gap:var(--gap); }
.stat { background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:16px 20px; min-height:104px; }
.stat-l { display:flex; align-items:center; gap:8px; color:var(--muted); font-size:13.5px; }
.stat-l .i { color:var(--primary); }
.stat-v { font-size:24px; font-weight:700; margin-top:8px; font-variant-numeric:tabular-nums; letter-spacing:0; }
.tbl-wrap { overflow-x:auto; }
.tbl { width:100%; border-collapse:collapse; min-width:560px; }
.tbl th { text-align:left; font-size:13px; font-weight:600; color:var(--muted); padding:10px 16px; border-bottom:1px solid var(--line-strong); white-space:nowrap; }
.tbl td { padding:12px 16px; border-bottom:1px solid var(--line); height:49px; }
.tbl tr:last-child td { border-bottom:0; }
.tbl .num, .tbl th.num { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
.badge { display:inline-block; padding:2px 9px; border-radius:999px; font-size:12px; font-weight:600; background:var(--soft); color:var(--primary-dark); }
.badge-soon { background:var(--line); color:var(--muted); }
.notice { display:flex; gap:10px; align-items:flex-start; padding:12px 16px; border-radius:var(--r-sm); background:var(--soft); border:1px solid var(--line); }
.notice .i { color:var(--primary); margin-top:2px; }
.chip { display:inline-flex; align-items:center; gap:8px; height:36px; padding:0 12px; border:1px solid var(--line); border-radius:999px; font-size:14px; white-space:nowrap; max-width:260px; overflow:hidden; text-overflow:ellipsis; }
.avatar { width:34px; height:34px; border-radius:50%; background:var(--primary); color:#fff; display:grid; place-items:center; font-weight:600; font-size:13px; flex:none; }
/* Messages are popups, not toasts (js/core/ui.js showMessage). */
dialog.msg-dlg { width:min(460px,calc(100vw - 32px)); border:1px solid var(--line-strong); box-shadow:0 12px 40px rgba(0,0,0,.25); }
dialog.msg-dlg::backdrop { background:rgba(15,23,42,.45); }
.msg-h { display:flex; align-items:center; gap:10px; }
.msg-h svg { width:22px; height:22px; flex:none; }
.msg-error { color:var(--danger); } .msg-warning { color:var(--warning); } .msg-success { color:var(--success); }
.msg-body p { margin:0 0 8px; white-space:pre-line; overflow-wrap:anywhere; }
.msg-body p:last-child { margin-bottom:0; }
.msg-body:empty { display:none; }
.dlg-body:has(> .msg-body:empty) { display:none; }
.skel { background:linear-gradient(90deg,var(--line),#EEF1F5,var(--line)); background-size:200% 100%; animation:sk 1.4s linear infinite; border-radius:var(--r); }
@keyframes sk { to { background-position:-200% 0; } }
.chart svg { display:block; width:100%; height:auto; }
.chart .bar { fill:var(--primary); }
.chart .grid { stroke:var(--line); stroke-width:1; }
.chart text { fill:var(--muted); font-size:11px; font-family:var(--font); }
.chart .val { fill:var(--ink); font-weight:600; }
.ad-slot { max-width:760px; margin:28px auto 0; text-align:center; }
.ad-slot:empty { display:none; }
.ad-slot .ad-cap { display:block; color:var(--muted); font-size:11px; margin-bottom:4px; }
.ad-slot ins { min-height:100px; }
@media print { .ad-slot { display:none !important; } }

/* Popups: heading and button row stay put, only the middle scrolls (js/core/dialog-frame.js). */
/* Height: on phones and tablets "vh" counts the area behind the browser's address bar, so a tall popup's button row ended up off-screen.
   The later lines win where the browser knows them: dvh = visible height right now, svh = smallest visible height (never hidden). */
dialog.dlg { padding:0 !important; max-height:min(92vh,920px); max-height:min(92dvh,920px); max-height:min(92svh,920px); overflow:hidden; border-radius:var(--r) !important; }
dialog.dlg[open] { display:flex; flex-direction:column; }
dialog.dlg > .dlg-form { flex:1 1 auto; min-height:0; display:flex; flex-direction:column; margin:0; }
.dlg-head { flex:none; padding:16px 20px 12px; border-bottom:1px solid var(--line-strong); background:var(--soft); }
.dlg-head > h2 { margin:0 !important; }
.dlg-head > p { margin:6px 0 0 !important; }
.dlg-note { flex:none; padding:10px 20px 0; }
.dlg-note > * { margin:0 !important; }
.dlg-body { flex:1 1 auto; min-height:0; overflow:auto; padding:16px 20px; overscroll-behavior:contain; }
.dlg-foot { flex:none; padding:12px 20px max(12px,env(safe-area-inset-bottom)) !important; margin:0 !important; border-top:1px solid var(--line-strong); background:var(--soft); }
.field .select { max-width:none; height:44px; padding:0 12px; } /* selects inside forms are full width like inputs */

.chart .line { stroke:var(--primary); stroke-width:2; stroke-linejoin:round; }
.chart .area { fill:var(--primary); opacity:.1; }

/* Section colours (S61): every block on a page (panel, stat tile) gets its own hue from the theme (themes.css --s1..--s6) so blocks read as separate sections. */
.page > .panel:nth-child(6n+1), .stats > .stat:nth-child(6n+1) { --sc:var(--s1); --sc-soft:var(--s1s); }
.page > .panel:nth-child(6n+2), .stats > .stat:nth-child(6n+2) { --sc:var(--s2); --sc-soft:var(--s2s); }
.page > .panel:nth-child(6n+3), .stats > .stat:nth-child(6n+3) { --sc:var(--s3); --sc-soft:var(--s3s); }
.page > .panel:nth-child(6n+4), .stats > .stat:nth-child(6n+4) { --sc:var(--s4); --sc-soft:var(--s4s); }
.page > .panel:nth-child(6n+5), .stats > .stat:nth-child(6n+5) { --sc:var(--s5); --sc-soft:var(--s5s); }
.page > .panel:nth-child(6n+6), .stats > .stat:nth-child(6n+6) { --sc:var(--s6); --sc-soft:var(--s6s); }
.page .panel { border-top:3px solid var(--sc, var(--primary)); }
.page .panel > .panel-h { border-radius:calc(var(--r) - 3px) calc(var(--r) - 3px) 0 0; background:linear-gradient(90deg, var(--sc-soft, var(--soft)), var(--surface) 80%); }
.page .panel > .panel-h h2::before { content:""; display:inline-block; width:10px; height:10px; margin-right:8px; border-radius:3px; background:var(--sc, var(--primary)); vertical-align:baseline; }
.page .panel .tbl th { background:var(--sc-soft, transparent); color:var(--ink); }
.stats > .stat { border-left:4px solid var(--sc, var(--primary)); background:linear-gradient(135deg, var(--sc-soft, var(--soft)), var(--surface) 72%); }
.stats > .stat .stat-l .i { color:var(--sc, var(--primary)); }

/* One "Details" button per table row; its popup lists the row's facts and all its actions (core/row-actions.js). */
.ra-facts { display:grid; grid-template-columns:minmax(110px,max-content) 1fr; gap:6px 16px; margin:0 0 14px; padding:12px 14px; border:1px solid var(--line); border-left:4px solid var(--primary); border-radius:var(--r-sm); background:var(--soft); }
.ra-facts dt { color:var(--muted); font-size:13.5px; }
.ra-facts dd { margin:0; font-weight:600; overflow-wrap:anywhere; }
.ra-list { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:8px; }
.ra-list .btn { width:100%; height:42px; white-space:normal; }
@media (max-width:480px) { .ra-facts { grid-template-columns:1fr; gap:0 0; } .ra-facts dd { margin-bottom:8px; } }

/* legal links, footer note and the ads / cookies notice */
.legal-links { display:flex; flex-wrap:wrap; gap:6px 16px; font-size:13px; }
.auth .legal-links { justify-content:center; margin-top:10px; }
.legal-note { margin:10px 0 0; font-size:13px; max-width:760px; }
.pub-f .legal-links { margin-top:10px; }
.nav-legal { display:flex; flex-direction:column; gap:4px; padding:14px 16px 20px; font-size:12px; border-top:1px solid var(--line); margin-top:12px; }
.nav-legal a { color:var(--muted); }
.chk { display:flex; gap:10px; align-items:flex-start; font-size:14px; cursor:pointer; }
.chk input { margin-top:4px; width:18px; height:18px; flex:none; }
.legal-notice { position:fixed; left:12px; right:12px; bottom:12px; z-index:90; max-width:640px; margin:0 auto; display:flex; gap:12px; align-items:center; justify-content:space-between;
  background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:var(--r); box-shadow:0 6px 24px rgba(0,0,0,.18); padding:10px 14px; font-size:13px; }
@media print { .legal-notice, .nav-legal { display:none !important; } }

/* Close button (X) at the top right of every popup (js/core/dialog-frame.js) */
.dlg-head { position:relative; padding-right:56px !important; }
.dlg-x { position:absolute; top:10px; right:12px; width:34px; height:34px; border:0; border-radius:50%; background:transparent; color:var(--muted); font-size:26px; line-height:1; cursor:pointer; display:flex; align-items:center; justify-content:center; z-index:2; }
.dlg-x:hover, .dlg-x:focus-visible { background:var(--line); color:var(--ink); }
dialog.dlg-xtop > .dlg-x { top:8px; right:8px; }
.dlg-foot .dlg-closebtn { height:34px !important; min-height:0 !important; padding:0 14px !important; font-size:13px !important; background:var(--line) !important; color:var(--ink) !important; border:1px solid var(--line-strong) !important; box-shadow:none !important; }
.dlg-foot .dlg-closebtn:hover { background:var(--line-strong) !important; }

/* Details popup: actions and Close share the fixed footer */
.ra-foot { flex-wrap:wrap; align-items:center; }
.ra-foot .ra-list { display:contents; }
.ra-foot .ra-list .btn { width:auto; flex:1 1 140px; }
.ra-foot .dlg-closebtn { flex:none; margin-left:auto; }
