/* Layout of "Portfel i podatek". Colours, fonts and shared parts come from look/look.css (MiniNexus look). */
.tx-main { padding: 12px 16px 24px; display: grid; gap: 12px; width: 100%; box-sizing: border-box; }
.tx-hint { color: var(--muted); font-size: .92em; }
p.tx-hint { margin: 0 0 8px; }
.mn-card p { margin: 0 0 8px; line-height: 1.5; }
.tx-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }

/* ---------- input card: fixed-width columns kept to the left ---------- */
.tx-inputgrid { display: grid; gap: 12px 32px; grid-template-columns: repeat(auto-fill, minmax(300px, 400px)); justify-content: start; align-items: start; }
.tx-field { display: grid; gap: 5px; min-width: 0; }
.tx-field > label { font-weight: 600; font-size: .92em; color: var(--muted); }
.tx-field > label.tx-gap { margin-top: 8px; }
.tx-field input[type=date], .tx-field input[type=text].tx-num, .tx-mtable input {
  font: inherit; color: var(--text); background: var(--surface2); border: 1px solid var(--line); border-radius: var(--r-btn);
  min-height: 30px; padding: 2px 8px; box-sizing: border-box; width: 100%; max-width: 260px; }
.tx-drop { position: relative; display: grid; place-items: center; text-align: center; min-height: 64px; padding: 10px 12px;
  border: 1px dashed var(--line); border-radius: var(--r-card); background: var(--surface2); cursor: pointer; color: var(--muted); }
.tx-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.tx-drop.mn-on { border-style: solid; }
.tx-loaded { display: grid; gap: 4px; }
.tx-file { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: .92em; }
.tx-filebtn { position: relative; display: inline-flex; align-items: center; }
.tx-filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.tx-fxgrid { display: grid; justify-content: start; grid-template-columns: auto minmax(0, 140px); gap: 6px 10px; align-items: center; }
.tx-fxgrid label { font-weight: 600; color: var(--muted); font-size: .92em; }
.tx-field .tx-fxgrid input { max-width: 140px; }

/* ---------- summary tiles ---------- */
.tx-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tx-tile { display: grid; gap: 2px; align-content: start; }
.tx-tile b { font-size: 1.35em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-tilelabel { color: var(--muted); font-size: .92em; font-weight: 600; }

/* ---------- tables ---------- */
.tx-scroll { overflow-x: auto; overflow-y: hidden; margin: 0 -4px; padding: 0 4px 10px; }
.tx-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.tx-table th, .tx-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; vertical-align: middle; }
.tx-table th { color: var(--muted); font-weight: 600; font-size: .92em; }
.tx-table th:nth-child(-n+2), .tx-table td:nth-child(-n+2) { text-align: left; }
#open th:nth-child(3), #open td:nth-child(3) { text-align: left; }
.tx-table tfoot td { font-weight: 700; border-bottom: 0; }
.tx-table tr.tx-lot td { color: var(--muted); font-size: .92em; background: color-mix(in srgb, var(--surface2) 50%, transparent); }
.tx-table tr.tx-lot td .tx-pos, .tx-table tr.tx-lot td .tx-neg { font-weight: 400; }
.tx-toggle { min-height: 24px; min-width: 28px; padding: 0 6px; }
.tx-pos { color: var(--ok); font-weight: 600; }
.tx-neg { color: var(--err); font-weight: 600; }
.tx-sort { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; white-space: nowrap; }
.tx-sort:hover, .tx-sort[aria-sort] { color: var(--text); }
.tx-prose p { max-width: none; }

/* ---------- positions on other accounts: full width, one line per position ---------- */
.tx-table.tx-mtable th, .tx-table.tx-mtable td { padding: 4px 6px; }
.tx-table.tx-mtable th:nth-child(-n+5), .tx-table.tx-mtable td:nth-child(-n+5) { text-align: left; }
.tx-mtable input { min-height: 28px; padding: 2px 6px; }
.tx-mtable .tx-w-acc { width: 80px; }
.tx-mtable .tx-w-name { width: 100%; min-width: 110px; max-width: none; }
.tx-mtable .tx-w-vol { width: 80px; }
.tx-mtable .tx-w-price { width: 100px; }
.tx-mtable td.tx-calc { color: var(--muted); }
.tx-price { display: flex; gap: 4px; align-items: center; }
.tx-unit { white-space: nowrap; min-height: 28px; padding: 0 6px; }

