/* ==========================================================================
   SECTION: CSS - CORE THEME & VARIABLES
   ========================================================================== */
:root {
    --bg: #1a1a1a;
    --text: #e0e0e0;
    --accent: #4caf50;
    --panel: #2d2d2d;
    --border: #444;
    --warn: #ff9800;
    --gold: #ffd700;
    --info: #2196f3;
    --profit: #00e676;
    --bio: #76ff03;
    --fuel: #ff5722;
    --danger: #f44336;
    --row-id: #4fc3f7;
    --byproduct: #9c27b0;
    --thumb-size: 14px;
    /* Variable for slider thumb calculations */
}

/* Currency Colors */
.curr-g {
    color: #ffd700;
    font-weight: bold;
}

.cap-warning {
    color: #FF7700;
    /* Dark Orange as requested */
    font-weight: bold;
    cursor: help;
    margin-right: 6px;
    font-size: 1.1em;
    vertical-align: middle;
}

.curr-s {
    color: #e0e0e0;
    font-weight: bold;
}

/* Silver */
.curr-c {
    color: #cd7f32;
    font-weight: bold;
}

/* Copper */

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 0;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 13px;
}

/* ==========================================================================
   SECTION: CSS - LAYOUT & GRID
   ========================================================================== */
header {
    background: #111;
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

h1 {
    color: var(--accent);
    margin: 0;
    font-size: 1.1em;
}

.repo-link {
    color: #888;
    text-decoration: none;
    font-size: 0.9em;
    margin-right: 15px;
    border: 1px solid #444;
    padding: 4px 8px;
    border-radius: 4px;
    transition: 0.2s;
}

.repo-link:hover {
    color: #fff;
    border-color: #666;
    background: #222;
}

.subtitle {
    color: #888;
    font-size: 0.8em;
    margin-left: 10px;
    cursor: pointer;
    text-decoration: underline;
}

.subtitle:hover {
    color: #fff;
}

.tabs {
    display: flex;
    gap: 5px;
}

.tab-btn {
    background: #222;
    border: 1px solid var(--border);
    color: #888;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9em;
}

.tab-btn:hover {
    background: #333;
    color: #fff;
}

.tab-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    font-weight: bold;
}

main {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 15px;
    display: none;
}

.view.active {
    display: block;
}

.app-grid {
    display: grid;
    grid-template-columns: 260px 1fr 280px 220px;
    gap: 15px;
    max-width: 1920px;
    margin: 0 auto;
    height: 100%;
}

.row-spread {
    display: flex;
    justify-content: space-between;
    gap: 5px;
}

.panel {
    background: var(--panel);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 15px;
}

.panel h3 {
    margin-top: 0;
    color: #fff;
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
    font-size: 1.05em;
    margin-bottom: 10px;
}

/* ==========================================================================
   SECTION: CSS - CONTROLS & INPUTS
   ========================================================================== */
.input-group {
    margin-bottom: 12px;
    position: relative;
}

label {
    display: block;
    font-size: 0.85em;
    color: #aaa;
    margin-bottom: 4px;
}

select {
    width: 100%;
    padding: 6px;
    background: #333;
    border: 1px solid #555;
    color: white;
    border-radius: 4px;
    font-size: 1em;
}

/* ==========================================================================
   SECTION: CSS - SLIDER COMPONENTS
   ========================================================================== */
.slider-container {
    position: relative;
    width: 100%;
    height: 50px;
    margin-top: 5px;
}

input[type=range] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    position: relative;
    z-index: 10;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: #444;
    border-radius: 3px;
}

/* THUMB: Downward Triangle Pointer */
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: var(--thumb-size);
    width: var(--thumb-size);
    background: var(--accent);
    margin-top: -6px;
    /* Center on track */
    border: none;
    clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
    transform: none;
    border-radius: 0;
    position: relative;
    z-index: 20;
}

input[type=range]:focus {
    outline: none;
}

.slider-ticks {
    position: absolute;
    top: 14px;
    left: 0;
    right: 0;
    height: 20px;
    pointer-events: none;
}

.tick-mark {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translateX(-50%);
}

.tick-line {
    width: 1px;
    height: 6px;
    background: #666;
    margin-bottom: 2px;
}

.tick-mark.labeled .tick-line {
    height: 8px;
    background: #999;
}

/* Vertical Fractions Logic */
.vertical-frac {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #888;
    font-family: sans-serif;
    font-size: 9px;
    line-height: 1;
}

.vertical-frac .num {
    margin-bottom: 2px;
}

.vertical-frac .sep {
    width: 8px;
    height: 1px;
    background: #666;
    opacity: 0.7;
}

.vertical-frac .den {
    margin-top: 2px;
}

.vertical-frac.full-label {
    font-size: 10px;
    margin-top: 2px;
}

/* ==========================================================================
   SECTION: CSS - COMBOBOX
   ========================================================================== */
.combobox-container {
    position: relative;
    width: 100%;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
}

.real-input {
    width: 100%;
    background: transparent;
    border: none;
    color: white;
    padding: 6px;
    font-size: 1em;
    z-index: 2;
    position: relative;
}

.real-input:focus {
    outline: none;
    border-color: var(--accent);
}

