/* Messiah Dashboard — design tokens + layout */
:root {
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, ui-monospace, monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --accent: #4f8cff;
  --accent-ink: #fff;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --sidebar-w: 232px;
  --topbar-h: 56px;
  --pad: 14px;
  --fs: 13px;
  color-scheme: dark;
  --bg: #0b0d12;
  --bg2: #0f1218;
  --surface: #141821;
  --surface2: #1a1f2b;
  --surface3: #222838;
  --line: #242a38;
  --line2: #2f3648;
  --ink: #e8ebf2;
  --ink2: #a9b1c3;
  --muted: #6f7890;
  --pos: #22c38e;
  --neg: #f05a6b;
  --warn: #f5b53d;
  --info: #4f8cff;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .35);
  --overlay: rgba(5, 7, 10, .62);
  --chart-grid: #222838;
  --chart-axis: #3a4257;
}

/* theme "system" được JS phân giải thành data-theme="light|dark" */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fa;
  --bg2: #eef1f6;
  --surface: #ffffff;
  --surface2: #f6f8fb;
  --surface3: #edf0f6;
  --line: #e3e7ef;
  --line2: #d4dae6;
  --ink: #121722;
  --ink2: #4a5368;
  --muted: #7d869b;
  --pos: #0f9d6c;
  --neg: #d93f52;
  --warn: #c98800;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 18px rgba(16, 24, 40, .06);
  --overlay: rgba(15, 20, 30, .35);
  --chart-grid: #edf0f6;
  --chart-axis: #c9d0dd;
}

:root[data-density="compact"] { --pad: 10px; --fs: 12.5px; --topbar-h: 50px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font: var(--fs)/1.5 var(--font);
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.num, td, .kpi .v { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; transition: grid-template-columns .25s var(--ease); }
.app.collapsed { --sidebar-w: 64px; }
.sidebar {
  background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 16px; border-bottom: 1px solid var(--line); }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #a259ff)); color: #fff; font-weight: 700;
}
.brand .name { font-weight: 650; letter-spacing: .2px; white-space: nowrap; }
.brand .name small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; margin-top: -2px; }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav .sec { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; padding: 12px 10px 4px; white-space: nowrap; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--ink2);
  white-space: nowrap; text-decoration: none; position: relative;
}
.nav a svg { flex: none; width: 18px; height: 18px; }
.nav a:hover { background: var(--surface2); color: var(--ink); }
.nav a.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--ink); }
.nav a.active::before { content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent); }
.app.collapsed .nav .sec, .app.collapsed .nav a span, .app.collapsed .brand .name, .app.collapsed .side-foot span { display: none; }
.app.collapsed .nav a { justify-content: center; }
.side-foot { border-top: 1px solid var(--line); padding: 10px 8px; }
.side-foot button { width: 100%; justify-content: flex-start; }
.app.collapsed .side-foot button { justify-content: center; }

