/* ============================================================
 * Reports prototype — single global stylesheet.
 * NetHunt-ish: light surface, blue accent, Roboto. App grid on #app.
 * ============================================================ */
* { box-sizing: border-box; }
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --line: #e3e8ee;
  --ink: #1f2933;
  --ink-2: #5a6b7b;
  --ink-3: #90a4ae;
  --primary: #1565c0;
  --primary-soft: #e8f1fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 42, 67, .06), 0 2px 8px rgba(16, 42, 67, .05);
}
html, body { margin: 0; height: 100%; }
body { font-family: Roboto, system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; }
#app { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
button { font-family: inherit; cursor: pointer; }
h1, h2 { margin: 0; }

/* ---- Sidebar ---- */
.sidebar { background: #102a43; color: #cdd9e5; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: #fff; padding: 6px 10px 18px; }
.brand__dot { width: 12px; height: 12px; border-radius: 50%; background: #4aa3ff; box-shadow: 0 0 0 4px rgba(74,163,255,.2); }
.snav { display: flex; flex-direction: column; gap: 2px; }
.snav__item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #9fb3c8; text-decoration: none; font-size: 13.5px; cursor: pointer; }
.snav__item:hover { background: rgba(255,255,255,.06); color: #e0e8f0; }
.snav__item--active { background: var(--primary); color: #fff; }
.snav__ic { font-size: 15px; }
.snav__sep { height: 1px; background: rgba(255, 255, 255, .1); margin: 8px 12px; }

/* ---- Main / topbar ---- */
.app-main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 24px; }
.tabs { display: flex; gap: 4px; align-items: flex-end; height: 52px; }
.tab { border: none; background: none; padding: 14px 16px; font-size: 14px; color: var(--ink-2); border-bottom: 2px solid transparent; }
.tab:hover { color: var(--ink); }
.tab--active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.tab--add { color: var(--ink-3); font-size: 18px; padding: 10px 12px; }
.folderbar { display: flex; align-items: center; gap: 8px; height: 52px; font-size: 15px; font-weight: 600; color: var(--ink); }
.folderbar__ic { font-size: 16px; }
.content { overflow-y: auto; padding: 24px; flex: 1; }

/* ---- Dashboard head ---- */
.dash__head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.dash__title { font-size: 22px; font-weight: 700; }
.dash__role { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.badge-sample { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; letter-spacing: .3px; }

/* ---- Grid ---- */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; align-items: stretch; }
.grid__cell.span-1 { grid-column: span 1; }
.grid__cell.span-2 { grid-column: span 2; }
.grid__cell.span-4 { grid-column: span 4; }
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(2, 1fr); } .grid__cell.span-4 { grid-column: span 2; } }

/* ---- Widget card ---- */
.widget { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; height: 100%; }
.widget__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.widget__title { border: none; background: none; padding: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); text-align: left; }
.widget__title:hover { color: var(--primary); text-decoration: underline; }
.widget__period { border: 1px solid var(--line); border-radius: 6px; background: #fafbfc; color: var(--ink-2); font-size: 11.5px; padding: 3px 6px; }
.widget__ctrls { display: flex; align-items: center; gap: 6px; }
.widget__gear { border: 1px solid var(--line); border-radius: 6px; background: #fafbfc; color: var(--ink-2); font-size: 12px; line-height: 1; padding: 4px 6px; }
.widget__gear:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.echart { width: 100%; }

/* ---- Widget debug marker (dev "how is this built" fold) ---- */
.widget { position: relative; }
.widget__dbg { position: absolute; top: 0; right: 0; width: 20px; height: 20px; z-index: 6; cursor: help; outline: none; }
.widget__dbg-mark { position: absolute; inset: 0; clip-path: polygon(100% 0, 0 0, 100% 100%);
  background: var(--ink-3); opacity: .35; border-top-right-radius: var(--radius); pointer-events: none; transition: opacity .15s, background .15s; }
.widget:hover .widget__dbg-mark { opacity: .6; }
.widget__dbg:hover .widget__dbg-mark, .widget__dbg:focus .widget__dbg-mark { opacity: 1; background: var(--primary); }
.widget__dbg-panel { position: absolute; top: 22px; right: 0; width: 320px; max-width: 78vw;
  background: #0f2233; color: #dbe6f0; border-radius: 8px; padding: 11px 13px;
  box-shadow: 0 8px 28px rgba(16, 42, 67, .32); font-size: 11.5px; line-height: 1.5; text-align: left;
  opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .14s, transform .14s, visibility .14s; }
.widget__dbg:hover .widget__dbg-panel, .widget__dbg:focus .widget__dbg-panel { opacity: 1; visibility: visible; transform: translateY(0); }
.dbg__row { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 3px 0; }
.dbg__row + .dbg__row { border-top: 1px solid rgba(255, 255, 255, .08); }
.dbg__k { color: #7f9bb3; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; font-size: 10px; padding-top: 1px; }
.dbg__row code { color: #ffd479; font-size: 11px; word-break: break-word; }

/* ---- Scorecard ---- */
.scorecard { cursor: pointer; padding: 6px 0 4px; }
.scorecard__value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.scorecard__sub { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.scorecard:hover .scorecard__value { opacity: .82; }

/* ---- Leaderboard / detail tables ---- */
.lb, .dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.lb th, .dtable th { text-align: left; color: var(--ink-3); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.lb td, .dtable td { padding: 8px; border-bottom: 1px solid #f0f3f6; }
.lb tr { cursor: pointer; }
.lb tbody tr:hover, .dtable--click tbody tr:hover { background: var(--primary-soft); }
.right { text-align: right; }
.lb__rank { display: inline-block; width: 20px; height: 20px; line-height: 20px; text-align: center; background: var(--primary-soft); color: var(--primary); border-radius: 50%; font-size: 11px; font-weight: 700; margin-right: 8px; }

/* ---- List widget ---- */
.listw { display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow-y: auto; }
.listw__empty { color: var(--ink-3); padding: 24px 0; text-align: center; }
.listw__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: none; background: none; padding: 8px; border-radius: 8px; text-align: left; width: 100%; }
.listw__row:hover { background: var(--bg); }
.listw__main { display: flex; flex-direction: column; min-width: 0; }
.listw__title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listw__meta { font-size: 11.5px; color: var(--ink-3); }
.listw__badge { font-size: 11px; color: var(--ink-2); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 2px 8px; white-space: nowrap; }
.listw__badge--warn { background: #fdecea; border-color: #f5c6c0; color: #c62828; }

/* ---- Report page ---- */
.report__title, .reclist__title, .record__title { font-size: 22px; font-weight: 700; margin: 6px 0 16px; }
.report__viz { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 12px; }
.report__subtitle { font-size: 14px; margin: 22px 0 10px; }
.report__table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-top: 16px; overflow-x: auto; }
.report__hint { color: var(--ink-3); font-size: 12px; margin-top: 14px; }
.link-back { border: none; background: none; color: var(--primary); padding: 0; font-size: 13px; margin-bottom: 8px; }
.link-back:hover { text-decoration: underline; }

/* ---- Record list ---- */
.reclist__count { background: var(--primary-soft); color: var(--primary); border-radius: 12px; padding: 2px 10px; font-size: 14px; font-weight: 600; vertical-align: middle; margin-left: 6px; }
.dtable--click { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.reclist__empty { color: var(--ink-3); padding: 30px; text-align: center; }

/* ---- Record detail ---- */
.record__cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .record__cols { grid-template-columns: 1fr; } }
.record__panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.record__h { font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.record__empty { color: var(--ink-3); }
.frow { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid #f0f3f6; }
.frow__k { color: var(--ink-3); font-size: 12.5px; }
.frow__v { font-weight: 500; font-size: 13px; text-align: right; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps__item { position: relative; padding: 0 0 14px 18px; border-left: 2px solid var(--line); }
.steps__item:last-child { border-left-color: transparent; }
.steps__dot { position: absolute; left: -5px; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.steps__label { display: block; font-size: 13px; font-weight: 500; }
.steps__date { font-size: 11.5px; color: var(--ink-3); }

/* ---- User Activity bar ---- */
.ua-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 16px; flex-wrap: wrap; }
.ua-select { margin-left: 8px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.ua-counts { display: flex; gap: 22px; }
.ua-count { display: flex; flex-direction: column; align-items: center; }
.ua-count__n { font-size: 20px; font-weight: 700; color: var(--primary); }
.ua-count__l { font-size: 11px; color: var(--ink-3); }

/* ============================================================
 * Dashboard builder (panel model)
 * ============================================================ */
.dash__headl { display: flex; flex-direction: column; gap: 2px; }
.dash__headr { display: flex; align-items: center; gap: 8px; }
.dash__nameinput { font-size: 22px; font-weight: 700; color: var(--ink); border: none; border-bottom: 2px solid var(--primary); padding: 2px 0; outline: none; min-width: 280px; }
.tab__dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #ffab40; margin-left: 6px; vertical-align: middle; }

/* buttons */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 500; }
.btn:hover { background: var(--bg); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: #0f4f9e; }
.btn--primary:disabled { opacity: .5; cursor: not-allowed; }
.btn--ghost { color: var(--ink-2); }
.btn--danger-ghost { color: var(--lost, #c62828); border-color: #f0c4c0; }
.btn--danger-ghost:hover { background: #fdecea; }
.link { border: none; background: none; color: var(--primary); font-size: inherit; padding: 0; }
.link:hover { text-decoration: underline; }

/* panel rows */
.panels { display: flex; flex-direction: column; gap: 16px; }
.panel-row { display: flex; gap: 10px; align-items: flex-start; }
.panel { flex: 1; display: grid; gap: 16px; align-items: stretch; }
.panel--1 { grid-template-columns: 1fr; }
.panel--2 { grid-template-columns: 1fr 1fr; }
.panel--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .panel--4 { grid-template-columns: repeat(2, 1fr); } }
.slot { position: relative; min-height: 60px; }
.slot-empty { min-height: 60px; }
.slot-add { width: 100%; min-height: 130px; border: 2px dashed var(--line); border-radius: var(--radius); background: #fafbfc; color: var(--ink-3); font-size: 13px; font-weight: 500; }
.slot-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.slot-remove { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 1px solid var(--line); color: var(--ink-2); font-size: 11px; box-shadow: var(--shadow); z-index: 2; }
.slot-remove:hover { background: #fdecea; color: #c62828; border-color: #f0c4c0; }
.panel-row--edit .panel { outline: 1px dashed var(--line); outline-offset: 8px; border-radius: 6px; }
.panel-del { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 10px; align-self: stretch; }
.panel-del:hover { background: #fdecea; }

/* add-panel bar */
.panel-add { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 2px dashed var(--line); border-radius: var(--radius); background: #fafbfc; }
.panel-add__l { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.layout-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 12px; font-size: 13px; color: var(--ink); }
.layout-btn:hover { border-color: var(--primary); color: var(--primary); }
.lbox { display: inline-grid; gap: 2px; width: 30px; height: 16px; }
.lbox--1 { grid-template-columns: 1fr; } .lbox--2 { grid-template-columns: 1fr 1fr; } .lbox--4 { grid-template-columns: repeat(4, 1fr); }
.lbox i { background: var(--primary); border-radius: 2px; display: block; height: 100%; opacity: .85; }
.dash-empty { color: var(--ink-3); padding: 40px; text-align: center; border: 2px dashed var(--line); border-radius: var(--radius); }

/* widget picker modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(16, 42, 67, .42); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; width: 760px; max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 12px 48px rgba(16,42,67,.3); }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal__head h2 { font-size: 16px; }
.modal__x { border: none; background: none; font-size: 16px; color: var(--ink-3); }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal--narrow { width: 460px; }

/* ---- Widget settings form ---- */
.setform { padding: 18px 20px; overflow-y: auto; }
.setrow { padding: 12px 0; border-bottom: 1px solid var(--line); }
.setrow:last-child { border-bottom: none; }
.setrow__l { display: block; font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 6px; }
.setrow .field__i { width: 100%; }
.setrow__toggle { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.setrow__toggle input { width: 16px; height: 16px; accent-color: var(--primary); }
.setrow__toggle .setrow__l { margin-bottom: 0; }
.setrow__help { font-size: 11.5px; color: var(--ink-3); line-height: 1.45; margin: 6px 0 0; }
.setrow__multi { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.setrow__check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink); cursor: pointer; }
.setrow__check input { width: 15px; height: 15px; accent-color: var(--primary); }
.picker { display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; flex: 1; min-height: 0; }
.picker__cats { padding: 16px 20px; overflow-y: auto; border-right: 1px solid var(--line); }
.picker__cat { margin-bottom: 14px; }
.picker__catlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3); font-weight: 600; margin-bottom: 6px; }
.chip { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 10px; font-size: 12.5px; margin-bottom: 5px; color: var(--ink); }
.chip:hover { border-color: var(--primary); }
.chip--on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 500; }
.picker__form { padding: 16px 20px; overflow-y: auto; }
.field { display: block; margin-bottom: 12px; }
.field__l { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.field__i { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; font-family: inherit; }
.picker__hint { color: var(--ink-3); font-size: 11.5px; margin-top: 8px; }
.picker__placeholder { color: var(--ink-3); display: flex; align-items: center; justify-content: center; height: 100%; font-size: 13px; }