.ghost-input {
    position: absolute;
    top: 6px;
    left: 7px;
    color: #666;
    font-size: 1em;
    z-index: 1;
    pointer-events: none;
    white-space: pre;
}

.combo-arrow {
    padding: 0 8px;
    color: #888;
    font-size: 0.8em;
    cursor: pointer;
    z-index: 3;
    user-select: none;
}

.combo-arrow:hover {
    color: #fff;
}

.combobox-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #252525;
    border: 1px solid #444;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    margin-top: 2px;
}

.combobox-list.active {
    display: block;
}

.combo-item {
    padding: 6px 8px;
    cursor: pointer;
    border-bottom: 1px solid #333;
    font-size: 0.95em;
    display: flex;
    justify-content: space-between;
}

.combo-item:hover,
.combo-item.selected {
    background: #333;
    color: white;
}

.combo-item.selected {
    border-left: 3px solid var(--accent);
    background: #2e3d30;
}

.combo-cat {
    font-size: 0.75em;
    color: #666;
    font-style: italic;
}

/* ==========================================================================
   SECTION: CSS - SPINNERS & BUTTONS
   ========================================================================== */
.spinner-wrapper {
    display: flex;
    align-items: stretch;
    width: 100%;
    height: 32px;
}

.spinner-btn {
    background: #444;
    border: 1px solid #555;
    color: white;
    padding: 0 10px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.1s;
    min-width: 32px;
}

.spinner-btn:hover {
    background: #555;
}

.spinner-btn:active {
    background: var(--accent);
}

.spinner-btn.left {
    border-right: none;
}

.spinner-btn.right {
    border-left: none;
}

.spinner-btn.first {
    border-radius: 4px 0 0 4px;
}

.spinner-btn.last {
    border-radius: 0 4px 4px 0;
}

input[type="number"] {
    flex: 1;
    text-align: center;
    font-size: 1.1em;
    background: #333;
    border: 1px solid #555;
    border-left: 1px solid #444;
    border-right: 1px solid #444;
    color: white;
    width: 10px;
    -moz-appearance: textfield;
    appearance: textfield;
}

input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #2a2a2a;
    color: #aaa;
}

.split-btn-container {
    display: flex;
    gap: 5px;
    margin-top: 6px;
}

.split-btn {
    flex: 1;
    padding: 6px 4px;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: bold;
    transition: 0.2s;
    color: #ddd;
    background: #333;
    text-align: center;
}

.split-btn:hover:not(:disabled) {
    background: #444;
    color: #fff;
}

.btn-active-green {
    background: #2e7d32 !important;
    border-color: #4caf50 !important;
    color: white !important;
}

.btn-inactive-red {
    background: #333 !important;
    color: #aaa !important;
}

.checkbox-row {
    display: flex;
    align-items: center;
    margin-top: 8px;
    font-size: 0.9em;
    color: #ccc;
}

.checkbox-row input {
    margin-right: 8px;
}

/* ==========================================================================
   SECTION: CSS - CONSTRUCTION LIST
   ========================================================================== */
.build-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.build-group {
    margin-bottom: 2px;
}

.build-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: #333;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    color: #ccc;
    border: 1px solid transparent;
    user-select: none;
}

.build-header:hover {
    background: #444;
    border-color: #555;
    color: #fff;
}

.build-arrow {
    font-size: 0.8em;
    margin-right: 8px;
    transition: transform 0.1s;
    display: inline-block;
    width: 10px;
}

.expanded .build-arrow {
    transform: rotate(90deg);
}

.build-sublist {
    list-style: none;
    padding: 0 0 0 10px;
    margin: 0;
    display: none;
    border-left: 2px solid #444;
    margin-left: 10px;
}

.expanded .build-sublist {
    display: block;
}

.build-subitem {
    display: flex;
    justify-content: space-between;
    padding: 4px 8px;
    font-size: 0.9em;
    color: #aaa;
    border-bottom: 1px dashed #333;
}

.build-subitem:last-child {
    border-bottom: none;
}

.build-val {
    color: var(--gold);
}

.total-mats-header {
    margin-top: 20px;
    border-top: 1px solid #555;
    padding-top: 10px;
    font-weight: bold;
    color: var(--accent);
    text-transform: uppercase;
    font-size: 0.9em;
}

.total-mat-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid #333;
    font-size: 0.95em;
    color: #ddd;
}

/* ==========================================================================
   SECTION: CSS - SUMMARY BOX
   ========================================================================== */
.summary-box {
    background: #252525;
    border-left: 4px solid var(--accent);
    padding: 12px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    gap: 10px;
}

.stat-block {
    display: flex;
    flex-direction: column;
    padding-right: 10px;
    border-right: 1px solid #444;
}

.stat-block:last-child {
    border-right: none;
}

.stat-label {
    font-size: 0.75em;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.1em;
    font-weight: bold;
    color: #fff;
    margin-top: 4px;
}

.stat-sub {
    font-size: 0.85em;
    color: var(--warn);
    margin-top: 2px;
}

.gold-profit {
    color: var(--profit);
}

.gold-cost {
    color: var(--gold);
}

.net-positive {
    color: #69f0ae;
}

/* ==========================================================================
   SECTION: CSS - TREE NODES
   ========================================================================== */
