/* ---------- themes: dark navy (default, measured from the reference) and light ---------- */
:root {
  color-scheme: dark;
  --bg: #0f172a;          /* page, charts, the open row, fills */
  --panel: #1e293b;       /* cards, menus */
  --panel2: #172133;      /* hovers, the top bar */
  --side: #1e293b;        /* the open trade's notes */
  --line: #334155;        /* separators; buttons */
  --line2: #475569;       /* stronger borders: fields, the header's bottom */
  --text: #e2e8f0;
  --text2: #cbd5e1;
  --text-hi: #ffffff;
  --muted: #94a3b8;
  --ph: #aab1bc;          /* placeholders */
  --accent: #3b82f6;
  --link: #60a5fa;
  --green: #26c281;
  --red: #ef5a6f;
  --warn: #f0b54a;
  --thead: #141d30;
  --row: #151e31;
  --row-hover: #1a2539;
  --row-sel: #182a3c;
  --row-open: #0f172a;
  --input: #0b1222;
  --btn: #334155;
  --btn-hover: #3e4c63;
  --foot: linear-gradient(90deg, #1c2738, #131c2d);
  --pill-up: rgba(31, 237, 31, 0.5);
  --pill-up-line: #1fed1f;
  --pill-down: rgba(240, 48, 48, 0.5);
  --pill-down-line: #f03030;
  --dot-market: #f97316;
  --dot-limit: #3b82f6;
  --dot-none: #64748b;
  --f-line: #253044;
  --f-edge: #313e52;
  --split-line: #1f2a3d;
  --dw-bg: #1b2537;       /* «Сводка»: widgets, measured from the reference */
  --dw-line: #334155;
  --dw-board: #343f5d;
  --dw-add: #9fb5ce;
  --dw-add-text: #0f172a;
  --dw-tip: rgba(17, 20, 26, 0.95);
  --tm-up: #047857;
  --tm-down: #8b3a36;
  --legend: #8b93a0;
  --banner: #3a1d24;
  --overlay: rgba(2, 6, 23, 0.66);
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
  --top: 56px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-table: Roboto, "Segoe UI", Arial, sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f8fafc;
  --panel2: #f1f5f9;
  --side: #f1f5f9;
  --line: #e2e8f0;
  --line2: #cbd5e1;
  --text: #0f172a;
  --text2: #334155;
  --text-hi: #0f172a;
  --muted: #64748b;
  --ph: #64748b;
  --accent: #2563eb;
  --link: #1d4ed8;
  --green: #15803d;
  --red: #b91c1c;     /* 4.5:1 on the side panel too */
  --warn: #b45309;
  --thead: #f8fafc;
  --row: #ffffff;
  --row-hover: #f8fafc;
  --row-sel: #eff6ff;
  --row-open: #f8fafc;
  --input: #ffffff;
  --btn: #e2e8f0;
  --btn-hover: #cbd5e1;
  --foot: #f8fafc;
  --dw-bg: #ffffff;
  --dw-line: #e2e8f0;
  --dw-board: #e2e8f0;
  --dw-add: #1e293b;
  --dw-add-text: #ffffff;
  --dw-tip: #ffffff;
  --tm-up: #15803d;
  --tm-down: #b91c1c;
  /* white text keeps 4.5:1 on these */
  --pill-up: #15803d;
  --pill-up-line: #22c55e;
  --pill-down: #dc2626;
  --pill-down-line: #ef4444;
  --dot-market: #ea580c;
  --dot-limit: #2563eb;
  --dot-none: #94a3b8;
  --f-line: #e2e8f0;
  --f-edge: #cbd5e1;
  --split-line: #e2e8f0;
  --legend: #64748b;
  --banner: #fef2f2;
  --overlay: rgba(15, 23, 42, 0.4);
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--input); border: 1px solid var(--line2); border-radius: 6px; padding: 8px 10px; outline: none; }
input::placeholder, textarea::placeholder { color: var(--ph); opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
button { background: var(--btn); border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button:disabled { cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
a { color: var(--link); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1.2em; margin: 8px 0 0; }
.pos { color: var(--green); } .neg { color: var(--red); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
h2 { font-size: 16px; margin: 0 0 8px; } h3 { font-size: 14px; margin: 16px 0 8px; }

#auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; } .tabs button.active { border-color: var(--accent); color: var(--link); }

/* ---------- top bar and menus ---------- */
.topbar { display: flex; align-items: center; gap: 24px; padding: 0 20px; min-height: var(--top); border-bottom: 1px solid var(--line); background: var(--panel2); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--green); font-size: 10px; font-weight: 800; line-height: 1.05; letter-spacing: .06em; text-transform: uppercase; }
.logo { width: 32px; height: 24px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 24'%3E%3Cpath d='M2 20 L9 12 L14 16 L22 5 L30 10' fill='none' stroke='%2326c281' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='22' cy='5' r='2.6' fill='%2326c281'/%3E%3C/svg%3E") no-repeat center / contain; }
.menu { display: flex; align-items: center; gap: 2px; flex: 1; flex-wrap: wrap; }
.menu > button, .menu .dd-btn { background: none; border: 1px solid transparent; color: var(--text); font-weight: 600; padding: 7px 12px; border-radius: 6px; }
.menu > button:hover, .menu .dd-btn:hover { background: var(--panel); }
.menu button.active { background: var(--panel); border-color: var(--line); }
.live-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); margin-left: 3px; vertical-align: super; }
.live-dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.chev { display: inline-block; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-3px) rotate(45deg); margin-left: 5px; opacity: .65; }
.dd { position: relative; }
.dd-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 200px; max-width: calc(100vw - 24px); max-height: 65vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px; z-index: 30; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px; text-align: left; white-space: nowrap; font-size: 13px; font-weight: 400; line-height: 1.45; }
.dd-menu > button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; white-space: nowrap; font-weight: 500; }
.dd-menu > button:hover { background: var(--line); }
.dd-menu > button.cur { color: var(--green); }
.dd-menu > button.link { color: var(--link); }
.dd-menu p { margin: 6px 10px; }
.checklist label { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.checklist label:hover { background: var(--line); }
.checklist input { accent-color: var(--accent); margin: 0; }
.filters-pop { min-width: 260px; gap: 10px; padding: 12px; }
.filters-pop label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.theme-btn { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; background: none; border: 1px solid transparent; border-radius: 6px; color: var(--text2); }
.theme-btn:hover { background: var(--panel); border-color: var(--line); }
.theme-btn .i-moon, [data-theme="light"] .theme-btn .i-sun { display: none; }
[data-theme="light"] .theme-btn .i-moon { display: block; }
.me { display: flex; align-items: center; gap: 8px; color: var(--muted); white-space: nowrap; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; color: var(--text); font-weight: 700; font-size: 13px; }
main { padding: 16px 20px; max-width: 1500px; margin: 0 auto; }

/* ---------- filter bar ---------- */
.tbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.fbtn { background: transparent; border: 1px solid transparent; color: var(--text); padding: 6px 10px; border-radius: 6px; font-weight: 500; }
.fbtn:hover { background: var(--panel); border-color: transparent; }
select.fbtn { border-color: var(--line); background: var(--panel); }
.fbtn.outline { border-color: var(--line); }
.fbtn.on { color: var(--green); }
.fbtn.chip { border-color: var(--green); color: var(--green); }
.tbar-gap { flex: 1; }
.keys-live { font-size: 13px; color: var(--muted); white-space: nowrap; }
.keys-live::before { content: '●'; margin-right: 6px; }
.keys-live.on { color: var(--text); } .keys-live.on::before { color: var(--green); }

/* ---------- tables in general ---------- */
.table-wrap { padding: 0; overflow: auto; max-height: max(360px, calc(100vh - 290px)); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; background: var(--panel2); border: 1px solid var(--line); margin-right: 4px; font-weight: 500; }
.badge.open { color: var(--link); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.empty { padding: 24px; text-align: center; color: var(--muted); white-space: normal; }

/* ---------- Мои сделки: the table, one-to-one with the reference ---------- */
main.view-trades { max-width: none; padding: 0; display: flex; flex-direction: column; height: calc(100vh - var(--top)); font-family: var(--font-table); }
main.view-trades .tbar { padding: 10px 16px 0; font-family: var(--font); }
.trades-wrap { flex: 1; min-height: 0; max-height: none; position: relative; border-top: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
#tradesTable { table-layout: fixed; min-width: 1180px; border-collapse: separate; border-spacing: 0; font-size: 12px; line-height: 1.3; }
/* column starts at 1910 px: expand 20 (centre), checkbox 56 (centre), Тикер 80, API ключ 270, В сделке 550, Сторона 724,
   Процент 880, Прибыль 1052, Объём 1254, Комиссия 1476, Вход 1652; the text columns scale with the width */
.c-x { width: 40px; } .c-ck { width: 32px; }
.c-tk { width: 9.95%; } .c-acc { width: 14.66%; } .c-dur { width: 9.11%; } .c-side { width: 8.17%; } .c-pct { width: 9.01%; }
.c-pnl { width: 10.58%; } .c-size { width: 11.62%; } .c-fee { width: 9.21%; }
/* ">" everywhere: the open trade's fills table sits inside this one. A cell's height counts its border: 50 + 1 and 44 + 1 */
#tradesTable > thead > tr > th { height: 51px; padding: 0 8px; background: var(--thead); color: var(--text); font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--line2); z-index: 6; }
#tradesTable > tbody > tr > td { height: 45px; padding: 0 8px; background: var(--row); color: var(--text); border-bottom: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; }
#tradesTable > tbody > tr[data-key] { cursor: pointer; }
#tradesTable > tbody > tr[data-key]:hover > td { background: var(--row-hover); }
#tradesTable > tbody > tr.sel[data-key] > td { background: var(--row-sel); }
#tradesTable > tbody > tr.open[data-key] > td { background: var(--row-open); }
#tradesTable > tbody > tr.open > td:first-child { box-shadow: inset 3px 0 var(--line2); }
th[data-sort] { cursor: pointer; user-select: none; }
/* the sort mark after the label: lines and an arrow, brighter on the sorted column */
th[data-sort] > .th-l::after { content: ''; display: inline-block; width: 11px; height: 10px; margin-left: 6px; vertical-align: -1px; background: currentColor; opacity: .5;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 10'%3E%3Cpath d='M.5 1.5h5.5M.5 5h4M.5 8.5h2.5M9 1v8M7.4 7.3 9 9l1.6-1.7' fill='none' stroke='%23000' stroke-width='1.1'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 10'%3E%3Cpath d='M.5 1.5h5.5M.5 5h4M.5 8.5h2.5M9 1v8M7.4 7.3 9 9l1.6-1.7' fill='none' stroke='%23000' stroke-width='1.1'/%3E%3C/svg%3E") no-repeat center / contain; }
th.sorted > .th-l::after { opacity: 1; color: var(--link); }
th.sorted[data-dir="asc"] > .th-l::after { transform: scaleY(-1); }
/* ✕ after the mark of an order other than the list's own: back to newest entry first */
.sort-x { margin-left: 2px; padding: 1px 4px; border: 0; border-radius: 4px; background: none; color: var(--link); font: inherit; font-size: 15px; line-height: 1; vertical-align: -1px; cursor: pointer; }
.sort-x:hover { color: var(--text); background: var(--row-hover); }
.icon-col { padding: 0 !important; text-align: center !important; }
.expand { display: inline-block; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 4px; vertical-align: middle; color: var(--text); background: transparent; cursor: pointer; position: relative; }
.expand::before { content: ''; position: absolute; inset: 4px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='%23000' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 4.4V1h3.4M1 1l3.4 3.4M13 4.4V1H9.6M13 1 9.6 4.4M1 9.6V13h3.4M1 13l3.4-3.4M13 9.6V13H9.6M13 13 9.6 9.6'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='%23000' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 4.4V1h3.4M1 1l3.4 3.4M13 4.4V1H9.6M13 1 9.6 4.4M1 9.6V13h3.4M1 13l3.4-3.4M13 9.6V13H9.6M13 13 9.6 9.6'/%3E%3C/svg%3E") no-repeat center / contain; }
.expand:hover { background-color: var(--btn); }
/* checkboxes: 16 px inside a 1 px border, square corners like the reference */
.ck { appearance: none; -webkit-appearance: none; display: inline-grid; place-content: center; width: 18px; height: 18px; margin: 0; padding: 0; vertical-align: middle;
  border: 1px solid var(--line); border-radius: 2px; background: transparent; cursor: pointer; }
.ck::after { content: ''; width: 10px; height: 10px; background: #fff; transform: scale(0);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 5.2 4 7.6 8.6 2.4' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 5.2 4 7.6 8.6 2.4' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain; }
.ck:checked { background: var(--accent); border-color: var(--accent); }
.ck:checked::after { transform: scale(1); }
.ck:hover { border-color: var(--line2); }
#selAll { width: 16px; height: 16px; background: var(--btn); border-color: #4b5563; }
#selAll:checked { background: var(--accent); border-color: var(--accent); }
[data-theme="light"] #selAll { border-color: var(--line2); }
.tk { font-weight: 500; letter-spacing: .01em; } .tk .badge { margin-left: 6px; }
.side { font-weight: 600; color: var(--text-hi) !important; letter-spacing: .02em; }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 11px; border-radius: 12px; border: 1px solid transparent; vertical-align: middle;
  color: #fff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill.up { background: var(--pill-up); border-color: var(--pill-up-line); }
.pill.down { background: var(--pill-down); border-color: var(--pill-down-line); }
.pill.zero { background: var(--btn); border-color: var(--line2); color: var(--text); }
/* an open trade: outlined, its numbers still move */
.pill.open { background: transparent; }
.pill.up.open { color: var(--green); } .pill.down.open { color: var(--red); }
.note-mark { color: var(--muted); margin-left: 6px; }

/* the footer: the totals in one line, the pager on the right */
.tfoot { display: flex; align-items: center; gap: 8px 16px; min-height: 34px; padding: 0 0 0 6px; border-top: 1px solid var(--line2); background: var(--foot); font-size: 12px; flex-wrap: wrap; }
.tfoot-tools { display: flex; }
.tfoot-tools button { display: grid; place-items: center; width: 32px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 0; background: var(--panel); color: var(--muted); }
.tfoot-tools button:first-child { border-radius: 4px 0 0 4px; }
.tfoot-tools button:last-child { border-radius: 0 4px 4px 0; border-left: 0; background: color-mix(in srgb, var(--btn) 70%, var(--panel)); }
.tfoot-tools button:hover:not(:disabled) { color: var(--text); }
.tfoot-tools button:disabled { opacity: .5; }
.totals { flex: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; row-gap: 2px; }
.tot { white-space: nowrap; padding: 0 6px; color: var(--text); line-height: 14px; }
.tot + .tot { border-left: 1px solid var(--muted); }
.tot b { font-weight: 600; color: var(--text); } .tot b.pos { color: var(--green); } .tot b.neg { color: var(--red); }
.tot .pill { height: 18px; margin-right: 6px; padding: 0 6px; font-size: 11px; }
.pager { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; }
.pages { display: flex; align-items: center; gap: 4px; }
.pages button { min-width: 21px; height: 23px; padding: 0 5px; border: 0; border-radius: 4px; background: none; color: var(--text); font-size: 13px; line-height: 23px; }
.pages button:hover:not(:disabled) { background: var(--panel); }
.pages button.active { background: var(--btn); }
.pages button.arrow { font-size: 18px; line-height: 20px; color: var(--muted); }
.pages button:disabled { opacity: .35; }
.pages .gap { padding: 0 6px; color: var(--text); }
#range { white-space: nowrap; }
#pageSize { height: 26px; padding: 0 4px 0 8px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px 0 0 4px; }
/* «Таблица на весь экран»: the top bar and the filters step aside */
body.tbl-full .topbar, body.tbl-full #view-trades .tbar { display: none; }
body.tbl-full main.view-trades { height: 100vh; }
body.tbl-full .trades-wrap { border-top: 0; }

/* ---------- the open trade: chart | splitter | notes and fills ---------- */
.xrow > td { padding: 0 !important; height: auto !important; background: var(--bg) !important; overflow: visible !important; cursor: default; }
.tp { --split: .502; position: sticky; left: 0; width: var(--wrap-w, 100%); height: min(540px, max(380px, var(--wrap-h, 636px) - 96px)); display: flex; background: var(--bg); color: var(--text);
  font-family: var(--font-table); font-size: 12px; line-height: 1.35; text-align: left; white-space: normal; cursor: default; }
.tp.dragging { user-select: none; cursor: col-resize; }
.tp:fullscreen { width: 100%; height: 100%; }
/* where a page element cannot go full screen (iPhone): the panel covers the page */
.tp.full { position: fixed !important; inset: 0; z-index: 70; width: auto !important; height: auto !important; min-height: 0; overflow: auto; border-radius: 0; }
.tp-chart { flex: 0 0 calc((100% - 4px) * var(--split)); min-width: 0; display: flex; flex-direction: column; container-type: inline-size; }
.tp.chart-only .tp-chart { flex: 1; }
.tp.chart-only .tp-split, .tp.chart-only .tp-side { display: none; }
.tp-top { position: relative; z-index: 5; display: flex; align-items: center; gap: 2px; height: 25px; padding: 0 4px 0 8px; }
.tp-title { margin-right: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tp-tfs { display: flex; align-items: center; gap: 2px; }
.tp-tfs > button, .tp-more { height: 23px; min-width: 28px; padding: 0 6px; border: 0; border-radius: 4px; background: none; color: var(--text); font-size: 13px; line-height: 23px; }
.tp-tfs > button:hover:not(:disabled), .tp-more:hover { background: var(--panel); }
.tp-tfs > button.active, .tp-more.active { background: var(--btn); }
.tp-tfs > button:disabled { opacity: .35; cursor: not-allowed; }
.tp-more { display: inline-flex; align-items: center; gap: 2px; min-width: 22px; padding: 0 3px; }
.tp-more svg { width: 13px; height: 13px; }
.tp-gap { flex: 1; }
.tp-btn, .tp-ico { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 23px; padding: 0 5px; border: 0; border-radius: 4px; background: none; color: var(--text); font-size: 13px; text-decoration: none; }
.tp-ico { width: 25px; padding: 0; }
.tp-btn:hover, .tp-ico:hover:not(:disabled):not([aria-disabled]) { background: var(--panel); }
.tp-btn svg, .tp-ico svg { flex: none; }
.tp-menu { min-width: 150px; }
.tp-menu.tp-right { left: auto; right: 0; }
#tpMore { min-width: 64px; }
#tpLay > button { display: flex; align-items: center; gap: 8px; }
#tpLay > button svg { visibility: hidden; color: var(--green); }
#tpLay > button.cur svg { visibility: visible; }
#tpLay > button.cur { color: var(--text); }
@container (max-width: 700px) { .tp-btn span { display: none; } }
@container (max-width: 520px) { .tp-title { display: none; } }
.tp-body { flex: 1; min-height: 0; display: flex; }
.tp-tools { flex: 0 0 36px; width: 36px; border-right: 1px solid var(--line); overflow: hidden; }
.tp-plot { position: relative; flex: 1; min-width: 0; isolation: isolate; overflow: hidden; }
.tp-canvas { position: absolute; inset: 0; }
.tp-legend { position: absolute; left: 6px; top: 8px; right: 70px; z-index: 4; pointer-events: none; color: var(--legend); font-size: 11px; line-height: 15px; }
.tp-ohlc { display: flex; flex-wrap: wrap; column-gap: 6px; }
.tp-ohlc b { font-weight: 400; }
.tp-rows { margin-top: 3px; }
.tp-lrow { display: flex; align-items: center; gap: 4px; height: 18px; font-size: 12px; }
.tp-lrow span { margin-right: 4px; }
.tp-lrow button { pointer-events: auto; display: grid; place-items: center; width: 17px; height: 17px; padding: 0; border: 0; border-radius: 3px; background: none; color: var(--legend); }
.tp-lrow button:hover { color: var(--text); background: color-mix(in srgb, var(--panel) 80%, transparent); }
.tp-lrow button svg { width: 13px; height: 13px; }
.tp-lrow.off span { opacity: .5; }
.tp-pct { position: absolute; top: 0; right: 70px; z-index: 4; pointer-events: none; font-size: 13px; font-weight: 700; line-height: 16px; }
.tp .chart-msg { background: color-mix(in srgb, var(--bg) 88%, transparent); z-index: 5; }
.tp-split { flex: 0 0 4px; position: relative; cursor: col-resize; touch-action: none; border-left: 2px solid var(--split-line); }
.tp-split i { position: absolute; left: -3px; width: 6px; top: 50%; height: 34px; margin-top: -17px; border-radius: 3px; background: var(--btn); }
.tp-split:hover i, .tp.dragging .tp-split i { background: var(--line2); }
.tp-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding-bottom: 7px; overflow: auto; scrollbar-width: thin; }
.tp-card { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 6px; background: var(--side); }
.tp-notes textarea { height: 52px; min-height: 52px; padding: 8px 12px; resize: none; border-radius: 4px; font-size: 13px; line-height: 1.35; transition: height .15s; }
.tp-notes textarea:focus { height: 120px; }
.tp-notes input { height: 30px; padding: 0 12px; border-radius: 4px; font-size: 13px; min-width: 0; }
.tp-notes input:read-only, .tp-notes textarea:read-only { cursor: default; }
.tp-reasons { display: flex; gap: 6px; }
.tp-reasons input { flex: 1; }
.tp-video { display: flex; align-items: center; gap: 6px; }
.tp-video input { flex: 1; height: 32px; }
.tp-video .tp-ico { width: 28px; height: 28px; color: var(--muted); }
.tp-video .tp-ico:disabled, .tp-video .tp-ico[aria-disabled] { color: var(--line2); cursor: default; }
.tp-video .tp-ico svg { width: 17px; height: 17px; }
.tp-drop { display: flex; align-items: center; justify-content: center; gap: 8px; height: 36px; border: 1px dashed var(--line); border-radius: 4px; background: var(--bg);
  color: var(--text); font-size: 12px; cursor: pointer; }
.tp-drop svg { width: 20px; height: 20px; color: var(--text2); }
.tp-drop:hover, .tp-drop.over { border-color: var(--accent); }
.tp.ro .tp-drop { display: none; }
.tp-thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.tp-thumbs figure { position: relative; margin: 0; width: 72px; height: 54px; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--bg); cursor: zoom-in; }
.tp-thumbs img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tp-del { position: absolute; top: 2px; right: 2px; display: grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(15, 23, 42, 0.8); color: #fff; opacity: 0; }
.tp-del svg { width: 11px; height: 11px; }
.tp-thumbs figure:hover .tp-del, .tp-del:focus-visible { opacity: 1; }
.tp-state { margin: -2px 0 0; min-height: 0; color: var(--muted); font-size: 12px; }
.tp-state:empty { display: none; }
.tp-state.ok { color: var(--green); } .tp-state.err { color: var(--red); } .tp-state.warn { color: var(--warn); }
[data-theme="light"] .tp-state:not(.ok):not(.err):not(.warn) { color: var(--text2); }
.tp-share { display: flex; align-items: center; justify-content: center; gap: 8px; height: 33px; padding: 0; border: 0; border-radius: 4px; background: var(--btn); color: var(--text); font-size: 13px; }
.tp-share:hover { background: var(--btn-hover); }
.tp-fcard { flex: 1 1 auto; min-height: 150px; gap: 4px; }
.tp-fills { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--f-edge); border-radius: 4px; background: var(--bg); scrollbar-width: thin; }
.tp-fills table { border-collapse: separate; border-spacing: 0; }
.tp-fills th, .tp-fills td { padding: 0 6px; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tp-fills th { top: 0; height: 26px; background: var(--bg); color: var(--ph); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--line); }
.tp-fills td { height: 33px; border-bottom: 1px solid var(--f-line); font-size: 12px; color: var(--text); }
.tp-fills tr:last-child td { border-bottom: 0; }
.tp-fills .fs { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
.tp-fills .fs svg { width: 12px; height: 13px; }
.tp-fills tr.more td { height: 30px; }
.dot { display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; vertical-align: 2px; background: var(--dot-none); }
.dot.market { background: var(--dot-market); } .dot.limit { background: var(--dot-limit); }
.tp-key { margin: 0; padding: 4px 0 2px; text-align: center; font-size: 13px; color: var(--text); }
.tp-key .dot { margin: 0 2px 0 0; }
.tp-key .dot.limit { margin-left: 18px; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: var(--overlay); }
.modal-box { position: relative; max-width: 100%; max-height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 8px; box-shadow: var(--shadow); }
.modal-x { position: absolute; top: 6px; right: 6px; z-index: 2; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; background: none; color: var(--muted); }
.modal-x:hover { color: var(--text); background: var(--btn); }
body.modal-open { overflow: hidden; }
/* the trade: its row on top, then the same panel as in the table */
.tp-box { width: min(1700px, 100%); background: var(--bg); overflow: visible; }
.tp-mhead { position: relative; display: flex; align-items: center; padding-right: 44px; border-bottom: 1px solid var(--line); background: var(--row); border-radius: 8px 8px 0 0; font-family: var(--font-table); }
.tp-mrow { flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tp-mrow table { table-layout: fixed; min-width: 1050px; font-size: 12px; }
.tp-mrow td { height: 44px; padding: 0 8px; border: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.tp-mhead .modal-x { position: static; margin-left: 4px; }
/* the modal has room for more fills than the row's panel */
.tp-mslot .tp { position: static; width: auto; height: min(780px, calc(100vh - 110px)); min-height: 540px; border-radius: 0 0 8px 8px; }
.modal.small .modal-box { padding: 20px; }
.img-modal .modal-box { padding: 0; background: var(--bg); }
.big-img { display: block; max-width: calc(100vw - 48px); max-height: calc(100vh - 48px); cursor: zoom-out; }
.video-modal .modal-box { width: min(960px, 100%); padding: 36px 0 0; background: #000; }
.video-modal .modal-x { color: #cbd5e1; }
.video-frame { position: relative; aspect-ratio: 16 / 9; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.share-modal .modal-box { width: min(460px, 100%); display: flex; flex-direction: column; gap: 10px; }
.share-modal h2 { margin: 0; padding-right: 30px; }
.share-modal p { margin: 0; }
.share-link { width: 100%; font-size: 13px; }
.share-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.share-btns button { display: inline-flex; align-items: center; gap: 8px; }
.share-state { min-height: 1.4em; }

/* ---------- Сводка ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat .l { color: var(--muted); font-size: 12px; } .stat .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
#equity { height: 280px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0 16px; }
.grid2 .table-scroll { max-height: 480px; overflow: auto; }

/* ---------- keys and team ---------- */
.acc-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.invite { background: var(--input); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; white-space: pre-wrap; margin: 8px 0; font: inherit; }
.help { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.help details { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; margin-top: 8px; background: var(--panel2); }
.help summary { cursor: pointer; font-weight: 600; }
.help ol { margin: 8px 0 4px; padding-left: 20px; }
.help li { margin: 4px 0; }
.help code, .ipbox { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.warn { color: var(--warn); }
.small:not(.modal) { font-size: 12px; white-space: normal; max-width: 420px; } /* .modal.small is a dialog size */
.status { white-space: normal; min-width: 160px; }
.actions { white-space: nowrap; }
.actions button { padding: 4px 10px; font-size: 13px; }
.table-scroll { overflow-x: auto; }
.owner-tools { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 8px; }

/* the chart library puts its canvases at z-index 1–3: a message goes over them */
.chart-msg { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; color: var(--muted); background: color-mix(in srgb, var(--panel) 85%, transparent); padding: 16px; text-align: center; }
.banner { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; max-width: min(640px, calc(100vw - 32px));
  background: var(--banner); border: 1px solid var(--red); color: var(--text); border-radius: 8px; padding: 10px 14px; cursor: pointer; }
input:disabled, textarea:disabled, select:disabled { opacity: .7; }
.tf { display: flex; gap: 4px; } .tf button { padding: 4px 8px; font-size: 12px; } .tf button.active { border-color: var(--accent); color: var(--link); }
.note-actions { display: flex; align-items: center; gap: 10px; }

/* ========== Журнал: текущий год, месяц, неделя, день (journal.js) ========== */
/* ---------- «Поделиться сделкой»: the picture of a trade (the chart's camera button) ---------- */
.sh-modal .modal-box { width: min(1080px, 96vw); padding: 0; overflow: hidden; }
.sh-title { margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--line); font-size: 16px; }
.sh { display: grid; grid-template-columns: 410px 1fr; max-height: calc(92vh - 54px); }
.sh-side { padding: 6px 18px 18px; overflow: auto; border-right: 1px solid var(--line); }
.sh-side h4 { margin: 14px 0 10px; font-size: 14px; }
.sh-formats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; }
.sh-formats button { display: grid; justify-items: center; gap: 4px; padding: 8px 4px; background: none; border: 0; border-radius: 6px; font-size: 13px; }
.sh-formats button.on { background: var(--btn); }
.sh-custom { display: flex; gap: 10px; margin-top: 8px; }
.sh-custom label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.sh-custom input { width: 110px; padding: 6px 8px; }
.sh-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sh-tpl { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.sh-tpl select { padding: 6px 8px; }
.sh-line { display: grid; grid-template-columns: 16px 1fr 28px; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sh-line:first-child { border-top: 1px solid var(--line); }
.sh-n { color: var(--muted); }
.sh-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sh-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 0; border-radius: 6px; background: var(--btn); font-weight: 500; }
.sh-chip:hover { text-decoration: line-through; }
.sh-chip i { width: 8px; height: 8px; border-radius: 2px; background: var(--red); }
.sh-plus { width: 30px; padding: 2px; border: 0; background: none; color: var(--muted); font-size: 18px; text-align: center; cursor: pointer; appearance: none; -webkit-appearance: none; }
.sh-x { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; background: none; color: var(--muted); }
.sh-add { display: block; margin: 10px auto 0; border: 0; background: none; }
.sh-signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sh-signs button { position: relative; display: grid; place-items: center; height: 76px; padding: 0 6px; border: 1px solid var(--line); border-radius: 8px; background: none; overflow: hidden; }
.sh-signs button.on { background: var(--btn); border-color: var(--line2); }
.sh-ck { position: absolute; top: 6px; right: 6px; width: 16px; height: 16px; border: 1px solid var(--line2); border-radius: 3px; }
.sh-signs .on .sh-ck { border-color: var(--accent); background: var(--accent); }
.sh-ava { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--line2); font-weight: 700; }
.sh-stealth { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.sh-stealth span { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 4px 8px; }
.sh-stealth small { grid-column: 2; color: var(--muted); }
.sh-toggle { position: relative; flex: none; width: 36px; height: 20px; margin: 0; padding: 0; border: 0; border-radius: 10px; background: var(--line2); cursor: pointer; appearance: none; -webkit-appearance: none; }
.sh-toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.sh-toggle:checked { background: var(--accent); }
.sh-toggle:checked::after { left: 18px; }
.sh-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-width: 0; padding: 18px;
  background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 16px 16px; }
.sh-prev { display: grid; place-items: center; width: 100%; min-height: 0; flex: 1; }
.sh-prev canvas { max-width: 100%; max-height: 62vh; height: auto; border-radius: 12px; box-shadow: var(--shadow); }
.sh-bar { display: flex; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.sh-bar button { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; }
.sh-bar .sh-copy { border-color: #f5c542; background: #f5c542; color: #1f2937; font-weight: 600; }
.sh-state { min-height: 18px; margin: 0; }
@media (max-width: 768px) {
  .sh { grid-template-columns: 1fr; max-height: none; }
  .sh-side { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* ---------- «Мои сделки»: columns and private mode («Настройки колонок») ---------- */
.fbtn.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); background: var(--btn); }
.fbtn.icon-btn svg { width: 15px; height: 15px; }
#privBtn.on { color: #e3c766; border-color: #b39b4a; }
.priv { color: var(--muted); letter-spacing: 2px; }
.rchip { display: inline-block; margin: 1px 4px 1px 0; padding: 1px 8px; border: 1px solid var(--line2); border-radius: 10px; font-size: 12px; white-space: nowrap; }
.colset-modal .modal-box { width: min(920px, 96vw); padding: 0; }
.colset { display: flex; flex-direction: column; max-height: 88vh; overflow: auto; }
.colset h3 { margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--line); font-size: 16px; }
.cs-h { display: flex; align-items: center; gap: 8px; padding: 16px 18px 8px; }
.cs-h small { color: var(--muted); font-size: 13px; }
.cs-legend { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--text2); font-size: 13px; }
.cs-legend svg { width: 14px; height: 14px; margin-left: 12px; }
.cs-vis { display: grid; grid-auto-flow: column; grid-template-columns: 1fr 1fr; column-gap: 28px; padding: 0 18px; }
.cs-row { display: grid; grid-template-columns: 14px 20px 22px 1fr auto 32px 32px; align-items: center; gap: 8px; min-height: 40px; border-bottom: 1px solid var(--line); }
.cs-row.over { background: var(--panel2); }
.cs-grip { color: var(--muted); cursor: grab; letter-spacing: -3px; user-select: none; }
.cs-n { color: var(--muted); text-align: right; }
.cs-name { font-weight: 500; }
.cs-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border: 1px solid var(--line2); border-radius: 12px; font-size: 12px; background: var(--btn); }
.cs-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.cs-box { padding: 4px 8px; border: 1px solid var(--line2); border-radius: 6px; font-size: 12px; }
.cs-cm { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(90deg, var(--red) 50%, var(--green) 50%); }
.cs-cm-btn, .cs-pm { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: 6px; background: none; border: 1px solid transparent; color: var(--muted); }
.cs-cm-btn:not(.on) .cs-cm { filter: grayscale(1); opacity: .45; }
.cs-cm-btn.on { border-color: var(--line2); }
.cs-pm.on { background: #8a7a3a; border-color: #b39b4a; color: #fff3c4; }
.cs-hid { display: grid; grid-template-columns: repeat(4, 1fr); column-gap: 28px; padding: 0 18px 10px; }
.cs-hid label { display: flex; align-items: center; gap: 10px; min-height: 40px; border-bottom: 1px solid var(--line); cursor: pointer; }
.cs-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--line); }
.cs-foot button { height: 44px; }
.cs-foot .primary { background: var(--dw-add); color: var(--dw-add-text); border-color: transparent; }
@media (max-width: 768px) {
  .cs-vis { grid-auto-flow: row; grid-template-columns: 1fr; grid-template-rows: none !important; }
  .cs-hid { grid-template-columns: 1fr 1fr; }
  .cs-legend { display: none; }
}

/* ---------- «Сводка»: boards of widgets (dash.js) ---------- */
main.dash { max-width: none; padding: 6px 6px 24px; }
.dash-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 2px 0 8px; }
.dash-chips { display: contents; }
.dash-bar .fbtn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 1px solid var(--line); white-space: nowrap; }
.dash-bar .fbtn svg { width: 14px; height: 14px; flex: none; }
.dash-board { background: var(--dw-board); }
.dchip.set { border-color: var(--line2); color: var(--text-hi); }
.dash-bar .dash-add { background: var(--dw-add); color: var(--dw-add-text); border-color: transparent; font-weight: 500; }
.dash-bar .dash-add:hover { background: var(--dw-add); filter: brightness(1.07); }
#dashNone { padding: 40px 12px; text-align: center; }
.dash-grid { position: relative; min-height: 120px; }
.dw { position: absolute; display: flex; flex-direction: column; background: var(--dw-bg); border: 1px solid var(--dw-line); border-radius: 2px; overflow: hidden;
  transition: left .15s, top .15s, width .15s, height .15s; }
.dw.dragging { transition: none; z-index: 5; opacity: .92; box-shadow: var(--shadow); }
.dw-ph { position: absolute; background: rgba(148, 163, 184, .12); border: 1px dashed var(--line2); border-radius: 2px; transition: left .12s, top .12s, width .12s, height .12s; }
.dw-head { display: flex; align-items: center; gap: 2px; height: 36px; flex: none; padding: 0 2px 0 6px; cursor: move; user-select: none; touch-action: none; }
.dw-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; color: var(--text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the buttons show on hover, like the reference; a touch screen has them all in ☰ */
.dw-tools { display: none; align-items: center; }
.dw:hover .dw-tools, .dw:focus-within .dw-tools { display: flex; }
@media (hover: none) { .dw:hover .dw-tools, .dw:focus-within .dw-tools { display: none; } }
.dw-tools button, .dw-burger { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--muted); cursor: pointer; }
.dw-tools button:hover, .dw-burger:hover, .dw-tools button.on { color: var(--text-hi); background: var(--btn); }
.dw-tools i { width: 1px; height: 14px; margin: 0 3px; background: var(--line); }
.dw-body { position: relative; flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.dw.mini .dw-body, .dw.mini .dw-size { display: none; }
.dw-body > svg { display: block; flex: none; }
.dw-chartbox { position: relative; flex: 1; min-height: 0; }
.dw-chart { position: absolute; inset: 0 4px 0 0; }
.dw-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 12px; padding: 2px 10px 4px; font-size: 11px; color: var(--muted); flex: none; }
.dw-legend i, .dw-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dw-tip { position: absolute; z-index: 3; pointer-events: none; padding: 8px 12px; border-radius: 6px; background: var(--dw-tip); color: var(--text-hi); border: 1px solid var(--line);
  font-size: 12px; white-space: nowrap; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); }
.dw-tip div + div { margin-top: 5px; }
.dw-tip b { margin-left: 12px; font-weight: 600; }
.dw-size { position: absolute; right: 0; bottom: 0; z-index: 2; width: 16px; height: 16px; cursor: nwse-resize; touch-action: none; }
.dw-size::after { content: ''; position: absolute; right: 3px; bottom: 3px; width: 6px; height: 6px; border-right: 2px solid var(--line2); border-bottom: 2px solid var(--line2); }
.dw-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 12px; text-align: center; }
.dw-empty b { font-size: 16px; font-weight: 600; color: var(--text-hi); }
.dw-empty span { font-size: 13px; color: var(--text2); }
.dw-empty svg { vertical-align: -3px; }
.dw-num { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 22px 10px; }
.dw-nl span { display: block; font-size: 13px; }
.dw-nl small { font-size: 13px; color: var(--text2); text-decoration: underline dotted; }
.dw-nv { font-size: 30px; color: var(--text-hi); white-space: nowrap; }
.dw-bars { flex: 1; overflow: auto; padding: 0 10px 10px; }
.dw-bar { padding: 4px 0; }
.dw-bh { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.dw-bh span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-bh b { font-weight: 500; white-space: nowrap; }
.dw-bt { position: relative; height: 8px; margin-top: 3px; border-radius: 2px; background: rgba(148, 163, 184, .1); }
.dw-bt i { position: absolute; top: 0; bottom: 0; border-radius: 2px; background: var(--dw-accent, var(--muted)); }
.dw-bt i.p { background: var(--tm-up); }
.dw-bt i.m { background: var(--tm-down); }
.dw-table { flex: 1; overflow: auto; }
.dw-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dw-table th, .dw-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.dw-table th { position: sticky; top: 0; background: var(--dw-bg); color: var(--muted); font-weight: 500; }
.dw-table .num { text-align: right; }
.dcal { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 8px 8px; font-size: 12px; }
.dcal-head { display: flex; align-items: center; gap: 8px; }
.dcal-head > button { padding: 2px 8px; background: none; border-color: transparent; }
.dcal-tog { margin-left: auto; display: flex; gap: 2px; }
.dcal-tog button { padding: 2px 8px; font-size: 11px; background: none; }
.dcal-tog button.on { background: var(--btn); }
.dcal-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0; }
.dcal-stats div { display: grid; text-align: center; }
.dcal-stats span { color: var(--muted); font-size: 11px; }
.dcal-grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: auto; grid-auto-rows: 1fr; gap: 3px; min-height: 0; }
.dcal-wd { text-align: center; color: var(--muted); font-size: 11px; align-self: end; }
.dcal-c { display: flex; flex-direction: column; min-width: 0; padding: 3px 4px; border-radius: 4px; background: rgba(148, 163, 184, .06); overflow: hidden; }
.dcal-c.out { background: none; }
.dcal-c span { color: var(--muted); font-size: 11px; }
.dcal-c b { font-weight: 600; white-space: nowrap; }
.dcal-c small { color: var(--text2); font-size: 10px; white-space: nowrap; }
.dcal-c.p { background: color-mix(in srgb, var(--tm-up) 30%, transparent); }
.dcal-c.m { background: color-mix(in srgb, var(--tm-down) 34%, transparent); }
.dash-grid.stack { display: flex; flex-direction: column; gap: 6px; height: auto !important; }
.dash-grid.stack .dw { position: relative; transition: none; }
.dash-grid.stack .dw-head { cursor: default; touch-action: auto; }
.dash-grid.stack .dw-size { display: none; }
/* popovers: the filters' lists, the menus and the catalogue */
.dpop { position: fixed; z-index: 60; padding: 0; gap: 0; max-height: min(600px, 86vh); overflow: hidden; white-space: normal; }
.dpop .primary, .ded-foot .primary, .dcat-add { background: var(--dw-add); color: var(--dw-add-text); border-color: transparent; }
.dpop .primary:hover, .ded-foot .primary:hover, .dcat-add:hover { filter: brightness(1.07); }
.dpop-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.dpop-head b { flex: 1; font-size: 14px; }
.dpop-head button { padding: 6px 10px; background: none; border-color: transparent; font-weight: 500; }
.dpop-head button.save { background: var(--btn); }
.dpop-search { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-bottom: 1px solid var(--line); color: var(--muted); }
.dpop-search input { flex: 1; min-width: 0; border: 0; background: none; padding: 6px 0; }
.dpop-range { display: flex; align-items: center; gap: 6px; padding: 10px; }
.dpop-range input { flex: 1; min-width: 0; padding: 6px 8px; }
.dpop-list { display: flex; flex-direction: column; gap: 2px; padding: 6px; overflow: auto; max-height: 300px; min-height: 0; }
.dpop-list > button { display: flex; justify-content: space-between; gap: 12px; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; font-weight: 500; }
.dpop-list > button:hover, .dpop-list > .act { background: var(--line); }
.dpop-list > button.cur::after { content: '✓'; }
.dpop-list > button.on { color: var(--muted); }
.dpop-num { display: flex; align-items: end; gap: 8px; padding: 10px; }
.dpop-num label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.dpop-num input { width: 110px; padding: 6px 8px; }
.dpop-hints { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.dpop-hints kbd { padding: 1px 5px; border-radius: 4px; background: var(--btn); color: var(--text); font: inherit; font-size: 10px; }
.dpop-filter { width: 330px; }
.dpop-pick { width: 520px; }
.dpick { display: grid; grid-template-columns: 200px 1fr; min-height: 0; }
.dpick-cats, .dcat-cats { display: flex; flex-direction: column; gap: 2px; padding: 6px; overflow: auto; }
.dpick-cats { border-right: 1px solid var(--line); }
.dpick-cats button, .dcat-cats button { display: flex; justify-content: space-between; gap: 8px; text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 6px; }
.dpick-cats small, .dcat-cats small { color: var(--muted); }
.dpick-cats button.cur, .dcat-cats button.cur, .dpick-cats button:hover, .dcat-cats button:hover { background: var(--line); }
.dpop-tpl { width: 300px; padding-bottom: 6px; }
.dtpl { display: flex; }
.dtpl button:first-child { flex: 1; }
.dtpl-x { flex: none; padding: 4px; color: var(--muted); }
.dpop-tpl > .link { margin: 4px 10px; text-align: left; background: none; border: 0; color: var(--link); padding: 4px 0; }
.dpop-menu { padding: 6px; gap: 2px; min-width: 220px; }
.dpop-menu > button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; }
.dpop-menu > button:hover { background: var(--line); }
.dpop-menu > button.cur { color: var(--green); }
.dpop hr { width: 100%; margin: 4px 0; border: 0; border-top: 1px solid var(--line); }
.dcolors { display: grid; grid-template-columns: repeat(5, 28px); gap: 6px; padding: 10px; }
.dcolors button { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid var(--line); }
.dpop-cat { width: min(1000px, 96vw); }
.dcat { display: grid; grid-template-columns: 300px 1fr 280px; height: min(600px, 80vh); min-height: 0; }
.dcat-prev { display: flex; flex-direction: column; gap: 8px; padding: 10px; overflow: auto; border-right: 1px solid var(--line); }
.dcat-name { font-size: 15px; }
.dcat-card { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.dcat-card span b { display: block; margin-top: 2px; font-size: 18px; }
.dcat-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 6px; background: var(--btn); color: var(--text-hi); }
.dcat-ic svg { width: 22px; height: 22px; }
.dcat-add { width: 32px; height: 32px; padding: 0; font-size: 18px; line-height: 1; }
.dcat-mid { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.dcat-list { flex: 1; max-height: none; }
.dcat-list > button.cur { background: var(--line); }
.dcat-cats b { padding: 4px 10px 8px; }
/* the widget's settings */
.ded-modal .modal-box { width: min(1480px, 96vw); height: min(900px, 92vh); padding: 0; overflow: hidden; }
.ded { display: grid; grid-template-columns: 380px 1fr; height: 100%; }
.ded-side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--dw-bg); }
.ded-sh { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ded-sh b { flex: 1; font-size: 15px; }
.ded-sh .fbtn { display: inline-flex; align-items: center; gap: 6px; }
.ded-filters { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; overflow: auto; }
.ded-f { display: grid; grid-template-columns: 1fr auto 14px; align-items: center; gap: 8px; text-align: left; background: none; border: 0; border-radius: 6px; padding: 10px; }
.ded-f:hover { background: var(--panel2); }
.ded-f small { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.ded-f.set small { color: var(--text-hi); }
.ded-more { margin: 2px 12px; justify-content: center; }
.ded-foot { display: grid; grid-template-columns: 44px 1fr 1fr; gap: 8px; margin-top: auto; padding: 12px; border-top: 1px solid var(--line); }
.ded-foot button { height: 44px; }
.ded-color { display: grid; place-items: center; padding: 0; }
.ded-color i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line2); }
.ded-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ded-top { padding: 12px 50px 12px 16px; border-bottom: 1px solid var(--line); }
.ded-title { width: min(400px, 100%); }
.ded-applied { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.ded-chip { padding: 4px 8px; border: 1px solid var(--line2); border-radius: 4px; font-size: 13px; }
.ded-chip i { font-style: normal; color: var(--muted); }
.ded-prev { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; background: var(--bg); }
.ded-bot { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.ded-bot label { display: inline-flex; align-items: center; gap: 8px; }
.ded-ma { width: 64px; padding: 4px 6px; }
.ded-bot .on { color: var(--green); }
@media (max-width: 768px) {
  .ded { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: auto; }
  .ded-side { max-height: 46vh; }
  .dcat { grid-template-columns: 1fr; height: auto; }
  .dcat-cats, .dcat-prev { max-height: 220px; }
  .dpick { grid-template-columns: 1fr; }
  .dpop-pick, .dpop-filter { width: calc(100vw - 24px); }
}

main.journal { max-width: 1680px; }
.jhead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 20px; }
.jgap { flex: 1; }
.jtitle { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.25; }
.jintro p { margin: 3px 0 0; }
.jnav { display: flex; align-items: center; gap: 10px; min-width: 0; }
.jarrow { flex-shrink: 0; background: var(--panel); padding: 3px 11px; font-size: 18px; line-height: 1.3; }
.jcompare { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; user-select: none; }
.jcompare input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.jacc .dd-menu { left: auto; right: 0; }
/* a new period is on its way: the old numbers fade until it comes */
.jloading .jtop, .jloading .jcards, .jloading .jtl, .jloading .jwork { opacity: .45; }
.jbox { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }

/* metrics: 3 × 2 cells, thin lines between them */
.jm { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.jm-cell { background: var(--panel); padding: 12px 14px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.jm-v { font-size: 22px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.jm-l { font-size: 13px; }
/* a long sub-line breaks between words into even halves: "Объём" / "41 483 699 $", not "41 483 699" / "$" */
.jm-s, .jm-p { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: break-word; text-wrap: balance; }
.jm-p { font-style: italic; }
.jm-empty { margin: 10px 0 0; text-align: center; font-size: 13px; }

/* the top of a month, week or day: metrics | cumulative profit | note; the chart gives way first, so the metrics
   cells stay wider than their numbers */
.jtop { display: grid; grid-template-columns: minmax(500px, 1.25fr) minmax(0, 1fr) minmax(260px, 360px); gap: 16px; margin-bottom: 30px; }
.jchart { position: relative; min-height: 220px; }
.jchart-el { position: absolute; inset: 10px; }
.jchart-empty { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; margin: 0; background: var(--panel); border-radius: 10px; }
.jnote-slot { display: flex; min-width: 0; }

/* a note on a month, week or day; a line above it when the note was changed elsewhere */
.jnote { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; }
.jnote textarea { flex: 1 1 auto; width: 100%; min-height: 140px; resize: vertical; background: var(--panel); border-radius: 10px; padding: 12px 14px 24px; line-height: 1.5; }
.jnote-state { position: absolute; right: 12px; bottom: 6px; font-size: 11px; pointer-events: none; }
.jnote-clash { margin: 0 0 6px; font-size: 12px; }
.jnote-clash a { color: var(--accent); }

/* week and day cards; the button sits on the card's bottom edge */
.jcards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 30px 16px; padding-bottom: 14px; }
.jcard { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 14px 24px; min-width: 0; }
.jcard.up { border-color: color-mix(in srgb, var(--green) 45%, var(--line)); } .jcard.down { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
.jcard-h { font-weight: 600; margin-bottom: 10px; }
.jcard .jm-cell { padding: 10px 12px; }
.jcard .jm-v { font-size: 18px; }
.jcard-btn { position: absolute; left: 50%; bottom: 0; transform: translate(-50%, 50%); padding: 4px 14px; font-size: 12px; border-radius: 999px; white-space: nowrap; }
.jcard-btn:hover, .jsm:hover { border-color: var(--green); color: var(--green); }
/* the month, the week and the day as the reference draws them, edge to edge: the title, «Сравнить…» and the key filter
   in one plain line (no arrows on the month and the week); the figures straight on the page, the chart and the note in
   three equal columns; the week's days as flat panels close together, each figure a block at the middle of its
   column, the button inside each panel at its bottom */
main#view-jmonth, main#view-jweek, main#view-jday { max-width: none; padding: 0 0 24px; }
:is(#view-jmonth, #view-jweek, #view-jday) .jhead { gap: 6px 18px; margin: 0; padding: 12px 7px 10px; }
:is(#view-jmonth, #view-jweek, #view-jday) .jtitle { font-size: 17px; }
:is(#view-jmonth, #view-jweek) .jarrow { display: none; }
#view-jday .jarrow { background: none; border-color: transparent; padding: 0 8px; font-size: 18px; color: var(--muted); }
#view-jday .jarrow:hover { color: var(--text-hi); }
#view-jweek .jcompare { color: var(--text); font-size: 14px; }
:is(#view-jmonth, #view-jweek, #view-jday) .jacc .fbtn:not(.on) { border-color: transparent; background: none; font-size: 13px; padding: 2px 6px; }
:is(#view-jmonth, #view-jweek, #view-jday) .jtop { gap: 7px; margin-bottom: 8px; }
:is(#view-jmonth, #view-jweek, #view-jday) .jtop > .jbox:first-child { background: none; border: 0; border-radius: 0; padding: 0 7px; }
:is(#view-jmonth, #view-jweek, #view-jday) .jchart { border: 0; border-radius: 3px; background: color-mix(in srgb, var(--panel) 75%, var(--line)); min-height: 160px; }
:is(#view-jmonth, #view-jweek, #view-jday) .jchart-empty { background: none; }
:is(#view-jmonth, #view-jweek, #view-jday) .jnote textarea { border: 0; border-radius: 0; background: var(--input); min-height: 160px; }
:is(#view-jmonth, #view-jweek, #view-jday) .jm { background: none; gap: 0; }
:is(#view-jmonth, #view-jweek, #view-jday) .jm-cell { display: grid; justify-content: center; align-content: start; background: none; padding: 9px 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
:is(#view-jmonth, #view-jweek, #view-jday) .jm-cell:nth-child(3n) { border-right: 0; }
:is(#view-jmonth, #view-jweek, #view-jday) .jm-cell:nth-child(n+4) { border-bottom: 0; }
:is(#view-jmonth, #view-jweek, #view-jday) .jm-v, #view-jweek .jcard .jm-v { font-size: 17px; }
:is(#view-jmonth, #view-jweek, #view-jday) .jm-l, :is(#view-jmonth, #view-jweek, #view-jday) .jm-s { font-size: 12.5px; color: var(--text); }
/* the work area of the day and the month as the reference draws it, edge to edge and as tall as the screen: the tickers
   by key (220 px) | the trade's chart | its trades, figures and notes (333 px), in flat frames close together */
#jArea :is(.jw-left, .jw-center, .jw-right) { padding: 0; border-radius: 0; }
@media (min-width: 1101px) {
  /* below the title and the figures, down to the window's bottom */
  #jArea .jwork { grid-template-columns: 220px minmax(0, 1fr) 333px; gap: 0 7px; align-items: stretch; height: calc(100vh - var(--top) - 240px); min-height: 560px; }
  #jArea :is(.jw-left, .jw-center, .jw-right) { display: flex; flex-direction: column; min-height: 0; }
  #jArea .jw-chart-box { flex: 1; min-height: 0; }
  #jArea #jwChart { height: 100%; }
  #jArea .jw-list { flex: 1; max-height: none; }
  #jArea .jw-right { overflow: hidden; }
  #jArea .jw-table-wrap { flex: 0 0 auto; max-height: 45%; }
  /* the figures and notes scroll; «Перейти к сделке» and «Поделиться» stay in sight at the bottom */
  #jArea .jw-detail { flex: 1; min-height: 0; overflow: auto; }
  #jArea .jw-detail > * { flex-shrink: 0; }
  #jArea .jd-actions { position: sticky; bottom: 0; margin-top: auto; padding: 8px 0 2px; background: var(--panel); }
}
#jArea .jw-search { position: relative; margin: 7px; }
#jArea .jw-search input { width: 100%; padding-right: 30px; border-radius: 3px; }
#jArea .jw-search svg { position: absolute; right: 9px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.5; pointer-events: none; }
#jArea .jw-list { overflow: auto; }
#jArea .jw-gh { color: var(--text-hi); font-size: 15px; font-weight: 700; padding: 10px 6px 8px; border-bottom: 1px solid var(--line); }
/* a key's title folds and unfolds its tickers */
.jw-gh { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; background: none; border: 0; border-radius: 0; text-align: left; cursor: pointer; }
.jw-gh:hover { background: var(--panel2); }
.jw-gh span { min-width: 0; overflow-wrap: anywhere; }
.jw-gh .chev { flex-shrink: 0; margin: 0 4px 0 0; }
.jw-gh[aria-expanded="false"] .chev { transform: translate(-2px, 0) rotate(-45deg); }
#jArea .jw-tk { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 9px 7px 9px 18px; font-size: 14px; }
#jArea .jw-tk:hover { background: var(--panel2); }
#jArea .jw-tk span, #jArea .jw-tk b { font-weight: 400; color: var(--text); }
#jArea .jw-tk.sel { background: var(--input); border-color: transparent; }
#jArea .jw-tkd { background: var(--input); padding: 0 7px 10px 38px; font-size: 14px; gap: 7px; border-bottom: 1px solid var(--line); }
#jArea .jw-tkd span { color: var(--text); }
#jArea .jw-tkd b { font-weight: 400; }
#jArea .jw-table-wrap { min-height: 120px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
#jArea #jwTable th { background: var(--panel); font-size: 14px; font-weight: 600; color: var(--text-hi); }
#jArea #jwTable td { color: var(--text); font-size: 13.5px; }
#jArea .jw-side { font-size: 14px; font-weight: 700; letter-spacing: 0; box-shadow: inset 5px 0 var(--green); padding-left: 14px; }
#jArea .jw-side.loss { box-shadow: inset 5px 0 var(--red); }
#jArea .jw-detail { gap: 0; margin: 0; padding: 0 7px 10px; }
#jArea .jw-kv { display: block; }
#jArea .jw-kv div, #jArea .jd-pick { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
#jArea .jw-kv span { display: inline; color: var(--text-hi); font-size: 13.5px; }
#jArea .jw-kv b { font-weight: 400; font-variant-numeric: tabular-nums; }
#jArea .jd-dd { position: relative; }
#jArea .jd-pick { width: 100%; background: none; border-width: 0 0 1px; border-radius: 0; color: var(--text-hi); text-align: left; }
#jArea .jd-pick em { flex: 1; min-width: 0; font-style: normal; color: var(--text); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#jArea .jd-pick:disabled { cursor: default; opacity: 1; }
#jArea .jd-menu { left: 0; right: 0; max-height: 260px; overflow: auto; }
#jArea .jd-new { width: 100%; margin-bottom: 6px; }
#jArea .jw-detail textarea { margin-top: 10px; border-radius: 3px; background: var(--input); }
#jArea .jd-state { margin-top: 6px; }
#jArea #jdSave { align-self: flex-start; margin: 4px 0; }
#jArea .jd-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
#jArea .jd-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 8px; border: 0; border-radius: 3px; background: var(--btn); color: var(--text-hi); font-size: 14px; }
#jArea .jd-actions button:hover { background: var(--btn-hover); }
#jArea .jd-actions svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; }
#jArea .jd-all { margin-top: 10px; font-size: 12px; }
#view-jweek .jcards { gap: 8px 7px; padding-bottom: 0; }
#view-jweek .jcard, #view-jweek .jcard.up, #view-jweek .jcard.down { border-color: var(--line); border-radius: 0; padding: 12px 7px 62px; min-height: 284px; }
#view-jweek .jcard-h { font-weight: 400; font-size: 16px; margin: 0 0 6px; }
#view-jweek .jcard .jm-cell { padding: 9px 6px; }
#view-jweek .jcard-btn { bottom: 18px; transform: translateX(-50%); border: 0; border-radius: 3px; padding: 6px 9px; font-size: 14px; background: var(--input); color: var(--text-hi); }
#view-jweek .jcard-btn:hover { color: var(--green); }
@media (min-width: 1281px) {
  :is(#view-jmonth, #view-jweek, #view-jday) .jtop { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.jsm { padding: 3px 12px; font-size: 12px; border-radius: 999px; }
/* a week on the year's timeline: its four figures always in one line */
.jwc { display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 10px 8px; }
.jwc > div { display: flex; flex-direction: column; min-width: 0; }
.jwc b { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.jwc span { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* the year: a timeline of months, each with its note and its weeks */
.jyear-nav { display: flex; align-items: center; gap: 16px; margin: 0 0 24px; }
.jyear-num { font-size: 64px; font-weight: 800; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.jtl { position: relative; padding-left: 36px; }
.jtl::before { content: ''; position: absolute; left: 9px; top: 0; bottom: 34px; width: 1px; background: var(--line); }
.jtl-m { position: relative; padding-bottom: 34px; }
.jtl-m::before { content: ''; position: absolute; left: -27px; top: 13px; width: 19px; height: 1px; background: var(--line); }
.jtl-mh { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.jtl-mh h2 { margin: 0; font-size: 18px; }
.jtl-row { display: flex; gap: 16px; align-items: flex-start; }
.jtl-row > .jnote { flex: 0 0 360px; }
/* as many week cards in a row as fit at 360px or more: the four figures of a busy team's week need that much */
.jweeks { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 30px 16px; }
.jweeks:empty { display: none; }

/* the day: tickers by API key | the ticker's chart | its trades and the chosen trade */
.jwork { display: grid; grid-template-columns: 240px minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
#jDayCut { margin: -18px 0 12px; font-size: 12px; }
.jw-left, .jw-center, .jw-right { padding: 10px; }
#jwSearch { width: 100%; margin-bottom: 6px; }
.jw-list { max-height: 560px; overflow: auto; }
.jw-gh { color: var(--muted); font-size: 12px; padding: 10px 6px 4px; overflow-wrap: anywhere; }
.jw-tk { display: flex; width: 100%; justify-content: space-between; gap: 8px; background: none; border: 1px solid transparent; padding: 7px 8px; border-radius: 6px; text-align: left; }
.jw-tk:hover { background: var(--panel2); border-color: transparent; }
.jw-tk.sel { background: var(--panel2); border-color: var(--line); }
.jw-tk span { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.jw-tk b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.jw-tkd { display: grid; gap: 3px; padding: 6px 8px 10px; font-size: 12px; }
.jw-tkd div { display: flex; justify-content: space-between; gap: 8px; }
.jw-tkd span { color: var(--muted); }
.jw-tkd b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.jw-none { margin: 10px 6px; }
.jw-chead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.jw-sym { min-width: 0; overflow-wrap: anywhere; }
.jw-chart-box { position: relative; isolation: isolate; }
#jwChart { height: 520px; }
/* the trade's panel from «Мои сделки», only its chart */
#jwChart > .tp:not(.full) { position: relative; width: 100%; height: 100%; }
.tp.embed [data-dd="tpLay"] { display: none; }
.jw-table-wrap { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
#jwTable th, #jwTable td { padding: 7px 8px; font-size: 13px; }
#jwTable tbody tr { cursor: pointer; }
#jwTable tbody tr:hover td { background: var(--row-hover); }
#jwTable tbody tr.sel td { background: var(--row-sel); }
.jw-side { font-weight: 600; font-size: 12px; letter-spacing: .03em; box-shadow: inset 3px 0 var(--green); }
.jw-side.loss { box-shadow: inset 3px 0 var(--red); }
.jw-detail { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.jw-detail label { color: var(--muted); font-size: 12px; margin-top: 4px; }
.jw-detail input, .jw-detail textarea { width: 100%; }
.jw-detail textarea { resize: vertical; }
.jw-detail .note-actions { flex-wrap: wrap; margin-top: 4px; }
.jw-kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.jw-kv span { display: block; color: var(--muted); font-size: 12px; }
.jd-state { margin: 0; min-height: 1.2em; font-size: 12px; }
.jd-all { color: var(--link); font-size: 13px; }

/* «Настройки»: a card as the reference's «Дата и время»: a title over a line, then rows of a small icon, a name and the
   value with its arrow; the lists open under the value, the zones' with a search on top */
main.settings { max-width: 640px; margin: 0; padding-top: 24px; }
.set-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.set-h { margin: 0; padding: 20px; border-bottom: 1px solid var(--line); font-size: 16px; font-weight: 400; color: var(--text-hi); }
.set-body { display: flex; flex-direction: column; gap: 12px; padding: 20px 8px; }
.set-row { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px; }
.set-ico { display: grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0; border-radius: 6px; background: var(--input); color: var(--text-hi); }
.set-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.set-ico text { fill: currentColor; stroke: none; font: 600 6px/1 var(--font); }
.set-l { flex: 1; min-width: 0; color: var(--text-hi); font-size: 15px; }
.set-val { display: inline-flex; align-items: center; gap: 12px; background: none; border: 0; padding: 6px 10px; border-radius: 6px; color: var(--text-hi); font-size: 15px; }
.set-val:hover { background: var(--panel2); }
.set-val .chev { margin: 0 4px 0 0; }
.set-menu { left: auto; right: 0; width: 280px; max-height: 300px; padding: 0; overflow: hidden; gap: 0; }
.set-menu.set-list { padding: 6px; }
.set-search { display: flex; align-items: center; gap: 8px; padding: 0 10px; border-bottom: 1px solid var(--line); background: var(--panel2); }
.set-search svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: var(--muted); stroke-width: 1.5; }
.set-search input { flex: 1; min-width: 0; border: 0; background: none; padding: 9px 0; }
.set-search input:focus-visible { outline: none; }
#setZoneList { flex: 1; min-height: 0; overflow: auto; padding: 6px; }
.set-list button { display: flex; align-items: center; width: 100%; background: none; border: 0; border-radius: 6px; padding: 7px 12px; text-align: left; font-size: 14px; font-weight: 400; }
.set-list button:hover { background: var(--line); }
.set-list button.on::after { content: ''; width: 5px; height: 10px; margin-left: auto; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); }

@media (max-width: 1280px) {
  .jtop { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jtop > .jnote-slot { grid-column: 1 / -1; }
  .jcards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jwork { grid-template-columns: 220px minmax(0, 1fr); }
  .jw-right { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .jw-right .jw-detail { margin-top: 0; }
}
/* two week cards no longer fit beside the month's note: the note goes above them */
@media (max-width: 1210px) {
  .jtl-row { flex-direction: column; align-items: stretch; }
  .jtl-row > .jnote { flex: none; }
}
/* the metrics take a whole row; the chart and the note share the next one */
@media (max-width: 1100px) {
  .jtop > :first-child { grid-column: 1 / -1; }
  .jtop > .jnote-slot { grid-column: auto; }
}
/* the footer's totals and pager no longer fit in one line */
@media (max-width: 1100px) {
  .tfoot { padding: 4px 6px; }
  .totals { order: 3; flex: 1 1 100%; justify-content: flex-start; }
  .pager { margin-left: auto; }
}
/* two cards in a row would get cells narrower than their numbers */
@media (max-width: 820px) {
  .jcards { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- phones ---------- */
@media (max-width: 768px) {
  /* the open trade stays as wide as the screen while the table scrolls sideways; chart on top, notes below */
  .tp { flex-direction: column; height: auto; }
  .tp-chart { flex: none; height: 372px; }
  .tp-top { flex-wrap: wrap; height: auto; row-gap: 2px; padding: 4px 4px 4px 8px; }
  .tp-tfs { order: 3; flex: 1 1 100%; flex-wrap: wrap; }
  .tp-title { flex: 1; display: block; }
  .tp-gap { display: none; }
  .tp-tools { display: none; }
  .tp-split { display: none; }
  .tp-side { overflow: visible; padding-bottom: 6px; }
  .tp-fcard { flex: none; }
  .tp-fills { max-height: 340px; }
  .tp-reasons { flex-direction: column; }
  .tp-reasons input { flex: none; }
  .tp-legend { right: 8px; }
  .tp-ohlc span:nth-child(n+6) { display: none; }
  .modal { padding: 0; }
  .tp-box { width: 100%; height: 100%; border: 0; border-radius: 0; overflow: auto; }
  /* 16 px text (no iPhone zoom) needs taller fields */
  .tp-notes input, .tp-video input { height: 40px; }
  .tp-notes textarea { height: 64px; min-height: 64px; }
  .tp-mhead { border-radius: 0; position: sticky; top: 0; z-index: 7; }
  .tp-mslot .tp { border-radius: 0; height: auto; min-height: 0; }
}

@media (max-width: 700px) {
  :root { --top: 0px; }
  .topbar { flex-wrap: wrap; gap: 6px 12px; padding: 8px 12px; position: static; }
  .menu { order: 3; flex: 1 1 100%; }
  .menu > button, .menu .dd-btn { padding: 6px 9px; }
  /* a menu opens across the screen under its button, wherever the button lands */
  .dd { position: static; }
  .dd-menu { top: auto; left: 12px; right: 12px; margin-top: 6px; }
  .tp .dd { position: relative; }
  .tp .dd-menu { left: auto; right: 0; margin-top: 0; top: calc(100% + 4px); }
  .theme-btn { margin-left: auto; }
  .me { margin-left: 0; }
  main { padding: 12px; }
  main.view-trades { height: auto; }
  main.view-trades .tbar { padding: 10px 12px 0; }
  .trades-wrap { max-height: 75vh; }
  /* iPhone zooms the page into any field with text smaller than 16px */
  input, select, textarea, #pageSize, .tp-notes input, .tp-notes textarea { font-size: 16px; }
  .jtitle { font-size: 18px; }
  .jhead { margin-bottom: 14px; }
  .jacc .dd-menu { left: 12px; right: 12px; }
  .jyear-num { font-size: 44px; }
  .jtl { padding-left: 22px; }
  .jtl::before { left: 5px; }
  .jtl-m::before { left: -17px; width: 12px; }
  .jtop, .jcards, .jweeks, .jwork, .jw-right { grid-template-columns: minmax(0, 1fr); }
  .jtop { gap: 12px; margin-bottom: 24px; }
  .jm, .jwc { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jwc b { font-size: 16px; } .jwc span { font-size: 12px; }
  .jm-cell { padding: 10px; }
  .jm-v, .jcard .jm-v { font-size: 17px; }
  .jw-list { max-height: 300px; }
  #jwChart { height: 400px; }
  /* the figures in two columns: lines between the columns and under every row but the last */
  :is(#view-jmonth, #view-jweek, #view-jday) .jm-cell:nth-child(n) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  :is(#view-jmonth, #view-jweek, #view-jday) .jm-cell:nth-child(2n) { border-right: 0; }
  :is(#view-jmonth, #view-jweek, #view-jday) .jm-cell:nth-child(n+5) { border-bottom: 0; }
  :is(#view-jmonth, #view-jweek, #view-jday) .jnote textarea { min-height: 96px; }
}
