:root {
    font-family: Inter, system-ui, -apple-system, sans-serif;

    color: #e5eaf2;
    background: #0d1119;

    --background: #0d1119;
    --sidebar: #111722;
    --panel: #151d29;
    --panel-secondary: #111824;
    --border: #293345;

    --text: #e5eaf2;
    --muted: #8996aa;

    --accent: #72dfc0;
    --accent-background: #18312f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

[hidden] {
    display: none !important;
}

/* Main layout */

.app {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    min-height: 100vh;
}

/* Sidebar */

.sidebar {
    display: flex;
    flex-direction: column;

    min-height: 100vh;
    padding: 26px 18px 18px;

    background: var(--sidebar);
    border-right: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 0 7px;
    margin-bottom: 35px;
}

.brand-icon {
    display: grid;
    place-items: center;

    width: 42px;
    height: 42px;

    border-radius: 12px;

    background: var(--accent);
    color: #10201d;

    font-size: 22px;
    font-weight: 800;
}

.eyebrow {
    margin: 0 0 5px;

    color: var(--muted);

    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
}

.brand h1 {
    margin: 0;
    font-size: 19px;
}

/* Search */

.search-label {
    margin: 0 0 9px 4px;

    color: #bac4d2;
    font-size: 12px;
    font-weight: 600;
}

#component-search {
    width: 100%;
    padding: 12px;

    border: 1px solid var(--border);
    border-radius: 8px;

    outline: none;

    background: var(--panel);
    color: var(--text);

    font-size: 12px;
}

#component-search::placeholder {
    color: #6f7c90;
}

#component-search:focus {
    border-color: var(--accent);
}

/* Component list */

.list-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin: 28px 0 10px;

    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.count {
    padding: 4px 7px;

    border-radius: 5px;

    background: #222c3b;
    color: #c1ccdc;

    font-size: 10px;
    letter-spacing: normal;
}

.component-list {
    display: flex;
    flex-direction: column;
    gap: 5px;

    overflow-y: auto;
}

.component-option {
    display: flex;
    align-items: center;
    gap: 11px;

    width: 100%;
    padding: 12px;

    border: 1px solid transparent;
    border-radius: 8px;

    background: transparent;
    color: #b5c0d0;

    text-align: left;
    cursor: pointer;
}

.component-option:hover {
    background: #1a2331;
    color: var(--text);
}

.component-option.selected {
    border-color: #31534c;
    background: var(--accent-background);
    color: var(--accent);
}

.radio-visual {
    display: grid;
    place-items: center;

    flex-shrink: 0;

    width: 16px;
    height: 16px;

    border: 1px solid #68758a;
    border-radius: 50%;
}

.component-option.selected .radio-visual {
    border-color: var(--accent);
}

.component-option.selected .radio-visual::after {
    width: 8px;
    height: 8px;

    border-radius: 50%;

    background: var(--accent);
    content: "";
}

.part-number {
    overflow: hidden;

    font-size: 12px;
    font-weight: 600;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.message {
    padding: 12px;

    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 9px;

    margin-top: auto;
    padding: 25px 5px 0;

    color: var(--muted);
    font-size: 11px;
}

.status-dot {
    width: 8px;
    height: 8px;

    border-radius: 50%;

    background: var(--accent);
}

.status-dot.error {
    background: #ff8585;
}

/* Main content */

.main-content {
    min-width: 0;
    padding: 36px clamp(20px, 3vw, 45px);
}

.page-header {
    padding-bottom: 25px;
    margin-bottom: 25px;

    border-bottom: 1px solid var(--border);
}

.page-header h2 {
    margin: 0;

    font-size: clamp(24px, 3vw, 34px);
    font-weight: 800;
    letter-spacing: -0.04em;

    overflow-wrap: anywhere;
}

.subtitle {
    margin: 9px 0 0;

    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

/* Empty state */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    min-height: 55vh;
    padding: 30px;

    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;

    width: 75px;
    height: 75px;

    margin-bottom: 20px;

    border: 1px solid var(--border);
    border-radius: 20px;

    background: var(--panel);
    color: var(--accent);

    font-size: 42px;
}

.empty-state h3 {
    margin: 0 0 10px;
    font-size: 17px;
}

.empty-state p {
    max-width: 350px;
    margin: 0;

    color: var(--muted);
    font-size: 12px;
    line-height: 1.8;
}

/* Viewers */

.workspace {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.xml-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.viewer-card {
    min-width: 0;
    overflow: hidden;

    border: 1px solid var(--border);
    border-radius: 11px;

    background: var(--panel);
}

.viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    padding: 16px;

    border-bottom: 1px solid var(--border);
}

.viewer-header h3 {
    margin: 8px 0 0;
    font-size: 13px;
}

.file-description {
    margin: 5px 0 0;

    color: var(--muted);
    font-size: 10px;
}

.file-type {
    display: inline-block;

    padding: 5px 7px;

    border: 1px solid;
    border-radius: 5px;

    font-size: 9px;
    font-weight: 700;
}

.xml-type {
    border-color: #31554d;
    background: #1a302e;
    color: var(--accent);
}

.pdf-type {
    border-color: #59343e;
    background: #38242c;
    color: #ff9caa;
}

.button {
    flex-shrink: 0;

    padding: 7px 10px;

    border: 1px solid var(--border);
    border-radius: 6px;

    background: #1c2635;
    color: #cbd5e3;

    font-size: 10px;
    text-decoration: none;

    cursor: pointer;
}

.button:hover {
    border-color: #54756c;
    color: var(--accent);
}

.code-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 10px 15px;

    border-bottom: 1px solid #222c3a;

    background: var(--panel-secondary);
    color: #8290a5;

    font-family: monospace;
    font-size: 10px;
}