.node {
    margin-left: 15px;
    padding: 4px 0;
    border-left: 2px solid #555;
    position: relative;
}

.node-content {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #222;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #333;
}

.tree-arrow {
    display: inline-block;
    width: 14px;
    cursor: pointer;
    transition: transform 0.1s;
    user-select: none;
    font-size: 0.8em;
    color: #888;
    text-align: center;
}

.row-id {
    color: var(--row-id);
    font-family: monospace;
    font-weight: bold;
    min-width: 20px;
    font-size: 0.9em;
    cursor: pointer;
}

.node.collapsed .node-children {
    display: none;
}

.node.collapsed .tree-arrow {
    transform: rotate(-90deg);
}

.node-children {
    margin-left: 0;
}

.qty {
    color: var(--accent);
    font-weight: bold;
    min-width: 70px;
}

.item-link {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: 0.2s;
}

.item-link:hover {
    color: var(--info);
    text-decoration: underline;
}

.machine-tag {
    background: #333;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.85em;
    border: 1px solid #444;
    color: #fff;
    font-weight: bold;
    cursor: help;
}

.heat-tag {
    color: var(--warn);
    font-size: 0.85em;
    margin-left: 5px;
}

.bio-tag {
    color: var(--bio);
    font-size: 0.85em;
    margin-left: 5px;
}

.cost-tag {
    color: var(--gold);
    font-size: 0.85em;
    margin-left: 10px;
    font-weight: bold;
}

.fail-tag {
    color: var(--danger);
    font-size: 0.85em;
    margin-left: 5px;
    font-weight: bold;
}

.max-cap-tag {
    color: #888;
    font-size: 0.8em;
    margin-left: 5px;
    font-style: italic;
}

.details {
    font-size: 0.9em;
    color: #ccc;
}

.output-tag {
    color: var(--info);
    font-size: 0.85em;
    margin-left: 10px;
    font-weight: bold;
    border-left: 1px solid #555;
    padding-left: 10px;
}

.recycle-tag {
    color: var(--byproduct);
    font-size: 0.85em;
    margin-left: 10px;
    font-weight: bold;
}

.swap-btn {
    background: transparent;
    border: 1px solid #555;
    color: #888;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 11px;
    cursor: pointer;
    margin-left: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.swap-btn:hover {
    background: #444;
    color: white;
    border-color: #fff;
}

.push-right {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.recycle-btn {
    background: transparent;
    border: 1px solid var(--byproduct);
    color: var(--byproduct);
    border-radius: 4px;
    font-size: 0.8em;
    cursor: pointer;
    padding: 2px 8px;
    font-weight: bold;
    transition: 0.2s;
}

.recycle-btn:hover {
    background: rgba(156, 39, 176, 0.2);
}

.recycle-btn.active {
    background: #2e3d30;
    color: var(--profit);
    border-color: var(--profit);
}

.section-header {
    margin-top: 25px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px dashed #555;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85em;
    font-weight: bold;
}

/* ==========================================================================
   SECTION: CSS - MODALS & EDITOR
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--panel);
    border: 1px solid var(--border);
    width: 600px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px;
    border-radius: 8px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.close-modal {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.5em;
    cursor: pointer;
}

.close-modal:hover {
    color: #fff;
}

.recipe-option {
    background: #333;
    border: 1px solid #444;
    padding: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: column;
    align-items: flex-start;
}

.recipe-option.active {
    border-color: var(--accent);
    background: #2e3d30;
}

.recipe-option.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #3e2a2a;
    border-color: #d32f2f;
}

.recipe-header {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.recipe-details {
    font-size: 0.9em;
    color: #aaa;
}

.loop-warning {
    color: #ef5350;
    font-size: 0.85em;
    font-weight: bold;
    margin-top: 4px;
}

/* ==========================================================================
   SECTION: CSS - DATABASE EDITOR
   ========================================================================== */
.db-container {
    display: flex;
    height: 100%;
    gap: 15px;
    max-width: 1400px;
    margin: 0 auto;
}

.db-sidebar {
    width: 300px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.db-filters {
    display: flex;
    padding: 8px;
    border-bottom: 1px solid #333;
    gap: 4px;
    background: #222;
}

.filter-btn {
    flex: 1;
    background: #333;
    border: 1px solid #444;
    color: #888;
    font-size: 0.75em;
    padding: 4px 0;
    cursor: pointer;
    border-radius: 4px;
}

.filter-btn:hover {
    background: #444;
    color: white;
}

.filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    font-weight: bold;
}

.db-search {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    background: #222;
}

.db-search input {
    width: 100%;
    padding: 8px;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    color: #fff;
}

.db-list {
    flex: 1;
    overflow-y: auto;
}

.db-list-item {
    padding: 8px 12px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    align-items: center;
}

.db-list-item:hover {
    background: #333;
    color: white;
}

.db-list-item.selected {
    background: #2e3d30;
    border-left: 3px solid var(--accent);
    color: white;
}

.db-subtext {
    color: #81d4fa;
    font-style: italic;
    font-size: 0.85em;
    opacity: 0.8;
    margin-left: 5px;
}

.db-type-tag {
    font-size: 0.7em;
    padding: 2px 5px;
    border-radius: 2px;
    background: #444;
    color: #aaa;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.db-type-tag.item {
    background: #1a237e;
    color: #8c9eff;
}

.db-type-tag.recipe {
    background: #3e2723;
    color: #ffccbc;
}

.db-type-tag.machine {
    background: #263238;
    color: #b0bec5;
}

.db-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    overflow-y: auto;
}

.db-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.db-title {
    font-size: 1.3em;
    color: var(--accent);
    font-weight: bold;
}

.db-controls {
    display: flex;
    gap: 10px;
}

.db-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group {
    margin-bottom: 10px;
}

.form-group.full-width {
    grid-column: span 2;
}

.form-group label {
    color: #888;
    font-size: 0.85em;
    margin-bottom: 4px;
    display: block;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px;
    background: #222;
    border: 1px solid #444;
    border-radius: 4px;
    color: white;
}

.form-group input:focus {
    border-color: var(--accent);
    outline: none;
}

.dynamic-list {
    background: #222;
    border: 1px solid #444;
    padding: 10px;
    border-radius: 4px;
}

.dynamic-row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    align-items: center;
}

