/* ---- Chart of accounts tree & chart levels (R12): level colours, highlight, level filter chips, context menu, details panel.
   A level colour arrives as the CSS variable --lvl (inline style); it is always mixed with the theme surface so text stays readable
   in light and dark themes. Logical properties (inline-start) keep the stripe on the reading side in Arabic. */

/* level colour: a stripe on the code cell + a soft tint (only levels that have a colour get the class) */
.grid.chart-tree tr.lvl-colored td { background: color-mix(in srgb, var(--lvl) 7%, var(--surface)); }
.grid.chart-tree tr.lvl-colored.header-row td { background: color-mix(in srgb, var(--lvl) 12%, var(--surface)); }
.grid.chart-tree tr.lvl-colored td:first-child { box-shadow: inset 4px 0 0 var(--lvl); }
[dir="rtl"] .grid.chart-tree tr.lvl-colored td:first-child { box-shadow: inset -4px 0 0 var(--lvl); }
.level-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
    font-family: var(--mono); font-size: 12px; font-weight: 600; border: 1px solid var(--lvl, var(--border));
    background: color-mix(in srgb, var(--lvl, var(--gray-bg)) 18%, var(--surface)); color: color-mix(in srgb, var(--lvl, var(--text)) 55%, var(--text)); }

/* rows: keyboard focus, highlighted account and the path to it */
.grid.chart-tree tbody tr { cursor: default; scroll-margin: 96px 0; }
.grid.chart-tree tbody tr:focus { outline: none; }
.grid.chart-tree tbody tr:focus-visible td { outline: 2px solid var(--primary); outline-offset: -2px; }
.grid.chart-tree tr.path-row td { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.grid.chart-tree tr.path-row td:nth-child(2) { color: var(--primary); }
.grid.chart-tree tr.focus-row td { background: color-mix(in srgb, var(--primary) 20%, var(--surface)); font-weight: 600;
    border-bottom-color: color-mix(in srgb, var(--primary) 45%, var(--surface)); }
.grid.chart-tree tr.focus-row td:first-child { box-shadow: inset 4px 0 0 var(--primary); }
[dir="rtl"] .grid.chart-tree tr.focus-row td:first-child { box-shadow: inset -4px 0 0 var(--primary); }
.grid.chart-tree tr.focus-row.lvl-colored td:first-child { box-shadow: inset 4px 0 0 var(--lvl), inset 7px 0 0 var(--primary); }
[dir="rtl"] .grid.chart-tree tr.focus-row.lvl-colored td:first-child { box-shadow: inset -4px 0 0 var(--lvl), inset -7px 0 0 var(--primary); }
/* parents shown only for context while filtering by level */
.grid.chart-tree tr.context-row td { color: var(--muted); opacity: .62; font-weight: 400; }

/* level filter chips */
.level-filter .level-chip { border: 1px solid var(--border); cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }
.level-filter .level-chip:hover { border-color: var(--primary); }
.level-filter .level-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.level-filter .level-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.level-chip .level-count { font-family: var(--mono); font-weight: 500; opacity: .8; padding-inline-start: 2px; }
.level-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--lvl); box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 25%, transparent); }
.level-chip[style*="--lvl"]:not(.on) { background: color-mix(in srgb, var(--lvl) 12%, var(--surface)); color: var(--text); }

/* context menu (position comes inline) */
.ctx-menu { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .22); display: flex; flex-direction: column; }
.ctx-head { padding: 6px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--row-line); margin-bottom: 4px;
    max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent;
    color: inherit; font: inherit; font-size: 13px; text-align: start; cursor: pointer; }
.ctx-item:hover, .ctx-item:focus-visible { background: var(--green-bg); color: var(--green-fg); outline: none; }
.ctx-sep { height: 1px; background: var(--row-line); margin: 4px 2px; }

/* details panel */
.account-details .details-list { margin: 8px 0 14px; }
.account-details .details-list dd.num { text-align: start; }

/* chart levels screen */
.level-color-edit { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.level-color-input { width: 36px; height: 30px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; }
.level-color-text.invalid { border-color: var(--danger); }