/* ---------- proposal and charts side by side, same height ---------- */
.tx-layout { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
.tx-layout > [hidden] + .tx-charts { grid-column: 1 / -1; }
#plan .tx-table th { white-space: normal; }
#plan .tx-table td:first-child { white-space: normal; }
@media (max-width: 1100px) { .tx-layout { grid-template-columns: minmax(0, 1fr); } }

/* ---------- charts: stacked bars, the bar form of a pie ---------- */
.tx-charts { --tx-c1: #2e1170; --tx-c2: #3f2fa3; --tx-c3: #3d55b8; --tx-c4: #3a74c6; --tx-c5: #3593d2; --tx-c6: #33b0da;
  --tx-c7: #52c8e2; --tx-c8: #93dcec; --tx-c0: #5b6478; }
/* "Graphite" follows the second reference picture: slate greys and navy first, then blue, violet, wine and amber. */
.tx-charts.pal-graphite { --tx-c1: #2b3442; --tx-c2: #4a5366; --tx-c3: #6c7587; --tx-c4: #a2a8b4; --tx-c5: #1d3368; --tx-c6: #4767c0;
  --tx-c7: #7d56b5; --tx-c8: #8d3158; --tx-c0: #c47c2b; }
.tx-charts.pal-muted { --tx-c1: #7aa2f7; --tx-c2: #bb9af7; --tx-c3: #7dcfff; --tx-c4: #9ece6a; --tx-c5: #e0af68; --tx-c6: #f7768e;
  --tx-c7: #73daca; --tx-c8: #ff9e64; --tx-c0: #6b7089; }
html.light .tx-charts.pal-muted { --tx-c1: #3d63c9; --tx-c2: #8a5cd6; --tx-c3: #1f8fb8; --tx-c4: #5f8f2e; --tx-c5: #b07a1e; --tx-c6: #c9475f;
  --tx-c7: #2a9d8f; --tx-c8: #d06a2a; --tx-c0: #9aa0b4; }
/* Shades of the accent chosen in the Appearance panel, from full colour towards the background. */
.tx-charts.pal-accent { --tx-c1: var(--accent); --tx-c2: color-mix(in oklab, var(--accent) 72%, var(--bg1));
  --tx-c3: color-mix(in oklab, var(--accent) 52%, var(--bg1)); --tx-c4: color-mix(in oklab, var(--accent) 86%, var(--bg1));
  --tx-c5: color-mix(in oklab, var(--accent) 38%, var(--bg1)); --tx-c6: color-mix(in oklab, var(--accent) 62%, var(--bg1));
  --tx-c7: color-mix(in oklab, var(--accent) 45%, var(--bg1)); --tx-c8: color-mix(in oklab, var(--accent) 78%, var(--bg1));
  --tx-c0: color-mix(in oklab, var(--accent) 25%, var(--bg1)); }
.tx-charts.pal-aurora { --tx-c1: #818cf8; --tx-c2: #22d3ee; --tx-c3: #c084fc; --tx-c4: #34d399; --tx-c5: #f472b6; --tx-c6: #fbbf24;
  --tx-c7: #60a5fa; --tx-c8: #fb923c; --tx-c0: #94a3b8; }
.tx-charts.pal-vivid { --tx-c1: #338ced; --tx-c2: #e76624; --tx-c3: #00a888; --tx-c4: #d28e05; --tx-c5: #e24d8b; --tx-c6: #0aac23;
  --tx-c7: #9887ef; --tx-c8: #eb6263; --tx-c0: #8a8f98; }

.tx-chart { display: grid; gap: 8px; min-width: 0; padding: 10px 0; border-top: 1px solid var(--line); }
.tx-chart:first-child { border-top: 0; padding-top: 2px; }
.tx-chart h3 { margin: 0; font-size: 1em; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tx-chart h3 small { color: var(--muted); font-weight: 400; }
.tx-stack { display: flex; height: 32px; width: 100%; border-radius: 6px; overflow: hidden; gap: 2px; }
.tx-chart.tx-big .tx-stack { height: 42px; }
.tx-stack > div { display: grid; place-items: center; min-width: 2px; font-weight: 700; font-size: .9em; white-space: nowrap; overflow: hidden; }
/* Legend: items flow into as many columns as fit; amount and share sit right next to the name. */
/* Legend: one item per row; names, amounts and shares aligned in columns right next to each other. */
.tx-legend { display: grid; grid-template-columns: 12px minmax(0, max-content) max-content max-content; gap: 5px 12px; align-items: center;
  font-size: .95em; font-variant-numeric: tabular-nums; }
.tx-legend > div { display: contents; }
.tx-legend span:nth-child(2) { overflow-wrap: anywhere; }
.tx-legend span:nth-child(3) { text-align: right; white-space: nowrap; }
.tx-legend span:nth-child(4) { text-align: right; white-space: nowrap; color: var(--muted); }
.tx-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
p.tx-otherlist { margin: 0; font-size: .85em; color: var(--muted); line-height: 1.4; }

/* ---------- chart colours inside the Appearance panel (this app only) ---------- */
.drawer .tx-palgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.drawer .tx-palbtn { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-btn);
  background: var(--surface2); color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.drawer .tx-palbtn.on { outline: 2px solid var(--text); outline-offset: 1px; }
.tx-paldots { display: inline-flex; gap: 2px; flex: none; }
.tx-paldots b { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.tx-dot-indigo-1 { background: #2e1170; } .tx-dot-indigo-2 { background: #3a74c6; } .tx-dot-indigo-3 { background: #52c8e2; }
.tx-dot-graphite-1 { background: #2b3442; } .tx-dot-graphite-2 { background: #6c7587; } .tx-dot-graphite-3 { background: #4767c0; }
.tx-dot-muted-1 { background: #7aa2f7; } .tx-dot-muted-2 { background: #bb9af7; } .tx-dot-muted-3 { background: #9ece6a; }
.tx-dot-aurora-1 { background: #818cf8; } .tx-dot-aurora-2 { background: #22d3ee; } .tx-dot-aurora-3 { background: #c084fc; }
.tx-dot-vivid-1 { background: #338ced; } .tx-dot-vivid-2 { background: #e76624; } .tx-dot-vivid-3 { background: #00a888; }
.tx-dot-accent-1 { background: var(--accent); }
.tx-dot-accent-2 { background: color-mix(in oklab, var(--accent) 62%, var(--bg1)); }
.tx-dot-accent-3 { background: color-mix(in oklab, var(--accent) 38%, var(--bg1)); }

/* ---------- top row: input card and positions on other accounts side by side, same height ---------- */
.tx-top { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); align-items: stretch; }
.tx-top .tx-inputgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 24px; }
.tx-top .tx-inputgrid > .tx-field:first-child { grid-row: span 2; }
.tx-table.tx-mtable th, .tx-table.tx-mtable td { width: 1%; }
.tx-table.tx-mtable th:nth-child(2), .tx-table.tx-mtable td.tx-namecell { width: auto; }
.tx-table.tx-mtable td.tx-calc, .tx-table.tx-mtable td:nth-child(8) { padding-left: 14px; }
@media (max-width: 1439px) {
  .tx-top { grid-template-columns: minmax(0, 1fr); }
  .tx-top .tx-inputgrid { grid-template-columns: repeat(auto-fill, minmax(300px, 400px)); }
  .tx-top .tx-inputgrid > .tx-field:first-child { grid-row: auto; }
  .tx-mtable .tx-w-name { max-width: 420px; }
}

/* ---------- charts card: whole portfolio on top, accounts side by side, spacing spread evenly ---------- */
#structcard { display: flex; flex-direction: column; }
#charts { flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; }
.tx-acccharts { display: grid; gap: 14px 24px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); border-top: 1px solid var(--line); padding-top: 12px; align-items: start; }
.tx-acccharts .tx-chart, #charts > .tx-chart { border-top: 0; padding: 0; }

/* The positions table never scrolls: on narrow screens every position becomes a small block with labelled fields. */
.tx-mwrap { overflow: visible; }
@media (max-width: 899px) {
  .tx-mtable thead { display: none; }
  .tx-mtable, .tx-mtable tbody { display: block; }
  .tx-mtable tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: 6px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .tx-table.tx-mtable td { display: block; width: auto; padding: 0; border: 0; text-align: left; }
  .tx-table.tx-mtable td::before { content: attr(data-label); display: block; font-size: .85em; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
  .tx-table.tx-mtable td.tx-namecell { grid-column: 1 / 3; }
  .tx-table.tx-mtable td:last-child { grid-column: 3; grid-row: 1; align-self: end; }
  .tx-table.tx-mtable td.tx-calc, .tx-table.tx-mtable td:nth-child(8) { padding-left: 0; }
  .tx-mtable .tx-w-name { max-width: none; }
}
/* Side by side with the input card the table gets narrower fields, so a position still fits one line. */
@media (min-width: 1440px) {
  .tx-table.tx-mtable th, .tx-table.tx-mtable td { padding: 4px 3px; }
  .tx-table.tx-mtable td.tx-calc, .tx-table.tx-mtable td:nth-child(8) { padding-left: 8px; }
  .tx-mtable .tx-w-acc { width: 62px; }
  .tx-mtable .tx-w-vol { width: 60px; }
  .tx-mtable .tx-w-price { width: 78px; }
  .tx-mtable .tx-w-name { min-width: 84px; }
  .tx-unit { padding: 0 5px; }
}
/* Medium screens: a little more width for the charts, so the three accounts stay in one row. */
@media (min-width: 1100px) and (max-width: 1799px) {
  .tx-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); }
  .tx-acccharts { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 16px; }
  .tx-acccharts .tx-legend { font-size: .9em; gap: 4px 8px; }
}

/* Positions panel only as wide as its content; the input card takes the rest. */
@media (min-width: 1440px) {
  .tx-top { grid-template-columns: minmax(0, 1fr) max-content; }
  .tx-top .tx-inputgrid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .tx-top .tx-inputgrid > .tx-field:first-child { grid-row: auto; }
  .tx-table.tx-mtable { width: auto; }
  .tx-table.tx-mtable th, .tx-table.tx-mtable td { width: auto; }
  .tx-mtable .tx-w-name { width: 150px; min-width: 0; max-width: 150px; }
}
@media (max-width: 1439px) {
  .tx-mtable .tx-w-name { max-width: 240px; }
}
/* Own price of an XTB position, typed in the open positions table. */
.tx-pricebox { display: inline-flex; align-items: center; gap: 4px; }
.tx-pricebox small { color: var(--muted); }
.tx-pricein { width: 84px; font: inherit; text-align: right; color: var(--text); background: var(--surface2); border: 1px solid var(--line);
  border-radius: var(--r-btn); min-height: 26px; padding: 1px 6px; box-sizing: border-box; }
.tx-pricein::placeholder { color: var(--muted); opacity: 1; }
.tx-pricein.tx-own { border-color: var(--accent-ring); box-shadow: inset 0 0 0 1px var(--accent-ring); }
/* The long hint must not decide the card's width: it wraps to the width of the table. */
.tx-manualcard > p.tx-hint { max-width: 860px; }
@media (min-width: 1440px) {
  .tx-top .tx-inputgrid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 20px; }
}
@media (min-width: 1440px) and (max-width: 1799px) {
  .tx-top .tx-inputgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 16px; }
  .tx-top .tx-inputgrid > .tx-field:first-child { grid-row: span 2; }
  .tx-top .tx-fxgrid { grid-template-columns: auto minmax(0, 120px); }
}

/* Wide screens: the positions panel gets about a fifth more width than its bare content, taken from the input card. */
@media (min-width: 1800px) {
  .tx-top { grid-template-columns: minmax(0, 44fr) minmax(0, 56fr); }
  .tx-table.tx-mtable { width: 100%; }
  .tx-table.tx-mtable th, .tx-table.tx-mtable td { width: 1%; }
  .tx-table.tx-mtable th:nth-child(2), .tx-table.tx-mtable td.tx-namecell { width: auto; }
  .tx-mtable .tx-w-name { width: 100%; max-width: 340px; }
  .tx-table.tx-mtable th, .tx-table.tx-mtable td { padding: 4px 5px; }
  .tx-table.tx-mtable td.tx-calc, .tx-table.tx-mtable td:nth-child(8) { padding-left: 14px; }
}
.tx-resetrow { margin: 0 0 6px; }

/* Price suffix (USD, EUR, PLN) in a fixed-width slot, so all inputs line up. */
.tx-pricebox small { display: inline-block; min-width: 30px; text-align: left; }

/* Positions on other accounts: more rows scroll inside the panel (no visible scrollbar) instead of making it taller. */
.tx-mwrap { overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain; }
.tx-mwrap::-webkit-scrollbar { display: none; }
.tx-mtable thead th { position: sticky; top: 0; z-index: 1;
  background: linear-gradient(var(--surface), var(--surface)), color-mix(in srgb, var(--bg1) 50%, var(--bg2)); }
@media (min-width: 1440px) {
  /* Side by side with the input card: the list fills the card's height and does not stretch it (contain: size). */
  .tx-manualcard { display: flex; flex-direction: column; }
  .tx-mwrap { flex: 1 1 0; contain: size; min-height: 230px; }
}
@media (max-width: 1439px) {
  .tx-mwrap { max-height: 420px; }
}

/* Fixed share of width per column, so the layout does not depend on what is typed (empty rows looked lopsided).
   Applies where the table has spare width: wide screens (side by side) and narrow screens (full width). */
@media (min-width: 1800px), (min-width: 900px) and (max-width: 1439px) {
  .tx-table.tx-mtable { table-layout: fixed; width: 100%; }
  .tx-table.tx-mtable th, .tx-table.tx-mtable td { width: auto; overflow: hidden; }
  .tx-mtable col.tx-c-acc { width: 7%; }
  .tx-mtable col.tx-c-name { width: 20%; }
  .tx-mtable col.tx-c-vol { width: 7%; }
  .tx-mtable col.tx-c-price { width: 14%; }
  .tx-mtable col.tx-c-calc { width: 11%; }
  .tx-mtable col.tx-c-del { width: 4%; }
  .tx-mtable .tx-w-acc, .tx-mtable .tx-w-vol, .tx-mtable .tx-w-name { width: 100%; min-width: 0; max-width: none; }
  .tx-mtable .tx-price .tx-w-price { width: auto; flex: 1 1 auto; min-width: 0; }
  .tx-table.tx-mtable th { white-space: normal; }
  .tx-table.tx-mtable td.tx-calc, .tx-table.tx-mtable td:nth-child(8) { padding-left: 6px; }
}
/* 1440-1799 px: fixed 40/60 split too, and the same fixed column shares, so empty and filled rows look the same. */
@media (min-width: 1440px) and (max-width: 1799px) {
  .tx-top { grid-template-columns: minmax(0, 40fr) minmax(0, 60fr); }
  .tx-manualcard > p.tx-hint { max-width: none; }
  .tx-table.tx-mtable { table-layout: fixed; width: 100%; }
  .tx-table.tx-mtable th, .tx-table.tx-mtable td { width: auto; overflow: hidden; padding: 4px 3px; }
  .tx-mtable col.tx-c-acc { width: 7%; }
  .tx-mtable col.tx-c-name { width: 16%; }
  .tx-mtable col.tx-c-vol { width: 7%; }
  .tx-mtable col.tx-c-price { width: 15.5%; }
  .tx-mtable col.tx-c-calc { width: 11%; }
  .tx-mtable col.tx-c-del { width: 6%; }
  .tx-mtable .tx-w-acc, .tx-mtable .tx-w-vol, .tx-mtable .tx-w-name { width: 100%; min-width: 0; max-width: none; }
  .tx-mtable .tx-price .tx-w-price { width: auto; flex: 1 1 auto; min-width: 0; }
  .tx-table.tx-mtable th { white-space: normal; }
  .tx-table.tx-mtable td.tx-calc, .tx-table.tx-mtable td:nth-child(8) { padding-left: 4px; }
}
@media (min-width: 1440px) and (max-width: 1799px) {
  .tx-top { grid-template-columns: minmax(0, 38fr) minmax(0, 62fr); }
  .tx-mtable col.tx-c-acc { width: 8%; }
  .tx-mtable col.tx-c-name { width: 16%; }
  .tx-mtable col.tx-c-vol { width: 6.5%; }
  .tx-mtable col.tx-c-price { width: 16.5%; }
  .tx-mtable col.tx-c-calc { width: 10.5%; }
  .tx-mtable col.tx-c-del { width: 5%; }
}
/* Unit switch: short labels of equal width, so the price input keeps its room. */
.tx-mtable .tx-unit { min-width: 58px; padding: 0 4px; justify-content: center; text-align: center; }
@media (min-width: 1800px), (min-width: 900px) and (max-width: 1439px) {
  .tx-mtable col.tx-c-name { width: 16%; }
  .tx-mtable col.tx-c-price { width: 16%; }
  .tx-mtable col.tx-c-del { width: 5%; }
}
@media (min-width: 1440px) and (max-width: 1799px) {
  .tx-mtable col.tx-c-acc { width: 8%; }
  .tx-mtable col.tx-c-name { width: 14%; }
  .tx-mtable col.tx-c-vol { width: 6%; }
  .tx-mtable col.tx-c-price { width: 18%; }
  .tx-mtable col.tx-c-calc { width: 10%; }
  .tx-mtable col.tx-c-del { width: 6%; }
}
@media (min-width: 1440px) and (max-width: 1799px) {
  .tx-mtable col.tx-c-name { width: 13%; }
  .tx-mtable col.tx-c-vol { width: 7%; }
}