.dynamic-row input {
    flex: 1;
}

.dynamic-row input[type="number"] {
    width: 80px;
    flex: none;
}

.btn-remove {
    background: #d32f2f;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add {
    background: #333;
    color: var(--accent);
    border: 1px dashed #555;
    width: 100%;
    padding: 6px;
    cursor: pointer;
    margin-top: 5px;
    border-radius: 4px;
}

.btn-add:hover {
    background: #383838;
    border-color: var(--accent);
}

/* Code Snippet Styles */
#json-snippet {
    width: 100%;
    height: 150px;
    background: #1e1e1e;
    color: #ce9178;
    font-family: 'Consolas', monospace;
    border: 1px solid #333;
    border-left: 3px solid var(--info);
    padding: 10px;
    resize: none;
    line-height: 1.4;
    white-space: pre;
    font-size: 0.9em;
}

/* Full Source Editor */
#json-editor {
    width: 100%;
    flex: 1;
    background: #151515;
    color: #a5d6a7;
    font-family: 'Consolas', 'Courier New', monospace;
    border: 1px solid #444;
    padding: 15px;
    resize: none;
    line-height: 1.4;
    white-space: pre;
}

.db-search input {
    width: 100%;
    padding: 8px;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    color: #fff;
}

.db-list {
    flex: 1;
    overflow-y: auto;
}

.db-list-item {
    padding: 8px 12px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
}

.db-list-item:hover {
    background: #333;
    color: white;
}

.db-list-item.selected {
    background: #2e3d30;
    border-left: 3px solid var(--accent);
    color: white;
}

.db-type-tag {
    font-size: 0.8em;
    padding: 1px 4px;
    border-radius: 2px;
    background: #444;
    color: #aaa;
}

.db-type-tag.item {
    background: #2c3e50;
    color: #87cefa;
}

.db-type-tag.recipe {
    background: #4e342e;
    color: #ffab91;
}

.db-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    overflow-y: auto;
}

.db-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.db-title {
    font-size: 1.3em;
    color: var(--accent);
    font-weight: bold;
}

.db-controls {
    display: flex;
    gap: 10px;
}

.db-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group {
    margin-bottom: 10px;
}

.form-group.full-width {
    grid-column: span 2;
}

.form-group label {
    color: #888;
    font-size: 0.85em;
    margin-bottom: 4px;
    display: block;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px;
    background: #222;
    border: 1px solid #444;
    border-radius: 4px;
    color: white;
}

.form-group input:focus {
    border-color: var(--accent);
    outline: none;
}

.dynamic-list {
    background: #222;
    border: 1px solid #444;
    padding: 10px;
    border-radius: 4px;
}

.dynamic-row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    align-items: center;
}

.dynamic-row input {
    flex: 1;
}

.dynamic-row input[type="number"] {
    width: 80px;
    flex: none;
}

.btn-remove {
    background: #d32f2f;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add {
    background: #333;
    color: var(--accent);
    border: 1px dashed #555;
    width: 100%;
    padding: 6px;
    cursor: pointer;
    margin-top: 5px;
    border-radius: 4px;
}

.btn-add:hover {
    background: #383838;
    border-color: var(--accent);
}

/* Raw Editor Fallback */
#json-editor {
    flex: 1;
    background: #151515;
    color: #a5d6a7;
    font-family: 'Consolas', 'Courier New', monospace;
    border: 1px solid #444;
    padding: 15px;
    resize: none;
    line-height: 1.4;
    white-space: pre;
}

.editor-toolbar {
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
}

/* --- REVERTED TO COLORED OUTLINE STYLE --- */
button.save-btn {
    width: 100%;
    margin-top: 10px;
    background: #333;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9em;
    border-radius: 4px;
}

button.save-btn:hover {
    background: var(--accent);
    color: white;
}

button.reset-btn {
    width: 100%;
    margin-top: 15px;
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    font-size: 0.8em;
    padding: 5px;
    cursor: pointer;
    border-radius: 4px;
}

button.reset-btn:hover {
    background: var(--danger);
    color: white;
}

/* ==========================================================================
   SECTION: RESPONSIVE DESIGN (MOBILE)
   ========================================================================== */