.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px;
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px);
}
.topbar h1 { font-size: 16px; font-weight: 600; margin: 0; white-space: nowrap; }
.topbar .crumb { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.search-btn {
  display: flex; align-items: center; gap: 8px; min-width: 240px; padding: 6px 10px; border-radius: 8px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.search-btn:hover { border-color: var(--line2); color: var(--ink2); }
.search-btn kbd { margin-left: auto; }
kbd { font: 11px var(--mono); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line2); background: var(--surface2); color: var(--ink2); }

.content { flex: 1; overflow: auto; padding: 14px 14px 40px; }
.content.editing { background-image: radial-gradient(circle, var(--line2) 1px, transparent 1px); background-size: 20px 20px; }
.page-tools { display: flex; align-items: center; gap: 8px; margin: 0 4px 10px; flex-wrap: wrap; }
.page-tools .hint { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 8px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink2); white-space: nowrap; transition: .15s var(--ease);
}
.btn:hover { border-color: var(--line2); color: var(--ink); background: var(--surface2); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.btn.danger { color: var(--neg); }
.btn.danger:hover { border-color: color-mix(in srgb, var(--neg) 50%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface2); }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn.icon.sm { width: 26px; }
.btn.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled { opacity: .5; cursor: default; }

.input, .select {
  height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  outline: none; min-width: 0;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.select { padding-right: 26px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.input.sm, .select.sm { height: 26px; font-size: 12px; }

.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 3px 10px; border-radius: 6px; cursor: pointer; color: var(--ink2); font-size: 12px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch i { width: 32px; height: 18px; border-radius: 99px; background: var(--line2); position: relative; transition: .2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .2s var(--ease); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); }

.pill { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; color: var(--ink2); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.live { background: var(--pos); box-shadow: 0 0 0 0 color-mix(in srgb, var(--pos) 60%, transparent); animation: pulse 1.8s infinite; }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--neg); }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; background: var(--surface3); color: var(--ink2); white-space: nowrap; }
.tag.pos { background: color-mix(in srgb, var(--pos) 15%, transparent); color: var(--pos); }
.tag.neg { background: color-mix(in srgb, var(--neg) 15%, transparent); color: var(--neg); }
.tag.acc { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.tag.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--muted); } .ink2 { color: var(--ink2); }
.mono { font-family: var(--mono); font-size: 12px; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

/* ------------------------------------------------------------------ widgets */
.grid-stack { min-height: 200px; }
:root { --gap: 12px; }
.grid-stack { margin: calc(var(--gap) / -2); }   /* mép ngoài thẳng hàng với thanh công cụ */
.grid-stack > .grid-stack-item > .grid-stack-item-content { inset: calc(var(--gap) / 2) !important; overflow: visible !important; transition: inset .2s var(--ease); }
.w {
  height: 100%; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: border-color .15s;
}
.w:hover { border-color: var(--line2); }
.w-head { display: flex; align-items: center; gap: 8px; padding: 9px 10px 8px var(--pad); min-height: 42px; flex: none; }
.w-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.w-title svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.w-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }
.w-tools .btn.icon.sm { opacity: .55; }
.w:hover .w-tools .btn.icon.sm, .w-tools .btn.icon.sm.on { opacity: 1; }
.w-body { flex: 1; min-height: 0; padding: 0 var(--pad) var(--pad); position: relative; overflow: auto; }
.w-body.flush { padding: 0; }
.w-body.chart { overflow: hidden; padding: 0 6px 6px; }
.chart-el { width: 100%; height: 100%; }
.editing .w-head { cursor: grab; background: color-mix(in srgb, var(--accent) 6%, transparent); }
.editing .w { border-style: dashed; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.w .rm { display: none; }
.editing .w .rm { display: inline-flex; }
.grid-stack-item.ui-draggable-dragging .w { box-shadow: 0 18px 40px rgba(0, 0, 0, .45); }
.grid-stack-placeholder > .placeholder-content { border: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent) !important; border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 8%, transparent) !important; }
/* tay cầm đổi kích thước: hiện khi rê chuột vào widget, nằm trong mép thẻ */
.grid-stack-item > .ui-resizable-se, .grid-stack-item > .ui-resizable-sw { z-index: 5; opacity: .75; bottom: calc(var(--gap) / 2) !important; }
.grid-stack-item > .ui-resizable-se { right: calc(var(--gap) / 2) !important; }
.grid-stack-item > .ui-resizable-sw { left: calc(var(--gap) / 2) !important; }
.grid-stack-item > .ui-resizable-e { right: calc(var(--gap) / 2 - 5px) !important; }
.grid-stack-item > .ui-resizable-w { left: calc(var(--gap) / 2 - 5px) !important; }
.grid-stack-item > .ui-resizable-s { bottom: calc(var(--gap) / 2 - 5px) !important; }
.grid-stack-item:hover > .ui-resizable-handle { filter: drop-shadow(0 0 1px var(--surface)); }
.grid-stack-item.ui-resizable-resizing .w, .grid-stack-item.ui-draggable-dragging .w { border-color: var(--accent); }
.w.max { position: fixed; inset: 16px; z-index: 50; }
.max-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 49; }

