/* Global Scrollbar Styles */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.3);
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

:root {
    --bg-color: #0f172a;
    --card-bg: rgba(255, 255, 255, 0.03);
    --border-color: #334155;
    --accent-yellow: #ffff69;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow-x: hidden;
}

.dashboard {
    padding: 1rem 2rem;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.top-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.minimal-select {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 250px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.status-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.status-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.2);
}

.status-card .label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-card .value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.status-card .unit {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Main Layout Area */
.main-container {
    display: flex;
    gap: 1rem;
    flex: 1;
    min-height: 500px;
    margin-bottom: 2rem;
}


.chart-box {
    flex: 1;
    border: 1px solid var(--accent-yellow);
    background: rgba(51, 65, 85, 0.5);
    position: relative;
    overflow: visible;
    min-width: 0;
    min-height: 0;
    padding: 1.5rem 1.5rem 0.5rem 1.5rem;
}

/* uPlot Legend Styling */
.u-legend {
    font-size: 0.85rem !important;
    padding: 0 !important;
    margin-top: -5px !important;
    border: none !important;
}
.u-legend .u-series th, .u-legend .u-series td {
    padding: 2px 8px !important;
}

/* Status Box Area */
.status-box {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1.5rem 2.5rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, auto);
    gap: 1.5rem 2.5rem;
    margin-bottom: 2rem;
}

.pen-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    transition: opacity 0.2s ease;
}

.pen-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pen-item.disabled .pen-checkbox {
    pointer-events: none;
}

.pen-checkbox {
    width: 18px;
    height: 18px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    background: transparent;
    appearance: none;
    position: relative;
}

.pen-checkbox:checked {
    background: var(--text-primary);
}

.pen-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--bg-color);
    font-size: 12px;
    font-weight: bold;
}

.pen-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pen-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    text-align: right;
    min-width: 80px;
}

/* Settings Modal Tabs */
.settings-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.settings-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 600;
    border-bottom: 2px solid transparent;
}

.settings-tab.active {
    color: var(--accent-pressure);
    border-bottom-color: var(--accent-pressure);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.reg-split {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
    height: 400px;
}

.reg-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    height: 100%;
}

.reg-section h3 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.scroll-list {
    flex: 1;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

.reg-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
}

.reg-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent-pressure);
    min-width: 40px;
}

.input-field {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    width: 100%;
}
.node-id-input {
    width: 80px !important;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-pressure);
}

.pen-config-item {
    display: grid;
    grid-template-columns: 40px 1fr 1fr 40px;
    gap: 0.75rem;
    align-items: center;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    align-items: center;
    justify-content: center;
}

.reg-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.reg-table th, .reg-table td {
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}
.reg-table th {
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
}
.btn {
    border-radius: 20px;
    padding: 0.5rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.btn-small {
    padding: 0.3rem 1.2rem;
    font-size: 0.75rem;
    border-radius: 15px;
}

.btn-ghost {
    background: transparent;
    color: var(--accent-pressure);
    border: 1px solid var(--accent-pressure);
}

.btn-ghost:hover {
    background: rgba(0, 212, 255, 0.1);
    box-shadow: 0 0 10px var(--accent-pressure);
}

.btn-right-container {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

.w-name { width: 300px !important; }
.w-tag-no { width: 12ch !important; }
.w-range { width: 8ch !important; }
.w-color { width: 60px !important; }

.btn-danger {
    background: #ef4444;
    color: white;
}
.btn-danger:hover {
    background: #dc2626;
}

.modal-content {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 20px rgba(0, 212, 255, 0.1);
    width: 1200px;
    max-width: 95vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #f8fafc;
}

#close-modal {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

#close-modal:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.settings-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.3rem;
    border-radius: 8px;
}

.settings-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.settings-tab.active {
    background: #1e293b;
    color: var(--accent-yellow);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

.tab-btn {
    background: var(--accent-yellow);
    border: none;
    color: #000;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}