@media (max-width: 1200px) {
    .app-grid {
        /* On mid-size screens, stack the right-hand columns */
        grid-template-columns: 260px 1fr 280px;
    }

    /* Move the upgrades panel to flow naturally */
    .app-grid>div:nth-child(4) {
        grid-column: 3;
    }
}

@media (max-width: 1000px) {
    body {
        height: auto;
        display: block;
        overflow-y: auto;
    }

    main {
        overflow: visible;
    }

    .view {
        position: relative;
        display: none;
        height: auto;
        overflow: visible;
    }

    .view.active {
        display: block;
    }

    .app-grid {
        display: flex;
        flex-direction: column;
        height: auto;
    }

    /* Adjust summary box for smaller screens */
    .summary-box {
        grid-template-columns: 1fr 1fr;
    }

    /* DB Editor Mobile */
    .db-container {
        flex-direction: column;
        height: auto;
    }

    .db-sidebar {
        width: 100%;
        height: 200px;
    }

    .db-main {
        height: auto;
        min-height: 500px;
    }

    .db-form {
        grid-template-columns: 1fr;
    }

    .form-group.full-width {
        grid-column: span 1;
    }

    /* Make touch targets larger */
    .tab-btn {
        padding: 10px 15px;
    }

    select,
    input,
    .split-btn {
        min-height: 40px;
    }

    /* Tree node tweaks for mobile width */
    .node-content {
        flex-wrap: wrap;
    }

    .push-right {
        margin-left: 0;
        width: 100%;
        margin-top: 5px;
        justify-content: flex-end;
    }
}

/* ==========================================================================
   SECTION: COLLAPSIBLE PANELS
   ========================================================================== */
.panel {
    transition: all 0.2s ease;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    margin-bottom: 10px;
}

.panel-header h3 {
    margin: 0;
    font-size: 1.1em;
    flex-grow: 1;
}

.toggle-icon {
    font-size: 0.9em;
    color: #888;
    transition: transform 0.2s;
}

/* Rotate icon when collapsed (optional animation) */
.panel.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

/* --- GENERIC COLLAPSE BEHAVIOR --- */
/* By default, hide specific contents when collapsed if they are marked */
.panel.collapsed .panel-content {
    display: none;
}

/* OVERRIDE: Keep content wrapper visible for Mini-Mode panels so CSS can control children */
.section-production.collapsed .panel-content,
.section-logistics.collapsed .panel-content {
    display: block !important;
}

/* --- SECTION SPECIFIC RULES --- */

/* 1. Production Goal (Mini-Mode) */

/* Override panel-content display for flex layout */
.section-production.collapsed .panel-content {
    display: flex !important;
    gap: 10px;
    align-items: center;
    padding-bottom: 5px;
    /* Minor adjustment */
}

/* Hide Labels and Belt Slider Group */
.section-production.collapsed label,
.section-production.collapsed .input-group:nth-child(2) {
    display: none !important;
}

/* Input Groups -> Flex Items */
.section-production.collapsed .input-group {
    margin-bottom: 0 !important;
}

/* Item Selector Group (approx 70%) */
.section-production.collapsed .input-group:nth-child(1) {
    flex: 2.5;
}

/* Rate Input Group (approx 30%) */
.section-production.collapsed .input-group:nth-child(3) {
    flex: 1;
}

/* Combobox Container Adjustments */
.section-production.collapsed .combobox-container {
    width: 100%;
}

/* Height Matching */
.section-production.collapsed .input-wrapper,
.section-production.collapsed #targetRate {
    height: 36px;
    display: flex;
    align-items: center;
}

/* Hide Spinner Buttons for Rate */
.section-production.collapsed .spinner-btn {
    display: none !important;
}

/* Rate Input Styling */
.section-production.collapsed .spinner-wrapper {
    width: 100%;
    display: block;
}

.section-production.collapsed #targetRate {
    width: 100%;
    border-radius: 4px;
    text-align: center;
    padding: 0;
    /* Remove padding to prevent height issues */
}

/* 2. Logistics (Mini-Mode) */
.section-logistics.collapsed .input-group label {
    display: none;
}

.section-logistics.collapsed .checkbox-row {
    display: none;
}

.section-logistics.collapsed .input-group {
    display: flex;
    gap: 5px;
    margin-bottom: 5px;
}

.section-logistics.collapsed select {
    width: 65%;
}

.section-logistics.collapsed .split-btn-container {
    margin-top: 0;
    width: 35%;
    display: flex;
}

.section-logistics.collapsed .split-btn-container button:last-child {
    display: none;
    /* Hide Make Default */
}

.section-logistics.collapsed .split-btn-container button:first-child {
    white-space: nowrap;
    padding: 4px;
    font-size: 0.75em;
}

/* 3. Upgrades (Summary Mode) */
.section-upgrades.collapsed .input-group {
    display: none;
}

.section-upgrades .upgrade-summary {
    display: none;
    color: var(--accent);
    font-size: 0.9em;
    font-weight: bold;
    margin-top: -5px;
    margin-bottom: 10px;
}

.bg-transparent {
    background-color: transparent !important;
    border: none !important;
}

