/* ==========================================================================
   ui/ui.css — page layout for the new pages (compact).
   Colours and fonts come from /theme.css, the top bar and menus from
   /ui/shell.css. Load order: theme.css, shell.css, ui.css, page css.
   ========================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg); color: var(--text); font-family: var(--disp);
       font-size: 13.5px; min-height: 100vh; font-variant-numeric: tabular-nums; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
html body a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.up { color: var(--buy); } .dn { color: var(--sell); } .mut { color: var(--muted); } .dim { color: var(--dim); }
html body a.lnk, .lnk { color: var(--accent); font-weight: 600; }

.page { max-width: 1440px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 40px; }

/* ---------------------------------------------------------------- heading */
.hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.hello h1 { font-size: 23px; font-weight: 700; letter-spacing: -.03em; }
.hello p { color: var(--muted); margin-top: 3px; font-size: 12.5px; }
.hello .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.ui-btn { border: 0; border-radius: 999px; padding: 8px 15px; font-weight: 700; font-size: 12.5px;
          background: var(--panel); color: var(--text); display: inline-flex; align-items: center; gap: 6px; box-shadow: var(--shadow); }
html body a.ui-btn { color: var(--text); }
.ui-btn.primary, html body a.ui-btn.primary { background: var(--accent); color: #fff; }
.ui-btn.dark { background: var(--ink); color: #fff; }
.ui-btn.danger { background: var(--sell-dim); color: var(--sell); }
.ui-btn.sm { padding: 5px 11px; font-size: 11.5px; }
.ui-btn:disabled { opacity: .55; cursor: default; }

/* ---------------------------------------------------------------- grid */
.grid { display: grid; gap: 12px; }
.grid > * { min-width: 0; }
.g-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.c-3 { grid-column: span 3; } .c-4 { grid-column: span 4; } .c-5 { grid-column: span 5; } .c-6 { grid-column: span 6; }
.c-7 { grid-column: span 7; } .c-8 { grid-column: span 8; } .c-9 { grid-column: span 9; } .c-12 { grid-column: span 12; }
@media (max-width: 1100px) { .c-4, .c-5, .c-6, .c-7, .c-8, .c-9 { grid-column: span 12; } .c-3 { grid-column: span 6; } }
@media (max-width: 560px) { .c-3 { grid-column: span 12; } }
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.box { background: var(--panel2); border-radius: var(--r-card); padding: 12px; }
.box.white { background: var(--panel); box-shadow: var(--shadow); }
.box-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.box-h h3 { font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; }
.box-h small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; font-weight: 500; }
.box-h .tools { display: flex; gap: 6px; align-items: center; }
.round { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--panel); display: grid; place-items: center; color: var(--text); }
.pane { background: var(--panel); border-radius: var(--r-tile); padding: 12px; }

.tile { background: var(--panel); border-radius: var(--r-tile); padding: 12px; position: relative; overflow: hidden; min-height: 118px;
        display: flex; flex-direction: column; }