.state { display: grid; place-items: center; height: 100%; min-height: 80px; color: var(--muted); text-align: center; padding: 12px; }
.state.err { color: var(--neg); }
.skeleton { height: 100%; min-height: 60px; border-radius: 8px; background: linear-gradient(90deg, var(--surface2) 0%, var(--surface3) 50%, var(--surface2) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; align-content: start; }
.kpi { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface2); min-width: 0; }
.kpi .k { color: var(--muted); font-size: 11.5px; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v { font-size: 22px; font-weight: 600; letter-spacing: -.3px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v.txt { font-size: 16px; padding-top: 4px; }
.kpi .d { font-size: 11.5px; color: var(--ink2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* tables */
.tbl-wrap { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.tbl-bar { display: flex; gap: 6px; align-items: center; padding: 0 var(--pad) 8px; flex-wrap: wrap; }
.tbl-bar .grow { flex: 1; }
.tbl-scroll { flex: 1; overflow: auto; min-height: 0; border-top: 1px solid var(--line); }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.t th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: right; font-weight: 500; color: var(--muted);
  padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none;
}
table.t th:hover { color: var(--ink); }
table.t th.sorted { color: var(--ink); }
table.t th .ar { opacity: .7; margin-left: 3px; font-size: 10px; }
table.t td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.t tr:hover td { background: var(--surface2); }
table.t tr.sel td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
table.t th.l, table.t td.l { text-align: left; }
table.t td.click { cursor: pointer; }
table.t tbody tr.clickable { cursor: pointer; }
.tbl-foot { display: flex; align-items: center; gap: 8px; padding: 6px var(--pad); color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.tbl-foot .grow { flex: 1; }
.bar-cell { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); vertical-align: middle; margin-left: 6px; opacity: .8; }
.stars { color: var(--warn); letter-spacing: 1px; }

/* menus / popovers */
.menu {
  position: fixed; z-index: 200; min-width: 200px; max-height: 70vh; overflow: auto; padding: 5px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line2); box-shadow: 0 18px 44px rgba(0, 0, 0, .35); animation: pop .12s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu .mi { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 7px; cursor: pointer; color: var(--ink2); white-space: nowrap; }
.menu .mi:hover, .menu .mi.hl { background: var(--surface2); color: var(--ink); }
.menu .mi svg { width: 15px; height: 15px; }
.menu .mi .chk { width: 15px; text-align: center; color: var(--accent); }
.menu .sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu .mh { padding: 6px 10px 3px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }

/* modal / drawer */
.backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 150; animation: fade .15s; backdrop-filter: blur(2px); }
@keyframes fade { from { opacity: 0; } }
.modal {
  position: fixed; z-index: 160; left: 50%; top: 10vh; transform: translateX(-50%); width: min(720px, calc(100vw - 32px)); max-height: 80vh;
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line2); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45); animation: pop .15s var(--ease);
}
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 14px 16px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.drawer {
  position: fixed; z-index: 160; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); background: var(--surface);
  border-left: 1px solid var(--line2); box-shadow: -20px 0 50px rgba(0, 0, 0, .3); display: flex; flex-direction: column;
  animation: slide .2s var(--ease);
}
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label { color: var(--ink2); font-size: 12px; font-weight: 500; }
.field .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 24px; height: 24px; border-radius: 7px; cursor: pointer; border: 2px solid transparent; }
.swatch.on { border-color: var(--ink); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.gal-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; background: var(--surface2); transition: .15s; }
.gal-item:hover { border-color: var(--accent); }
.gal-item.used { opacity: .5; }
.gal-item .t { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.gal-item .t svg { width: 15px; height: 15px; color: var(--accent); }
.gal-item .d { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* command palette */
.cmdk { top: 12vh; width: min(620px, calc(100vw - 32px)); }
.cmdk input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 15px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.cmdk .list { max-height: 50vh; overflow: auto; padding: 6px; }
.cmdk .it { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.cmdk .it.hl { background: var(--surface2); }
.cmdk .it svg { width: 16px; height: 16px; color: var(--muted); }
.cmdk .it .meta { margin-left: auto; color: var(--muted); font-size: 12px; }
.cmdk .grp { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 8px 10px 4px; }

/* toast */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--surface3); border: 1px solid var(--line2); box-shadow: var(--shadow); animation: pop .2s var(--ease); max-width: 380px; }
.toast.ok .dot { background: var(--pos); } .toast.err .dot { background: var(--neg); }

/* misc content */
.log { font: 12px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; color: var(--ink2); margin: 0; }
.log .e { color: var(--neg); } .log .w { color: var(--warn); }
.md h1, .md h2, .md h3 { font-size: 14px; margin: 14px 0 6px; }
.md h1 { font-size: 16px; }
.md table { border-collapse: collapse; margin: 8px 0; font-size: 12px; }
.md td, .md th { border: 1px solid var(--line); padding: 4px 8px; }
.md code { font: 12px var(--mono); background: var(--surface2); padding: 1px 4px; border-radius: 4px; }
.md ul { padding-left: 20px; }
.list-news { display: flex; flex-direction: column; }
.news-it { padding: 10px 0; border-bottom: 1px solid var(--line); }
.news-it:last-child { border-bottom: 0; }
.news-it .h { font-weight: 550; color: var(--ink); }
.news-it .h:hover { color: var(--accent); }
.news-it .s { color: var(--ink2); font-size: 12.5px; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.news-it .m { color: var(--muted); font-size: 11.5px; margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 12.5px; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; font-variant-numeric: tabular-nums; }
.sigcard { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.sigcard .kpi .v { font-size: 17px; }
.disclaimer { color: var(--muted); font-size: 11.5px; padding: 8px 4px 0; }
.legend-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--pad) 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); font-size: 12px; cursor: pointer; color: var(--ink2); user-select: none; }
.chip.off { opacity: .4; }
.chip:hover { border-color: var(--line2); }