.section-upgrades.collapsed .upgrade-summary {
    display: block;
}

/* --- HIGHLIGHTING --- */
.highlight-node {
    border: 2px solid var(--gold) !important;
    background-color: rgba(255, 215, 0, 0.05);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
    transform: scale(1.02);
    transition: all 0.15s ease;
}

/* ==========================================================================
   SECTION: PRODUCTION CHAIN DEPTH COLORS (Evolving Biome)
   ========================================================================== */
.node[data-depth="0"] {
    border-left-color: #512DA8;
}

/* Deep Purple (Start) */
.node[data-depth="1"] {
    border-left-color: #2962FF;
}

/* Blue */
.node[data-depth="2"] {
    border-left-color: #2979FF;
}

.node[data-depth="3"] {
    border-left-color: #448AFF;
}

.node[data-depth="4"] {
    border-left-color: #29B6F6;
}

.node[data-depth="5"] {
    border-left-color: #03A9F4;
}

.node[data-depth="6"] {
    border-left-color: #00BCD4;
}

/* Cyan */
.node[data-depth="7"] {
    border-left-color: #26C6DA;
}

.node[data-depth="8"] {
    border-left-color: #4DB6AC;
}

.node[data-depth="9"] {
    border-left-color: #009688;
}

/* Teal */
.node[data-depth="10"] {
    border-left-color: #43A047;
}

.node[data-depth="11"] {
    border-left-color: #66BB6A;
}

/* Green */
.node[data-depth="12"] {
    border-left-color: #9CCC65;
}

.node[data-depth="13"] {
    border-left-color: #D4E157;
}

.node[data-depth="14"] {
    border-left-color: #FFEE58;
}

/* Yellow */
.node[data-depth="15"] {
    border-left-color: #FFCA28;
}

.node[data-depth="16"] {
    border-left-color: #FFA000;
}

/* Amber */
.node[data-depth="17"] {
    border-left-color: #FB8C00;
}

.node[data-depth="18"] {
    border-left-color: #F57C00;
}

/* Orange */
.node[data-depth="19"] {
    border-left-color: #E64A19;
}

/* Deep Orange (End) */
.node[data-depth="18"] {
    border-left-color: #F57C00;
}

/* Orange */

/* ==========================================================================
   SECTION: RECYCLE BUTTON STYLES
   ========================================================================== */
.btn-recycle-off {
    background: #222 !important;
    border: 1px solid #ab47bc !important;
    /* Purple Border */
    color: #ddd !important;
    transition: all 0.2s;
}

.btn-recycle-off:hover {
    background: #333 !important;
    border-color: #ce93d8 !important;
    /* Lighter Purple */
}

.btn-recycle-on {
    background: #2e7d32 !important;
    /* Green BG */
    border: 1px solid #66bb6a !important;
    /* Light Green Border */
    color: #fff !important;
}

.btn-recycle-on:hover {
    background: #388e3c !important;
}

.recycle-icon-green {
    color: #4caf50;
    /* Green Icon */
    margin-right: 5px;
    font-size: 1.1em;
}

.recycle-icon-white {
    color: #fff;
    margin-right: 5px;
    font-size: 1.1em;
}

/* For Byproducts, we want icon only, minimal padding */
.btn-recycle-icon-only {
    width: 20px !important;
    min-width: 20px !important;
    max-width: 20px !important;
    height: 20px !important;
    min-height: 20px !important;
    max-height: 20px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    box-sizing: border-box !important;
    line-height: 1 !important;
    font-size: 14px !important;
}

.recycle-icon-only {
    margin-right: 0 !important;
    font-size: 0.9em;
    line-height: 1;
}

/* ==========================================================================
   SECTION: FLAT LIST (Inputs & Byproducts)
   ========================================================================== */
.flat-node {
    margin-left: 0 !important;
    border-left: none !important;
    padding: 0 !important;
    padding-left: 0px !important;
    /* Removed extra indentation */
}

.flat-node .node-content {
    margin-bottom: 1px !important;
    /* Tightest vertical spacing */
    padding: 2px 6px !important;
    /* Minimal padding */
}

/* External Toggle Button */
/* External Toggle Button */
/* External Toggle Button */
.btn-toggle-round {
    width: 20px;
    height: 20px;
    padding: 0;
    border-radius: 50%;
    margin-left: 5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    transition: all 0.2s;
}

.btn-toggle-round svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.btn-toggle-int {
    color: #888;
}

.btn-toggle-int:hover {
    color: #fff;
    background: #333;
}

.btn-toggle-ext {
    color: #d40000;
}

.btn-toggle-ext svg {
    transform: scaleX(-1);
}

.btn-toggle-ext:hover {
    background: rgba(212, 0, 0, 0.1);
}

/* --- LAYOUT REFINEMENTS --- */

/* External Inputs & Byproducts Alignment */
.section-external-inputs .panel-content,
.section-byproducts .panel-content {
    padding-left: 0 !important;
}

