/*
 * Admin -> Skills -> Skills & rules (App\Filament\Admin\Pages\SkillsAndRules; resources/views/filament/admin/pages/skills-rules*).
 * The approved mockup's layout (tree | content | inspector, step flow, rule cards, level colours) on Filament's colour
 * variables, light and dark (html.dark). Filament's prebuilt CSS has no Tailwind utilities, so the styles are here;
 * registered as FilamentAsset 'skills-rules' - run `php artisan filament:assets` after editing.
 */
.tbx-rx { --rx-line: var(--gray-200, #e5e7eb); --rx-panel: #fff; --rx-panel2: var(--gray-50, #f9fafb); --rx-ink: var(--gray-950, #030712);
    --rx-ink2: var(--gray-600, #4b5563); --rx-ink3: var(--gray-400, #9ca3af); --rx-brand: var(--primary-600, #5b3df5);
    --rx-brand-soft: color-mix(in srgb, var(--primary-500, #6366f1) 12%, transparent);
    --rx-ok: var(--success-600, #16a34a); --rx-warn: var(--warning-600, #d97706); --rx-bad: var(--danger-600, #dc2626); font-size: .8125rem; }
.dark .tbx-rx { --rx-line: rgb(255 255 255 / .1); --rx-panel: var(--gray-900, #111827); --rx-panel2: rgb(255 255 255 / .03);
    --rx-ink: #fff; --rx-ink2: var(--gray-400, #9ca3af); --rx-ink3: var(--gray-500, #6b7280); --rx-brand: var(--primary-400, #818cf8); }
.tbx-rx [data-level] { --lv: #64748b; }
.tbx-rx [data-level="global"] { --lv: #6366f1; }
.tbx-rx [data-level="discipline"] { --lv: #0891b2; }
.tbx-rx [data-level="application"] { --lv: #059669; }
.tbx-rx [data-level="line"] { --lv: #d97706; }
.tbx-rx [data-level="equipment"] { --lv: #db2777; }
.tbx-rx [data-level="company"] { --lv: #64748b; }

.tbx-rx code { font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; font-size: .92em; background: var(--rx-panel2); border-radius: .25rem; padding: 0 .2rem; }
.tbx-rx-mono, .tbx-rx-id, .tbx-rx-src { font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; }
.tbx-rx-muted { color: var(--rx-ink3); }
.tbx-rx a.tbx-rx-link, .tbx-rx button.tbx-rx-link { color: var(--rx-brand); text-decoration: underline; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }

/* the search, the filters */
.tbx-rx-top { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.tbx-rx-search { flex: 1; min-width: 14rem; max-width: 40rem; }
.tbx-rx-input, .tbx-rx select, .tbx-rx textarea { width: 100%; border: 1px solid var(--rx-line); background: var(--rx-panel); color: var(--rx-ink);
    border-radius: .5rem; padding: .45rem .6rem; font: inherit; }
.tbx-rx textarea { min-height: 6rem; resize: vertical; }
.tbx-rx select.tbx-rx-inline { width: auto; max-width: 100%; }
.tbx-rx-filters { display: flex; gap: .375rem; flex-wrap: wrap; align-items: center; }
.tbx-rx-filters .tbx-rx-lbl { color: var(--rx-ink3); font-size: .6875rem; text-transform: uppercase; letter-spacing: .05em; margin-left: .375rem; }
.tbx-rx-chip { border: 1px solid var(--rx-line); background: var(--rx-panel); color: var(--rx-ink2); border-radius: 999px; padding: .125rem .625rem;
    font-size: .75rem; cursor: pointer; display: inline-flex; gap: .3rem; align-items: center; }
.tbx-rx-chip.is-on { border-color: var(--rx-brand); color: var(--rx-brand); background: var(--rx-brand-soft); }

/* the three columns */
.tbx-rx-work { display: grid; grid-template-columns: 17rem minmax(0, 1fr) 24rem; border: 1px solid var(--rx-line); border-radius: .75rem;
    background: var(--rx-panel); overflow: hidden; min-height: 65vh; }
.tbx-rx-work.no-insp { grid-template-columns: 17rem minmax(0, 1fr); }
.tbx-rx-tree, .tbx-rx-content, .tbx-rx-insp { overflow: auto; max-height: calc(100vh - 13rem); min-width: 0; }
.tbx-rx-tree { border-right: 1px solid var(--rx-line); padding: .5rem .375rem 2rem; }
.tbx-rx-tree .tbx-rx-input { margin: 0 0 .5rem; padding: .3rem .5rem; font-size: .75rem; }
.tbx-rx-content { padding: 1rem 1.25rem 2.5rem; background: var(--rx-panel2); }
.tbx-rx-insp { border-left: 1px solid var(--rx-line); }
@media (max-width: 1279px) {
    .tbx-rx-work, .tbx-rx-work.no-insp { grid-template-columns: 15rem minmax(0, 1fr); }
    .tbx-rx-insp { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--rx-line); max-height: none; }
}
@media (max-width: 767px) {
    .tbx-rx-work, .tbx-rx-work.no-insp { grid-template-columns: minmax(0, 1fr); }
    .tbx-rx-tree { max-height: 18rem; border-right: 0; border-bottom: 1px solid var(--rx-line); }
    .tbx-rx-content { max-height: none; padding: .875rem 1rem 2rem; }
}

/* the tree */
.tbx-rx-node { display: flex; align-items: center; gap: .25rem; padding: .125rem .25rem; border-radius: .375rem; white-space: nowrap; }
.tbx-rx-node:hover { background: var(--rx-panel2); }
.tbx-rx-node.is-sel { background: var(--rx-brand-soft); }
.tbx-rx-node.is-sel .tbx-rx-nlabel { color: var(--rx-brand); font-weight: 600; }
.tbx-rx-node.is-muted { opacity: .55; }
.tbx-rx-tw { width: 1rem; flex: none; color: var(--rx-ink3); font-size: .625rem; background: none; border: 0; padding: 0; cursor: pointer; text-align: center; }
.tbx-rx-nlabel { display: inline-flex; align-items: center; gap: .375rem; min-width: 0; background: none; border: 0; padding: .125rem 0; color: var(--rx-ink);
    cursor: pointer; font: inherit; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.tbx-rx-nlabel span:last-child { overflow: hidden; text-overflow: ellipsis; }
.tbx-rx-n { margin-left: auto; color: var(--rx-ink3); font-size: .6875rem; padding-left: .375rem; }
.tbx-rx-kids { margin-left: .625rem; border-left: 1px dashed var(--rx-line); padding-left: .25rem; }
.tbx-rx-lv { width: .5rem; height: .5rem; border-radius: 2px; display: inline-block; flex: none; background: var(--lv); }
.tbx-rx-swatch { width: .75rem; height: .75rem; border-radius: 3px; display: inline-block; flex: none; border: 1px solid var(--rx-line); vertical-align: middle; }
.tbx-rx-dot { font-size: .625rem; }
.tbx-rx-dot[data-st="approved"] { color: var(--rx-ok); }
.tbx-rx-dot[data-st="under_review"] { color: var(--rx-warn); }
.tbx-rx-dot[data-st="untrained"] { color: var(--rx-ink3); }

/* headings, cards */
.tbx-rx-h2 { font-size: 1.125rem; font-weight: 700; margin: 0 0 .25rem; color: var(--rx-ink); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.tbx-rx-sub { color: var(--rx-ink2); margin: 0 0 .875rem; }
.tbx-rx-card { background: var(--rx-panel); border: 1px solid var(--rx-line); border-radius: .625rem; padding: .875rem; margin-bottom: .875rem; }
.tbx-rx-card h3 { margin: 0 0 .5rem; font-size: .8125rem; font-weight: 600; color: var(--rx-ink); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.tbx-rx-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: .75rem; }
.tbx-rx-grid2 > .tbx-rx-card { margin-bottom: 0; }
.tbx-rx-stack { display: flex; flex-direction: column; gap: .875rem; }
/* a line's eligible applications in words (App\Library\UseWords), one under another */
.tbx-rx-uses { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .5rem; font-size: .75rem; overflow-wrap: anywhere; }
.tbx-rx-uses > li > div { margin-top: .125rem; }
.tbx-rx-kv { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: .25rem .75rem; font-size: .75rem; }
.tbx-rx-kv > dt { color: var(--rx-ink3); margin: 0; }
.tbx-rx-kv > dd { margin: 0; overflow-wrap: anywhere; display: flex; gap: .375rem; align-items: flex-start; justify-content: space-between; }
.tbx-rx-kv > dd > span { min-width: 0; flex: 1 1 auto; }
.tbx-rx-kv > dd > button, .tbx-rx-card h3 > button { flex: none; white-space: nowrap; }
.tbx-rx-count { background: var(--rx-line); color: var(--rx-ink2); border-radius: 999px; padding: 0 .4rem; font-size: .6875rem; font-weight: 600; }
.tbx-rx-badge { display: inline-flex; align-items: center; gap: .25rem; border-radius: 999px; padding: .05rem .5rem; font-size: .6875rem; font-weight: 600;
    background: color-mix(in srgb, var(--lv) 15%, transparent); color: var(--lv); white-space: nowrap; }
.tbx-rx-fmt { font-size: .625rem; border: 1px solid var(--rx-line); border-radius: .25rem; padding: 0 .3rem; color: var(--rx-ink2); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.tbx-rx-st { font-size: .6875rem; font-weight: 600; white-space: nowrap; }
.tbx-rx-st.is-ok, .tbx-rx-st[data-st="approved"], .tbx-rx-st[data-st="applied"] { color: var(--rx-ok); }
.tbx-rx-st.is-warn, .tbx-rx-st[data-st="under_review"], .tbx-rx-st[data-st="draft"], .tbx-rx-st[data-st="proposed"], .tbx-rx-st[data-st="pending"] { color: var(--rx-warn); }
.tbx-rx-st.is-bad, .tbx-rx-st[data-st="rejected"] { color: var(--rx-bad); }
.tbx-rx-st.is-mute, .tbx-rx-st[data-st="untrained"] { color: var(--rx-ink3); }
.tbx-rx-holds { font-size: .625rem; font-weight: 700; color: var(--rx-bad); border: 1px solid var(--rx-bad); border-radius: .25rem; padding: 0 .25rem; }
.tbx-rx-cond { display: inline-block; border: 1px dashed var(--rx-line); border-radius: .375rem; padding: 0 .4rem; margin: .125rem .25rem .125rem 0; font-size: .75rem; color: var(--rx-ink2); background: none; }
button.tbx-rx-cond { cursor: pointer; }
.tbx-rx-note { font-size: .75rem; color: var(--rx-ink2); background: var(--rx-panel2); border: 1px solid var(--rx-line); border-radius: .5rem; padding: .5rem .625rem; }
.tbx-rx-warnbox { font-size: .75rem; border: 1px solid color-mix(in srgb, var(--rx-warn) 40%, transparent); background: color-mix(in srgb, var(--rx-warn) 8%, transparent);
    border-radius: .5rem; padding: .5rem .625rem; color: var(--rx-ink); }
.tbx-rx-bad { color: var(--rx-bad); font-weight: 600; }
.tbx-rx-legend { display: flex; gap: .75rem; flex-wrap: wrap; font-size: .6875rem; color: var(--rx-ink2); margin-top: .25rem; }
.tbx-rx-legend span { display: inline-flex; gap: .3rem; align-items: center; }

/* the step flow */
.tbx-rx-flow { display: flex; overflow-x: auto; padding: .25rem .125rem .625rem; align-items: stretch; }
.tbx-rx-step { min-width: 8.5rem; max-width: 10.5rem; background: var(--rx-panel2); border: 1px solid var(--rx-line); border-radius: .625rem; padding: .5rem .625rem;
    cursor: pointer; text-align: left; font: inherit; color: var(--rx-ink); display: flex; flex-direction: column; gap: .125rem; }
.tbx-rx-step:hover { border-color: var(--rx-brand); }
.tbx-rx-step.is-sel { border-color: var(--rx-brand); background: var(--rx-brand-soft); }
.tbx-rx-step.is-sub { min-width: 7rem; border-style: dashed; }
.tbx-rx-step .tbx-rx-no { font-size: .625rem; color: var(--rx-ink3); font-weight: 700; text-transform: uppercase; }
.tbx-rx-step .tbx-rx-t { font-weight: 600; line-height: 1.25; }
.tbx-rx-step .tbx-rx-m { font-size: .6875rem; color: var(--rx-ink2); overflow-wrap: anywhere; }
.tbx-rx-arrow { align-self: center; color: var(--rx-ink3); padding: 0 .3rem; }

/* rule cards */
.tbx-rx-rule { border: 1px solid var(--rx-line); border-radius: .625rem; padding: .5rem .75rem; margin-bottom: .5rem; background: var(--rx-panel); cursor: pointer;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .625rem; }
.tbx-rx-rule:hover, .tbx-rx-rule:focus-visible { border-color: var(--rx-brand); outline: none; }
.tbx-rx-rule.is-sel { border-color: var(--rx-brand); box-shadow: 0 0 0 2px var(--rx-brand-soft); }
.tbx-rx-rule .tbx-rx-id { font-size: .6875rem; color: var(--rx-ink3); }
.tbx-rx-rule .tbx-rx-tt { font-weight: 600; color: var(--rx-ink); }
.tbx-rx-rule .tbx-rx-tx { grid-column: 1 / -1; color: var(--rx-ink2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tbx-rx-rule .tbx-rx-meta { grid-column: 1 / -1; display: flex; gap: .375rem; flex-wrap: wrap; align-items: center; }
.tbx-rx-src { font-size: .6875rem; color: var(--rx-ink3); overflow-wrap: anywhere; }
.tbx-rx-more { margin-top: .25rem; }

/* the inspector */
.tbx-rx-insp-hd { padding: .875rem 1rem; border-bottom: 1px solid var(--rx-line); position: sticky; top: 0; background: var(--rx-panel); z-index: 1; }
.tbx-rx-insp-hd .tbx-rx-title { font-weight: 700; font-size: .875rem; margin: .125rem 0 .375rem; color: var(--rx-ink); }
.tbx-rx-insp-bd { padding: .25rem 1rem 2.5rem; }
.tbx-rx-insp-bd h4 { margin: 1rem 0 .375rem; font-size: .6875rem; color: var(--rx-ink3); text-transform: uppercase; letter-spacing: .06em; }
.tbx-rx-ro { background: var(--rx-panel2); border: 1px solid var(--rx-line); border-radius: .5rem; padding: .5rem .625rem; overflow-wrap: anywhere; color: var(--rx-ink); }
.tbx-rx-ro pre, .tbx-rx-pre { margin: 0; white-space: pre-wrap; font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; font-size: .6875rem; max-height: 18rem; overflow: auto; }
.tbx-rx-btns { display: flex; gap: .375rem; flex-wrap: wrap; margin-top: .625rem; align-items: center; }
.tbx-rx-field { display: flex; flex-direction: column; gap: .25rem; margin-top: .625rem; }
.tbx-rx-field label { font-size: .75rem; color: var(--rx-ink2); font-weight: 500; }
.tbx-rx-err { color: var(--rx-bad); font-size: .75rem; }
.tbx-rx-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .25rem .75rem; max-height: 16rem; overflow: auto;
    border: 1px solid var(--rx-line); border-radius: .5rem; padding: .5rem; }
.tbx-rx-checks label { display: flex; gap: .375rem; align-items: flex-start; font-size: .75rem; color: var(--rx-ink); }
.tbx-rx-hist { border-left: 2px solid var(--rx-line); margin-left: .375rem; padding-left: .75rem; }
.tbx-rx-hist > div { margin-bottom: .625rem; position: relative; font-size: .75rem; }
.tbx-rx-hist > div::before { content: ""; position: absolute; left: -1.15rem; top: .3rem; width: .5rem; height: .5rem; border-radius: 50%; background: var(--rx-brand); }

/* diffs */
.tbx-rx-diff del { background: color-mix(in srgb, var(--rx-bad) 18%, transparent); text-decoration: line-through; border-radius: .2rem; padding: 0 .15rem; }
.tbx-rx-diff ins { background: color-mix(in srgb, var(--rx-ok) 18%, transparent); text-decoration: none; border-radius: .2rem; padding: 0 .15rem; }
.tbx-rx-diff .tbx-rx-item { border: 1px solid var(--rx-line); border-radius: .2rem; padding: 0 .15rem; }
.tbx-rx-diff { overflow-wrap: anywhere; max-height: 14rem; overflow: auto; }
.tbx-rx-was { margin-bottom: .375rem; }

/* tables */
.tbx-rx table { width: 100%; border-collapse: collapse; font-size: .75rem; }
.tbx-rx th, .tbx-rx td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--rx-line); vertical-align: top; color: var(--rx-ink); }
.tbx-rx th { color: var(--rx-ink3); font-weight: 600; font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; }
.tbx-rx-table-wrap { overflow-x: auto; }
.tbx-rx td.tbx-rx-heat { text-align: center; font-weight: 600; background: color-mix(in srgb, #059669 calc(min(var(--n, 0), 4) * 14%), transparent); }
.tbx-rx td.tbx-rx-heat.is-zero { color: var(--rx-bad); background: color-mix(in srgb, var(--rx-bad) 7%, transparent); }
.tbx-rx-group td { background: var(--rx-panel2); font-weight: 600; color: var(--rx-ink2); }

/* effective rules */
.tbx-rx-layers { display: flex; flex-direction: column; gap: .5rem; }
.tbx-rx-layer { border: 1px solid var(--rx-line); border-left: 5px solid var(--lv); border-radius: .625rem; padding: .625rem .75rem; background: var(--rx-panel); }
.tbx-rx-layer .tbx-rx-lh { display: flex; gap: .5rem; align-items: center; font-weight: 600; margin-bottom: .375rem; flex-wrap: wrap; color: var(--rx-ink); }
.tbx-rx-layer ul { margin: .25rem 0 0; padding-left: 1.1rem; color: var(--rx-ink2); list-style: disc; }
.tbx-rx-layer li { margin: .125rem 0; }
.tbx-rx-pickers { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .625rem; align-items: start; }
.tbx-rx-found { display: flex; flex-direction: column; gap: .125rem; margin-top: .25rem; border: 1px solid var(--rx-line); border-radius: .5rem; padding: .25rem; }
.tbx-rx-found button { text-align: left; background: none; border: 0; padding: .25rem .375rem; border-radius: .375rem; cursor: pointer; font: inherit; color: var(--rx-ink); }
.tbx-rx-found button:hover { background: var(--rx-brand-soft); }