.mobile-only { display: none !important; }
@media (max-width: 900px) {
  .app, .app.collapsed { grid-template-columns: 0 1fr; }
  .app.mobile-open { grid-template-columns: 232px 1fr; }
  .app.mobile-open .nav .sec, .app.mobile-open .nav a span, .app.mobile-open .brand .name { display: initial; }
  .mobile-only { display: inline-flex !important; }
  .search-btn { min-width: 0; }
  .search-btn span, .search-btn kbd, .topbar .crumb { display: none; }
}
@media (max-width: 760px) {
  .topbar { gap: 6px; padding: 0 8px; }
  .topbar h1 { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  .topbar .pill > span:last-child, .topbar .btn > span { display: none; }
  .topbar .pill { padding: 0 9px; }
  .topbar .btn:not(.icon) { width: 32px; padding: 0; justify-content: center; }
  .content { padding: 8px 6px 32px; }
  .w-head { flex-wrap: wrap; row-gap: 4px; }
  .w-tools { margin-left: 0; flex-wrap: wrap; }
  .w-sub { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* widget co giãn theo chính kích thước của nó */
.w-body { container-type: inline-size; }
@container (max-width: 980px) {
  .kpis { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 6px; }
  .kpi { padding: 7px 9px; }
  .kpi .v { font-size: 17px; }
  .kpi .v.txt { font-size: 14px; padding-top: 2px; }
}
.search-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1180px) { .search-btn { min-width: 0; } .search-btn span { display: none; } }

/* Nút lịch cạnh thanh trượt thời gian (charts.js calendarTool) */
.dz-cal-btn{position:absolute;right:6px;bottom:4px;z-index:3;width:28px;height:20px;display:grid;place-items:center;border:1px solid var(--line2);border-radius:6px;background:var(--surface2);color:var(--muted);cursor:pointer;padding:0}
.dz-cal-btn:hover{color:var(--accent);border-color:var(--accent)}
.dz-cal-btn[hidden]{display:none}
.dz-cal-pop{position:absolute;right:6px;bottom:30px;z-index:20;min-width:260px;padding:10px;border:1px solid var(--line2);border-radius:10px;background:var(--surface3);color:var(--ink);box-shadow:0 10px 30px rgba(0,0,0,.35);font-size:12px;display:flex;flex-direction:column;gap:8px}
.dz-cal-row{display:flex;gap:8px}.dz-cal-row label{display:flex;flex-direction:column;gap:3px;color:var(--muted);flex:1}
.dz-cal-row input{background:var(--surface2);color:var(--ink);border:1px solid var(--line2);border-radius:6px;padding:4px 6px;font:inherit;color-scheme:light dark}
.dz-cal-pre{display:flex;flex-wrap:wrap;gap:4px}.dz-cal-pre button,.dz-cal-act .ok{border:1px solid var(--line2);background:var(--surface2);color:var(--ink2);border-radius:6px;padding:2px 8px;cursor:pointer;font:inherit}
.dz-cal-pre button:hover{border-color:var(--accent);color:var(--accent)}
.dz-cal-act{display:flex;justify-content:space-between;align-items:center;gap:8px;color:var(--muted);font-size:11px}
.dz-cal-act .ok{background:var(--accent);color:#fff;border-color:var(--accent)}

/* biểu đồ đang nhận lăn chuột (đã bấm vào) */
.dz-armed{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 45%,transparent);border-radius:6px}

/* thanh báo có bản giao diện mới (main.js) */
.upd-bar{position:fixed;left:50%;bottom:18px;transform:translateX(-50%);z-index:9999;display:flex;align-items:center;gap:10px;padding:8px 10px 8px 14px;border:1px solid var(--accent);border-radius:10px;background:var(--surface3);color:var(--ink);box-shadow:0 10px 30px rgba(0,0,0,.35);font-size:13px}
.upd-bar button{border:1px solid var(--accent);background:var(--accent);color:#fff;border-radius:6px;padding:3px 10px;cursor:pointer;font:inherit}
.upd-bar button.x{background:transparent;color:var(--muted);border-color:var(--line2);padding:3px 7px}