/* External Inputs Grid (2-Column Layout) */
.ext-grid {
    display: grid;
    /* Col 1: Value (Cap width), Col 2: Item Name + Subtitle (takes rest) */
    grid-template-columns: fit-content(35%) 1fr;
    gap: 4px 12px;
    align-items: center;
    padding: 2px 0px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.ext-grid-val {
    text-align: left;
    font-weight: bold;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.1;
}

.ext-grid-item {
    text-align: left;
    font-weight: bold;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    /* Stack Item Name and Note vertically */
    justify-content: center;
}

.ext-grid-note {
    font-size: 0.85em;
    color: #888;
    font-style: italic;
    font-weight: normal;
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.1;
    margin-top: 2px;
    /* Small gap between Item and Note */
    text-align: left;
}

/* Primary Chain Alignment */
.section-primary-chain .panel-content {
    padding-left: 5px !important;
    /* Align content closer to header */
}

/* Fine-tune the root node position */
.section-primary-chain .node[data-depth="0"] {
    margin-left: 0;
    /* Make the purple line visible/distinct */
    border-left-width: 4px;
}

/* ==========================================================================
   SECTION: CSS - SHARE / IMPORT
   ========================================================================== */
.share-box {
    background: #252525;
    border-left: 4px solid var(--info);
    padding: 12px;
    margin-bottom: 20px;
}

.code-display-input {
    flex: 1;
    background: #111;
    border: 1px solid #444;
    color: var(--info);
    padding: 6px 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    cursor: copy;
}

.code-display-input:focus {
    outline: none;
    border-color: var(--info);
}

.icon-btn {
    background: #333;
    border: 1px solid #444;
    color: #ccc;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    white-space: nowrap;
}

.icon-btn:hover {
    background: #444;
    color: white;
    border-color: #666;
}

.full-width-btn {
    width: 100%;
    background: #333;
    border: 1px dashed #555;
    color: var(--accent);
    padding: 8px;
    margin-top: 5px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    text-align: center;
}

.full-width-btn:hover {
    background: #383838;
    border-color: var(--accent);
}

/* ==========================================================================
   SECTION: TARGET SELECTOR POLISH (v103)
   ========================================================================== */

/* 1. Button Fixes - Reduce Height */
#btn-target-select {
    width: 100%;
    display: block;
    text-align: center;
    background: #333;
    border: 1px solid #555;
    color: #e0e0e0;
    padding: 6px 12px;
    /* Reduced from 10px to match other inputs */
    border-radius: 4px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

#btn-target-select:hover {
    background: #444;
    border-color: #666;
    color: #fff;
}

#btn-target-select .arrow {
    display: none;
}

/* 2. Modal Layout Fixes & Header Tweak */
.modal-content {
    display: flex;
    flex-direction: column;
}

.modal-header {
    /* Compact Header */
    padding-bottom: 5px;
    margin-bottom: 10px;
    border-bottom: 1px solid #333;
}

.modal-header h2 {
    font-size: 1.2em;
    margin: 0;
}

.target-modal-layout {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

/* 3. Filters - Stretch & Tight Gap */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    /* Very tight gap */
    overflow-x: visible;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
    margin-bottom: 10px;
    height: auto;
}

.filter-pill {
    flex: 1 0 auto;
    /* Grow to fill row */
    text-align: center;
    background: #222;
    border: 1px solid #444;
    color: #aaa;
    padding: 8px 12px;
    /* Comfortable touch target */
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: bold;
    transition: 0.1s;
}

.filter-pill:hover {
    background: #333;
    color: #fff;
    border-color: #666;
}

.filter-pill.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* 4. Search - Compact */
.modal-search {
    width: 100%;
    background: #333;
    border: 1px solid #555;
    color: white;
    padding: 6px 10px;
    /* Reduced padding */
    font-size: 1em;
    border-radius: 4px;
    margin-bottom: 10px;
    /* Reduced margin */
    box-sizing: border-box;
}

.modal-search:focus {
    outline: none;
    border-color: var(--accent);
}

/* 5. Grid - Very Tight Gap */
.target-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 2px;
    /* Tightest gap */
    overflow-y: auto;
    padding-right: 5px;
}

/* 6. Item Cards - Polished */
.target-card {
    background: #252525;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: 0.1s;
}

.target-card:hover {
    background: #333;
    border-color: #555;
    transform: translateY(-1px);
}

.target-card strong {
    color: #ddd;
    font-size: 0.95em;
}

.target-card .item-cat {
    font-size: 0.75em;
    color: #aaa;
    background: #333;
    padding: 2px 6px;
    border-radius: 2px;
    border: 1px solid #444;
}

/* Category Specific Colors */
.target-card[data-cat="Component"] .item-cat {
    color: #90caf9;
}

/* Blue */
.target-card[data-cat="Currency"] .item-cat {
    color: #ffd54f;
}

/* Gold */
.target-card[data-cat="Metal"] .item-cat {
    color: #bcaaa4;
}

/* Brownish */
.target-card[data-cat="Logistics"] .item-cat {
    color: #ce93d8;
}

/* Purple */
.target-card[data-cat="Fuel"] .item-cat {
    color: #ffab91;
}

/* Orange */
.target-card[data-cat="Raw Materials"] .item-cat {
    color: #8d6e63;
}

/* Earth */
.target-card[data-cat="Seeds"] .item-cat {
    color: #a5d6a7;
}

/* Pale Green */
.target-card[data-cat="Herbs"] .item-cat {
    color: #81c784;
}