.xml-viewer {
    height: 310px;
    margin: 0;
    padding: 16px;

    overflow: auto;

    background: var(--panel-secondary);
    color: #c1d0df;

    font-family: "DejaVu Sans Mono", Consolas, monospace;
    font-size: 11px;
    line-height: 1.8;

    tab-size: 2;
    white-space: pre;
}

.xml-viewer code {
    font: inherit;
}

/* PDF viewer */

.pdf-container {
    height: min(70vh, 800px);
    min-height: 350px;

    background: #252b35;
}

.pdf-container iframe {
    display: block;

    width: 100%;
    height: 100%;
    min-height: 350px;

    border: 0;
    background: white;
}

.pdf-container .message {
    padding: 25px;
}

/* Notifications */

.notification {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 10;

    max-width: calc(100vw - 48px);
    padding: 12px 16px;

    border: 1px solid #36564e;
    border-radius: 8px;

    background: #18312f;
    color: #c3f4e4;

    font-size: 12px;

    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);

    transition: opacity 0.2s, transform 0.2s;
}

.notification.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive layout */

@media (max-width: 1050px) {
    .app {
        grid-template-columns: 230px minmax(0, 1fr);
    }

    .main-content {
        padding: 25px 20px;
    }

    .xml-grid {
        gap: 12px;
    }

    .xml-viewer {
        height: 270px;
    }
}

@media (max-width: 760px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;

        padding: 18px 16px;

        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .brand {
        margin-bottom: 22px;
    }

    .component-list {
        max-height: 190px;
    }

    .sidebar-footer {
        padding-top: 18px;
    }

    .main-content {
        padding: 24px 15px;
    }

    .xml-grid {
        grid-template-columns: 1fr;
    }

    .xml-viewer {
        height: 250px;
    }

    .pdf-container {
        height: 65vh;
        min-height: 320px;
    }
}

.calibrate-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 32px;
    padding: 24px 0 16px;
    border-top: 1px solid var(--border-color, #2a3441);
}

.calibrate-button {
    min-width: 200px;
    padding: 14px 32px;
    border: none;
    border-radius: 8px;
    background: var(--accent-color, #39d98a);
    color: #101820;
    font: inherit;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition:
        transform 0.15s ease,
        opacity 0.15s ease,
        box-shadow 0.15s ease;
}

.calibrate-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgb(57 217 138 / 20%);
}

.calibrate-button:active:not(:disabled) {
    transform: translateY(0);
}

.calibrate-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.calibrate-button.is-loading {
    cursor: wait;
    opacity: 0.7;
}

.calibrate-status {
    min-height: 20px;
    margin: 0;
    font-size: 13px;
    color: var(--text-muted, #94a3b8);
    text-align: center;
}

.calibrate-status.is-error {
    color: #ff7777;
}

.calibrate-status.is-success {
    color: #39d98a;
}

#download-calibration-button {
    margin-top: 4px;
}

#download-calibration-button[hidden] {
    display: none;
}

/* Device filters */

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-bottom: 18px;
}

.filter-group .search-label {
    margin: 0 0 0 4px;
    color: #bac4d2;
    font-size: 12px;
    font-weight: 600;
}

.filter-group select {
    width: 100%;
    padding: 12px;

    border: 1px solid var(--border);
    border-radius: 8px;

    outline: none;

    background: var(--panel);
    color: var(--text);

    font-family: inherit;
    font-size: 12px;

    cursor: pointer;
    transition: border-color 0.2s ease;
}

.filter-group select:hover {
    border-color: #46546a;
}

.filter-group select:focus {
    border-color: var(--accent);
}

.filter-group select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.filter-group select option {
    background: var(--panel);
    color: var(--text);
}

/* Get devices button */

#get-devices-button {
    width: 100%;
    margin: 2px 0 24px;
    padding: 11px 12px;

    border: 1px solid #31534c;
    border-radius: 8px;

    background: var(--accent-background);
    color: var(--accent);

    font-family: inherit;
    font-size: 12px;
    font-weight: 700;

    cursor: pointer;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        opacity 0.2s ease;
}

#get-devices-button:hover:not(:disabled) {
    border-color: var(--accent);
    background: #203d38;
}

#get-devices-button:active:not(:disabled) {
    background: #294b43;
}

#get-devices-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}