.tile.dark { background: var(--cocoa); color: #fff; }
.tile.dark .t-lbl, .tile.dark .t-sub { color: rgba(255,255,255,.62); }
.t-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 12.5px; }
.t-ico { width: 26px; height: 26px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font-size: 12px; flex: none; }
.tile.dark .t-ico { background: rgba(255,255,255,.12); }
.t-lbl { color: var(--muted); font-size: 11.5px; margin-top: 10px; }
.t-val { font-size: 21px; font-weight: 600; letter-spacing: -.03em; margin-top: 2px; white-space: nowrap; }
.t-sub { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.t-spark { margin-top: auto; padding-top: 8px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 700px) { .tiles { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpis.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis.k6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kpis.k6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) { .kpis.k4, .kpis.k6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--panel); border-radius: var(--r-tile); padding: 11px 12px; min-width: 0; }
.kpi .t-val { font-size: 19px; }
.kpi .k-l { color: var(--muted); font-size: 11.5px; font-weight: 600; }

/* segmented buttons */
.seg { display: inline-flex; background: var(--panel); border-radius: 999px; padding: 3px; gap: 2px; max-width: 100%;
       overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 999px; font-size: 11.5px;
              font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--ink); color: #fff; }
.seg button .n { font-size: 10px; opacity: .7; margin-left: 3px; }

/* ---------------------------------------------------------------- tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; color: var(--dim); font-weight: 600; font-size: 11px; padding: 8px 9px; white-space: nowrap;
          border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 1; }
.tbl th.sort { cursor: pointer; } .tbl th.sort:hover { color: var(--text); }
.tbl th.sort.on::after { content: ' ↓'; } .tbl th.sort.on.asc::after { content: ' ↑'; }
.tbl td { padding: 8px 9px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--panel2); }
.tbl tr.sel td { background: var(--accent-soft); }
.tbl .ltp { font-weight: 600; border-radius: 6px; }
.sym { font-weight: 700; white-space: nowrap; }
.sym small { display: block; font-weight: 500; color: var(--dim); font-size: 10.5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11px;
        font-weight: 600; border: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.chip::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip.g { color: var(--buy); } .chip.r { color: var(--sell); } .chip.o { color: var(--accent); } .chip.m { color: var(--muted); }
.chip.solid.g { background: var(--buy-dim); border-color: transparent; }
.chip.solid.r { background: var(--sell-dim); border-color: transparent; }
.chip.solid.o { background: var(--accent-soft); border-color: transparent; }
.scroll { overflow: auto; max-height: 420px; border-radius: var(--r-tile); background: var(--panel); }
.scroll.tall { max-height: 560px; } .scroll.free { max-height: none; }
.empty { color: var(--dim); padding: 16px 8px; font-size: 12.5px; }
.hint { color: var(--muted); font-size: 11.5px; line-height: 1.5; }

/* score bar inside a table cell */
.sbar { display: flex; align-items: center; gap: 7px; min-width: 90px; }
.sbar i { flex: 1; height: 6px; background: var(--panel2); border-radius: 999px; overflow: hidden; position: relative; }
.sbar i b { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 999px; }
.sbar span { font-size: 11.5px; font-weight: 600; min-width: 26px; text-align: right; }

/* price flash */
.flash-up { animation: fu .8s ease-out; } .flash-dn { animation: fd .8s ease-out; }
@keyframes fu { from { background: var(--buy-dim); } to { background: transparent; } }
@keyframes fd { from { background: var(--sell-dim); } to { background: transparent; } }

/* ---------------------------------------------------------------- charts (UI.line / UI.vbars / UI.hbars / UI.donut) */
.lc { position: relative; width: 100%; user-select: none; }
.lc svg { display: block; width: 100%; overflow: visible; }
.lc .lc-y { position: absolute; right: 0; font-size: 10px; color: var(--dim); transform: translateY(-50%); background: var(--panel); padding: 0 3px; border-radius: 4px; }
.lc .lc-x { display: flex; justify-content: space-between; font-size: 10px; color: var(--dim); margin-top: 4px; }
.lc .lc-dot { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: var(--panel); border: 2px solid var(--accent);
              transform: translate(-50%, -50%); pointer-events: none; display: none; }
.lc .lc-tip, .vb-tip { position: absolute; top: 0; background: var(--text); color: var(--bg); font-size: 11px; padding: 4px 8px; border-radius: 8px;
                       white-space: nowrap; pointer-events: none; display: none; transform: translateX(-50%); z-index: 3; font-weight: 600; }

.vb { position: relative; display: flex; align-items: stretch; gap: 3px; }
.vb .c { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; position: relative; min-width: 2px; cursor: default; }
.vb .c .p, .vb .c .n { width: 100%; border-radius: 4px; }
.vb .c .p { background: var(--accent); }
.vb .c .n { background: var(--bar-off); }
.vb.signed .c { justify-content: flex-start; }
.vb.signed .c .h { display: flex; flex-direction: column; justify-content: flex-end; }
.vb.signed .c .l { display: flex; flex-direction: column; justify-content: flex-start; }
.vb.signed .c .p { background: var(--buy); }
.vb.signed .c .n { background: var(--sell); }
.vb .c:hover .p, .vb .c:hover .n { filter: brightness(1.12); }
.vb .zero { position: absolute; left: 0; right: 0; height: 1px; background: var(--dim); opacity: .5; }
.vb-x { display: flex; justify-content: space-between; font-size: 10px; color: var(--dim); margin-top: 4px; }

.hb { display: flex; flex-direction: column; gap: 7px; }
.hb-r { display: grid; grid-template-columns: minmax(70px, 30%) 1fr auto; gap: 8px; align-items: center; font-size: 12px; }
.hb-r .lb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.hb-r .lb small { display: block; color: var(--dim); font-weight: 500; font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; }
.hb-r .tr { height: 8px; background: var(--panel2); border-radius: 999px; position: relative; overflow: hidden; }
.hb-r .tr b { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: var(--accent); }
.hb-r .tr.signed::before { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--line); }
.hb-r .tr b.pos { background: var(--buy); } .hb-r .tr b.neg { background: var(--sell); }
.hb-r .vl { font-weight: 600; text-align: right; min-width: 46px; font-size: 11.5px; }

.dn-wrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dn-wrap svg { flex: none; }
.dn-leg { display: flex; flex-direction: column; gap: 6px; font-size: 12px; min-width: 0; flex: 1; }
.dn-leg div { display: flex; align-items: center; gap: 7px; }
.dn-leg i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.dn-leg span { margin-left: auto; font-weight: 600; }
.dn-c1 { font-size: 15px; font-weight: 700; fill: var(--text); } .dn-c2 { font-size: 9.5px; fill: var(--muted); }

.meter { height: 8px; background: var(--panel2); border-radius: 999px; position: relative; overflow: hidden; }
.meter b { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 999px; background: var(--accent); }

/* ---------------------------------------------------------------- phones */
@media (max-width: 720px) {
  .page { padding: calc(10px + env(safe-area-inset-top)) 12px 30px; }
  .hello h1 { font-size: 20px; }
  .hello .acts { width: 100%; }
  .box { padding: 10px; border-radius: 18px; }
  .tbl { font-size: 12px; } .tbl td, .tbl th { padding: 7px 7px; }
  .hide-sm { display: none; }
}