/* Green */
.target-card[data-cat="Potion"] .item-cat {
    color: #f48fb1;
}

/* Pink */
.target-card[data-cat="Magic"] .item-cat {
    color: #ea80fc;
}

/* Magical Purple */

/* Improved Distinction for Requested Categories */
.target-card[data-cat="Catalyst"] .item-cat {
    color: #00e5ff;
}

/* Cyan Accent */
.target-card[data-cat="Fertilizer"] .item-cat {
    color: #76ff03;
}

/* Lime Green */
.target-card[data-cat="Gem"] .item-cat {
    color: #f50057;
}

/* Deep Pink/Magenta */
.target-card[data-cat="Relic"] .item-cat {
    color: #ff1744;
}

/* Red Accent */
.target-card[data-cat="Goods"] .item-cat {
    color: #e6ee9c;
}

/* Light Lime/Khaki */
.target-card[data-cat="Liquid"] .item-cat {
    color: #29b6f6;
}

/* Light Blue */
.target-card[data-cat="Material"] .item-cat {
    color: #cfd8dc;
}

/* Very Light Blue Grey */
.target-card[data-cat="Extract"] .item-cat {
    color: #ff9800;
}

/* Orange */

/* --- ICON INTEGRATION --- */
.item-icon {
    height: 1.4em;
    width: auto;
    vertical-align: middle;
    margin-right: 4px;
    object-fit: contain;
    display: inline-block;

    /* Content-Aware Glow (Drop Shadow respects transparency) */
    /* 1. Contrast/Brightness: Fix washed out colors first */
    /* 2. Drop Shadow: Adds a tight white glow around the ACTUAL PIXELS of the item */
    filter: contrast(2) brightness(1.0) saturate(1.2) drop-shadow(0 0 1px rgba(255, 255, 255, 0.8));
}

/* Specific Tweak for Buttons */
button .item-icon {
    height: 1.6em;
    /* Slightly larger in buttons */
    margin-right: 2px;
    background-color: transparent;
    padding: 0px;
}

/* Specific Tweak for Summary Box */
.stat-value .item-icon {
    height: 1.5em;
    margin-left: 2px;
    margin-right: 4px;
}

/* TREE NODES: Tighter Spacing & Larger Icons */
/* TREE NODES: Tighter Spacing & Larger Icons */
.node {
    margin-top: -1px !important;
    /* Overlap borders to prevent gaps/breaks */
    margin-bottom: 0px !important;
    padding-top: 1px !important;
    padding-bottom: 1px !important;
    border-top: 1px solid transparent;
    /* Prevents border collapse issues if any */
}

/* Target the icon inside the tree link */
.item-link .item-icon {
    height: 1.8em;
    margin-right: 6px;
    vertical-align: middle;
    margin-bottom: 2px;
}

/* Dynamic Header Info (Hide when Expanded, Show when Collapsed) */
.header-details {
    display: none;
}

/* Only show when the parent panel is collapsed */
.panel.collapsed .header-details {
    display: inline;
    font-size: 0.9em;
    color: #ccc;
    font-weight: normal;
}

.header-details .item-icon {
    height: 1.1em;
    vertical-align: text-bottom;
    margin-left: 4px;
    margin-right: 2px;
}

/* Mode Switch Buttons (Belt vs Machine) */
.mode-btn {
    background: transparent;
    border: 1px solid #444;
    color: #888;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    flex: 1;
    /* Equal width */
    margin-right: 4px;
    text-align: center;
}

.mode-btn:last-child {
    margin-right: 0;
}

.mode-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    font-weight: bold;
}

.mode-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #222;
    border-color: #333;
    color: #555;
}

/* Custom Tooltip */
.item-link,
.machine-tag,
.icon-btn,
.toggle-ext-btn {
    position: relative;
    /* Anchor for absolute tooltip */
}

.item-link .tooltip-box,
.machine-tag .tooltip-box,
.icon-btn .tooltip-box,
.toggle-ext-btn .tooltip-box {
    visibility: hidden;
    width: 250px;
    background-color: #222;
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    /* Position above */
    left: 50%;
    margin-left: -125px;
    /* Center */
    opacity: 0;
    transition: opacity 0.2s;
    border: 1px solid #555;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    font-size: 0.85em;
    pointer-events: none;
    /* Let clicks pass through if overlapping */
    white-space: normal;

    /* Reset font to normal in case parent (machine tag) is specialized */
    font-weight: normal;
    line-height: 1.4;
    cursor: auto;
    text-shadow: none;
    /* Clear button text shadows if any */
}

.item-link .tooltip-box::after,
.machine-tag .tooltip-box::after,
.icon-btn .tooltip-box::after,
.toggle-ext-btn .tooltip-box::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #555 transparent transparent transparent;
}

.item-link:hover .tooltip-box,
.machine-tag:hover .tooltip-box,
.icon-btn:hover .tooltip-box,
.toggle-ext-btn:hover .tooltip-box {
    visibility: visible;
    opacity: 1;
}

.tooltip-header {
    color: var(--accent);
    font-weight: bold;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
    margin-bottom: 5px;
    text-align: center;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3px;
    color: #ccc;
}

.tooltip-val {
    color: #fff;
    font-weight: bold;
}