:root {
    color-scheme: light;
    --vttb-bg: #eef3f5;
    --vttb-surface: #ffffff;
    --vttb-surface-muted: #f6f9fa;
    --vttb-text: #172431;
    --vttb-muted: #6d7e8f;
    --vttb-line: #d8e1e6;
    --vttb-primary: #056b7a;
    --vttb-primary-soft: #dff2f3;
    --vttb-success: #237b57;
    --vttb-success-soft: #e4f4eb;
    --vttb-warning: #a66a04;
    --vttb-warning-soft: #fff3d8;
    --vttb-danger: #b84436;
    --vttb-danger-soft: #fde8e5;
    --vttb-shadow: 0 16px 36px rgba(28, 50, 64, 0.08);
    --vttb-radius: 12px;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --vttb-bg: #101a23;
    --vttb-surface: #17232e;
    --vttb-surface-muted: #1d2c38;
    --vttb-text: #eef6f8;
    --vttb-muted: #aabdc8;
    --vttb-line: #334957;
    --vttb-primary: #77d3d6;
    --vttb-primary-soft: #173e46;
    --vttb-success: #86d7ad;
    --vttb-success-soft: #1d4035;
    --vttb-warning: #f0c166;
    --vttb-warning-soft: #493719;
    --vttb-danger: #ff9b91;
    --vttb-danger-soft: #4b2828;
    --vttb-shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--vttb-bg);
    color: var(--vttb-text);
    font-family: "Be Vietnam Pro", Arial, sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

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

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

.vttb-app {
    min-height: 100vh;
}

.vttb-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 68px;
    padding: 11px clamp(16px, 2vw, 32px);
    border-bottom: 1px solid var(--vttb-line);
    background: var(--vttb-surface);
}

.vttb-brand,
.vttb-top-actions,
.vttb-modal-header,
.vttb-panel-heading,
.vttb-inline-heading,
.vttb-modal-actions,
.vttb-row-actions,
.vttb-history-entry summary {
    display: flex;
    align-items: center;
}

.vttb-brand {
    gap: 12px;
}

.vttb-brand h1,
.vttb-panel-heading h2,
.vttb-modal-header h2,
.vttb-inline-heading h3,
.vttb-confirm-modal h2 {
    margin: 0;
    letter-spacing: 0;
}

.vttb-brand h1 {
    font-size: 1.25rem;
}

.vttb-eyebrow {
    margin: 0 0 4px;
    color: var(--vttb-primary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.vttb-back-link,
.vttb-icon-button {
    display: inline-grid;
    width: 38px;
    height: 38px;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid var(--vttb-line);
    border-radius: 10px;
    background: var(--vttb-surface);
    color: var(--vttb-muted);
    transition: 150ms ease;
}

.vttb-back-link:hover,
.vttb-icon-button:hover {
    border-color: var(--vttb-primary);
    color: var(--vttb-primary);
}

.vttb-icon-button.is-danger:hover {
    border-color: var(--vttb-danger);
    color: var(--vttb-danger);
}

.vttb-top-actions {
    min-width: 0;
    justify-content: flex-end;
    gap: 7px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    white-space: nowrap;
}

.vttb-top-actions::-webkit-scrollbar {
    display: none;
}

.vttb-top-actions > *,
.vttb-top-actions .vttb-summary-grid {
    flex: 0 0 auto;
}

.vttb-connection {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 38px;
    padding: 0;
    border: 0;
}

.vttb-connection .vttb-connection-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--vttb-warning);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--vttb-warning) 18%, transparent);
}

.vttb-connection.is-ready .vttb-connection-dot {
    background: var(--vttb-success);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--vttb-success) 18%, transparent);
}

.vttb-connection.is-error .vttb-connection-dot {
    background: var(--vttb-danger);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--vttb-danger) 18%, transparent);
}

.vttb-connection-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.vttb-secondary-button,
.vttb-primary-button,
.vttb-danger-button,
.vttb-small-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid var(--vttb-line);
    border-radius: 9px;
    font-weight: 700;
    transition: 150ms ease;
}

.vttb-secondary-button {
    background: var(--vttb-surface);
    color: var(--vttb-text);
}

.vttb-secondary-button:hover {
    border-color: var(--vttb-primary);
    color: var(--vttb-primary);
}

.vttb-primary-button {
    border-color: var(--vttb-primary);
    background: var(--vttb-primary);
    color: #fff;
}

html[data-theme="dark"] .vttb-primary-button {
    color: #0f2128;
}

.vttb-primary-button:hover {
    filter: brightness(1.08);
}

.vttb-primary-button:disabled,
.vttb-secondary-button:disabled,
.vttb-danger-button:disabled {
    cursor: not-allowed;
    filter: none;
    opacity: 0.5;
}

.vttb-danger-button {
    border-color: var(--vttb-danger);
    background: var(--vttb-danger);
    color: #fff;
}

.vttb-small-button {
    min-height: 32px;
    padding: 5px 9px;
    background: var(--vttb-surface);
    color: var(--vttb-primary);
    font-size: 0.78rem;
}

.vttb-small-button:hover {
    border-color: var(--vttb-primary);
    background: var(--vttb-primary-soft);
}

.vttb-small-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.vttb-small-button:disabled:hover {
    border-color: var(--vttb-line);
    background: var(--vttb-surface);
}

.vttb-small-button.is-danger {
    color: var(--vttb-danger);
}

.vttb-small-button.is-restore {
    color: var(--vttb-success);
}

.vttb-main {
    width: min(1600px, calc(100% - 32px));
    margin: 0 auto;
    padding: clamp(12px, 1.5vw, 22px) 0 52px;
}

.vttb-summary-grid {
    display: flex;
    gap: 7px;
    margin: 0;
}

.vttb-summary-card,
.vttb-inventory-panel,
.vttb-history-panel {
    border: 1px solid var(--vttb-line);
    border-radius: var(--vttb-radius);
    background: var(--vttb-surface);
    box-shadow: var(--vttb-shadow);
}

.vttb-summary-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 112px;
    min-height: 38px;
    padding: 6px 9px;
    box-shadow: none;
}

.vttb-summary-card span {
    color: var(--vttb-muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.vttb-summary-card strong {
    font-size: 1rem;
}

.vttb-top-command {
    min-height: 38px;
    padding: 7px 11px;
    font-size: 0.82rem;
}

.vttb-summary-card.is-success strong {
    color: var(--vttb-success);
}

.vttb-summary-card.is-warning strong {
    color: var(--vttb-warning);
}

.vttb-summary-card.is-danger strong {
    color: var(--vttb-danger);
}

.vttb-alert {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 14px;
    padding: 11px 13px;
    border: 1px solid var(--vttb-line);
    border-radius: 9px;
    font-size: 0.86rem;
}

.vttb-alert span {
    flex: 1;
}

.vttb-alert.is-error {
    border-color: color-mix(in srgb, var(--vttb-danger) 45%, var(--vttb-line));
    background: var(--vttb-danger-soft);
    color: var(--vttb-danger);
}

.vttb-alert.is-success {
    border-color: color-mix(in srgb, var(--vttb-success) 45%, var(--vttb-line));
    background: var(--vttb-success-soft);
    color: var(--vttb-success);
}

.vttb-toast {
    position: fixed;
    z-index: 40;
    top: 82px;
    right: clamp(16px, 2vw, 32px);
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(390px, calc(100vw - 32px));
    min-height: 48px;
    padding: 11px 14px;
    border: 1px solid var(--vttb-line);
    border-radius: 10px;
    box-shadow: 0 14px 36px rgba(7, 24, 34, 0.2);
    transition: opacity 160ms ease, transform 160ms ease;
    animation: vttb-toast-in 180ms ease-out;
}

.vttb-toast span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.vttb-toast svg {
    flex: 0 0 auto;
}

.vttb-toast.is-success {
    border-color: color-mix(in srgb, var(--vttb-success) 45%, var(--vttb-line));
    background: color-mix(in srgb, var(--vttb-success-soft) 92%, var(--vttb-surface));
    color: var(--vttb-success);
}

.vttb-toast.is-error {
    border-color: color-mix(in srgb, var(--vttb-danger) 45%, var(--vttb-line));
    background: color-mix(in srgb, var(--vttb-danger-soft) 92%, var(--vttb-surface));
    color: var(--vttb-danger);
}

.vttb-toast.is-leaving {
    opacity: 0;
    transform: translateY(-7px);
}

@keyframes vttb-toast-in {
    from {
        opacity: 0;
        transform: translateY(-7px);
    }
}

.vttb-alert.is-info {
    border-color: color-mix(in srgb, var(--vttb-primary) 35%, var(--vttb-line));
    background: var(--vttb-primary-soft);
    color: var(--vttb-text);
}

.vttb-readonly-tag {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid var(--vttb-line);
    border-radius: 999px;
    color: var(--vttb-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.vttb-workspace {
    display: block;
}

.vttb-inventory-panel,
.vttb-history-panel {
    min-width: 0;
    padding: 17px;
}

.vttb-panel-heading {
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 13px;
}

.vttb-panel-heading > svg {
    color: var(--vttb-primary);
}

.vttb-panel-heading h2 {
    font-size: 1rem;
}

.vttb-category-bar {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr) max-content;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 1px 0 12px;
    border-bottom: 1px solid var(--vttb-line);
}

.vttb-category-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--vttb-muted);
    font-size: 0.76rem;
    white-space: nowrap;
}

.vttb-category-label svg {
    width: 17px;
    height: 17px;
    color: var(--vttb-primary);
}

.vttb-category-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 2px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
}

.vttb-category-button {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--vttb-line);
    border-radius: 8px;
    background: var(--vttb-surface-muted);
    color: var(--vttb-muted);
    font-weight: 700;
    white-space: nowrap;
    transition: 150ms ease;
}

.vttb-category-button span {
    font-size: 0.82rem;
}

.vttb-category-button strong {
    display: inline-grid;
    min-width: 22px;
    min-height: 22px;
    padding: 2px 5px;
    border-radius: 6px;
    background: var(--vttb-surface);
    color: var(--vttb-muted);
    font-size: 0.72rem;
    place-items: center;
}

.vttb-category-button:hover {
    border-color: color-mix(in srgb, var(--vttb-primary) 40%, var(--vttb-line));
    color: var(--vttb-text);
}

.vttb-category-button.is-active {
    border-color: color-mix(in srgb, var(--vttb-primary) 45%, var(--vttb-line));
    background: var(--vttb-primary-soft);
    color: var(--vttb-primary);
}

.vttb-category-button.is-active strong {
    background: color-mix(in srgb, var(--vttb-primary) 16%, var(--vttb-surface));
    color: var(--vttb-primary);
}

.vttb-category-select {
    display: none;
    width: 100%;
    min-height: 40px;
    padding: 8px 34px 8px 11px;
    border: 1px solid var(--vttb-line);
    border-radius: 8px;
    background: var(--vttb-surface);
    color: var(--vttb-text);
    font: inherit;
}

.vttb-category-manage-button {
    flex: 0 0 auto;
}

.vttb-inventory-heading {
    margin-bottom: 12px;
}

.vttb-count-badge {
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--vttb-primary-soft);
    color: var(--vttb-primary);
    font-size: 0.75rem;
    font-weight: 800;
}

.vttb-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 8px;
    margin-bottom: 12px;
}

.vttb-toolbar select,
.vttb-history-filters select,
.vttb-history-filters input,
.vttb-search-field,
.vttb-editor-form input,
.vttb-editor-form select,
.vttb-editor-form textarea,
.vttb-custom-field-row input {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--vttb-line);
    border-radius: 8px;
    background: var(--vttb-surface-muted);
    color: var(--vttb-text);
    outline: none;
}

.vttb-toolbar select,
.vttb-history-filters select,
.vttb-history-filters input {
    padding: 8px 10px;
}

.vttb-search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
}

.vttb-search-field svg {
    flex: 0 0 auto;
    color: var(--vttb-muted);
}

.vttb-search-field input {
    min-height: 38px;
    border: 0;
    background: transparent;
}

.vttb-toolbar select:focus,
.vttb-history-filters input:focus,
.vttb-history-filters select:focus,
.vttb-search-field:focus-within,
.vttb-editor-form input:focus,
.vttb-editor-form select:focus,
.vttb-editor-form textarea:focus,
.vttb-category-form input:focus,
.vttb-custom-field-row input:focus {
    border-color: var(--vttb-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--vttb-primary) 18%, transparent);
}

.vttb-table-scrollbar {
    height: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--vttb-line);
    border-radius: 999px;
    background: var(--vttb-surface-muted);
    scrollbar-color: var(--vttb-primary) transparent;
}

.vttb-table-scrollbar-bottom {
    position: fixed;
    z-index: 35;
    left: 8px;
    top: calc(100vh - 22px);
    width: calc(100vw - 16px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--vttb-text) 12%, transparent);
}

.vttb-table-scrollbar.is-hidden {
    display: none;
}

.vttb-table-scrollbar-spacer {
    height: 1px;
}

.vttb-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--vttb-line);
    border-radius: 9px;
    scrollbar-color: var(--vttb-primary) transparent;
}

.vttb-table-wrap.has-docked-scrollbar {
    scrollbar-width: none;
}

.vttb-table-wrap.has-docked-scrollbar::-webkit-scrollbar {
    height: 0;
}

.vttb-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1360px;
    font-size: 0.8rem;
}

.vttb-table th,
.vttb-table td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--vttb-line);
    text-align: left;
    vertical-align: middle;
}

.vttb-table th {
    background: var(--vttb-surface-muted);
    color: var(--vttb-muted);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.vttb-table tbody tr:last-child td {
    border-bottom: 0;
}

.vttb-table tbody tr:hover {
    background: color-mix(in srgb, var(--vttb-primary-soft) 35%, transparent);
}

.vttb-table td small {
    display: block;
    margin-top: 3px;
    color: var(--vttb-muted);
    font-size: 0.7rem;
}

.vttb-item-name {
    max-width: 245px;
    color: var(--vttb-text);
    font-weight: 700;
}

@media (min-width: 681px) {
    .vttb-table .vttb-code-column,
    .vttb-table .vttb-calibration-column {
        width: 124px;
        min-width: 124px;
        max-width: 124px;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .vttb-table td[data-label="Tên TB"] {
        min-width: 180px;
    }

    .vttb-table td[data-label="Loại / Serial"] {
        min-width: 108px;
    }

    .vttb-table td[data-label="Trạng thái"] {
        min-width: 172px;
    }

    .vttb-table td[data-label="Vị trí"],
    .vttb-table td[data-label="Ghi chú"] {
        min-width: 144px;
    }

    .vttb-table td[data-label="Thao tác"] {
        width: 115px;
        min-width: 115px;
    }

    .vttb-table td[data-label="Thao tác"] .vttb-row-actions {
        flex-wrap: nowrap;
    }
}

.vttb-serial-cell {
    color: var(--vttb-primary);
}

.vttb-calibration-cell {
    display: block;
    max-width: 100%;
    line-height: 1.4;
    overflow-wrap: anywhere;
    white-space: normal;
    word-break: break-word;
}

.vttb-calibration-date {
    display: inline-block;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
}

.vttb-selection-column {
    width: 42px;
    min-width: 42px;
    text-align: center !important;
}

.vttb-selection-column input {
    width: 18px;
    height: 18px;
    accent-color: var(--vttb-primary);
    cursor: pointer;
}

.vttb-note-cell {
    display: -webkit-box;
    max-width: 220px;
    overflow: hidden;
    color: var(--vttb-muted);
    line-height: 1.45;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.vttb-status-tag {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 0.69rem;
    font-weight: 800;
    white-space: nowrap;
}

.vttb-status-tag.is-success {
    background: var(--vttb-success-soft);
    color: var(--vttb-success);
}

.vttb-status-tag.is-warning {
    background: var(--vttb-warning-soft);
    color: var(--vttb-warning);
}

.vttb-status-tag.is-info {
    background: var(--vttb-primary-soft);
    color: var(--vttb-primary);
}

.vttb-status-tag.is-danger {
    background: var(--vttb-danger-soft);
    color: var(--vttb-danger);
}

.vttb-status-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    min-width: 150px;
}

.vttb-location-status {
    font-size: 0.64rem;
    line-height: 1.15;
}

.vttb-location-status.is-rig {
    background: var(--vttb-primary-soft);
    color: var(--vttb-primary);
}

.vttb-location-status.is-warehouse {
    background: var(--vttb-success-soft);
    color: var(--vttb-success);
}

.vttb-inline-status {
    width: min(150px, 100%);
    min-height: 32px;
    padding: 5px 28px 5px 8px;
    border: 1px solid var(--vttb-line);
    border-radius: 8px;
    background: var(--vttb-surface);
    color: var(--vttb-text);
    font-size: 0.72rem;
    font-weight: 750;
    cursor: pointer;
}

.vttb-inline-status.is-success {
    border-color: color-mix(in srgb, var(--vttb-success) 38%, var(--vttb-line));
    color: var(--vttb-success);
}

.vttb-inline-status.is-warning {
    border-color: color-mix(in srgb, var(--vttb-warning) 42%, var(--vttb-line));
    color: var(--vttb-warning);
}

.vttb-inline-status.is-info {
    border-color: color-mix(in srgb, var(--vttb-primary) 38%, var(--vttb-line));
    color: var(--vttb-primary);
}

.vttb-inline-status.is-danger {
    border-color: color-mix(in srgb, var(--vttb-danger) 38%, var(--vttb-line));
    color: var(--vttb-danger);
}

.vttb-allocation-tag {
    display: inline-flex;
    padding: 5px 8px;
    border: 1px solid var(--vttb-line);
    border-radius: 999px;
    color: var(--vttb-muted);
    font-size: 0.69rem;
    font-weight: 700;
    white-space: nowrap;
}

.vttb-allocation-tag.is-onshore-project {
    border-color: color-mix(in srgb, var(--vttb-primary) 36%, var(--vttb-line));
    background: var(--vttb-primary-soft);
    color: var(--vttb-primary);
}

.vttb-allocation-tag.is-rig {
    border-color: color-mix(in srgb, var(--vttb-primary) 36%, var(--vttb-line));
    background: var(--vttb-primary-soft);
    color: var(--vttb-primary);
}

.vttb-bulk-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--vttb-line);
    border-radius: 9px;
    background: var(--vttb-surface-muted);
}

.vttb-bulk-toolbar.is-active {
    border-color: color-mix(in srgb, var(--vttb-primary) 42%, var(--vttb-line));
    background: var(--vttb-primary-soft);
}

.vttb-bulk-toolbar > div:first-child {
    display: grid;
    gap: 2px;
}

.vttb-bulk-toolbar strong {
    font-size: 0.84rem;
}

.vttb-bulk-toolbar span {
    color: var(--vttb-muted);
    font-size: 0.72rem;
}

.vttb-bulk-toolbar-actions {
    display: flex;
    gap: 7px;
    flex: 0 0 auto;
}

.vttb-assignment-cell {
    display: grid;
    gap: 2px;
    min-width: 145px;
}

.vttb-assignment-cell strong {
    color: var(--vttb-primary);
    font-size: 0.76rem;
}

.vttb-assignment-cell span,
.vttb-assignment-cell small {
    color: var(--vttb-muted);
    font-size: 0.68rem;
}

.vttb-location-cell {
    display: flex;
    align-items: center;
    gap: 7px;
}

.vttb-location-edit-button {
    width: 30px;
    min-width: 30px;
    height: 30px;
}

.vttb-location-edit-button svg {
    width: 15px;
    height: 15px;
}

.vttb-row-actions {
    flex-wrap: nowrap;
    gap: 5px;
}

.vttb-row-icon-button {
    display: inline-grid;
    width: 34px;
    min-width: 34px;
    height: 34px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--vttb-line);
    border-radius: 9px;
    background: var(--vttb-surface);
    color: var(--vttb-primary);
    transition: 150ms ease;
}

.vttb-row-icon-button:hover {
    border-color: var(--vttb-primary);
    background: var(--vttb-primary-soft);
}

.vttb-row-icon-button.is-danger {
    color: var(--vttb-danger);
}

.vttb-row-icon-button.is-danger:hover {
    border-color: var(--vttb-danger);
    background: var(--vttb-danger-soft);
}

.vttb-row-icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.vttb-row-icon-button svg {
    width: 17px;
    height: 17px;
}

.vttb-category-modal {
    width: min(920px, 100%);
}

.vttb-location-modal {
    width: min(620px, 100%);
}

.vttb-bulk-modal {
    width: min(720px, 100%);
}

.vttb-bulk-summary {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid var(--vttb-line);
    border-radius: 9px;
    background: var(--vttb-surface-muted);
}

.vttb-bulk-summary span {
    color: var(--vttb-muted);
}

.vttb-actions-spacer {
    flex: 1;
}

.vttb-history-modal {
    width: min(1080px, 100%);
}

.vttb-modal-header > div {
    min-width: 0;
}

.vttb-modal-header > div > span {
    display: block;
    margin-top: 4px;
    overflow: hidden;
    color: var(--vttb-muted);
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vttb-modal-header-actions,
.vttb-history-heading-actions,
.vttb-history-entry-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vttb-modal-header-actions {
    flex: 0 0 auto;
}

.vttb-history-heading-actions > svg {
    color: var(--vttb-primary);
}

.vttb-scoped-history-filters {
    display: grid;
    grid-template-columns: minmax(170px, 0.7fr) 130px minmax(170px, 0.7fr) minmax(240px, 1.4fr);
    gap: 8px;
    margin-bottom: 12px;
}

.vttb-device-history-modal .vttb-scoped-history-filters {
    grid-template-columns: 130px minmax(170px, 0.7fr) minmax(240px, 1.4fr);
}

.vttb-scoped-history-filters select,
.vttb-scoped-history-filters input,
.vttb-bulk-modal input,
.vttb-bulk-modal select {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--vttb-line);
    border-radius: 8px;
    background: var(--vttb-surface-muted);
    color: var(--vttb-text);
    outline: 0;
}

.vttb-scoped-history-filters .vttb-search-field {
    padding-block: 0;
}

.vttb-scoped-history-filters .vttb-search-field input {
    min-height: 38px;
    padding: 0;
    border: 0;
}

.vttb-scoped-history-list {
    display: grid;
    gap: 8px;
    max-height: min(62vh, 620px);
    overflow: auto;
    padding-right: 3px;
}

.vttb-scoped-history-event {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    padding: 11px;
    border: 1px solid var(--vttb-line);
    border-radius: 9px;
    background: var(--vttb-surface-muted);
}

.vttb-scoped-history-marker {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 8px;
    background: var(--vttb-primary-soft);
    color: var(--vttb-primary);
}

.vttb-scoped-history-content {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.vttb-scoped-history-title {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.vttb-scoped-history-title time,
.vttb-scoped-history-content span,
.vttb-scoped-history-content small {
    color: var(--vttb-muted);
    font-size: 0.73rem;
}

.vttb-scoped-history-content b {
    overflow-wrap: anywhere;
    font-size: 0.82rem;
}

.vttb-empty-state.is-compact {
    min-height: 150px;
}

.vttb-location-device {
    display: grid;
    gap: 3px;
    margin-bottom: 14px;
    padding: 11px 12px;
    border: 1px solid var(--vttb-line);
    border-radius: 9px;
    background: var(--vttb-surface-muted);
}

.vttb-location-device strong {
    color: var(--vttb-primary);
}

.vttb-location-device span,
.vttb-location-device small,
.vttb-form-hint {
    color: var(--vttb-muted);
}

.vttb-location-device small,
.vttb-form-hint {
    font-size: 0.75rem;
}

.vttb-form-hint {
    margin: 10px 0 0;
}

.vttb-category-form {
    display: grid;
    grid-template-columns: minmax(180px, 0.8fr) minmax(240px, 1.2fr) 100px auto;
    gap: 10px;
    align-items: end;
    padding: 13px;
    border: 1px solid var(--vttb-line);
    border-radius: 9px;
    background: var(--vttb-surface-muted);
}

.vttb-category-form label {
    display: grid;
    gap: 5px;
    color: var(--vttb-muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.vttb-category-form input {
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--vttb-line);
    border-radius: 8px;
    background: var(--vttb-surface);
    color: var(--vttb-text);
    outline: 0;
}

.vttb-category-form-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.vttb-category-manager-list {
    display: grid;
    gap: 7px;
    max-height: min(48vh, 460px);
    margin-top: 12px;
    overflow: auto;
}

.vttb-category-manager-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px 11px;
    border: 1px solid var(--vttb-line);
    border-radius: 9px;
}

.vttb-category-manager-row.is-archived {
    opacity: 0.72;
}

.vttb-category-manager-row > div:first-child {
    display: grid;
    min-width: 0;
}

.vttb-category-manager-row > div:first-child strong,
.vttb-category-manager-row > div:first-child span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vttb-category-manager-row > div:first-child span {
    color: var(--vttb-muted);
    font-size: 0.72rem;
}

.vttb-history-panel {
    margin-top: 14px;
}

.vttb-history-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 8px;
    margin-bottom: 10px;
}

.vttb-history-list {
    display: grid;
    gap: 5px;
    max-height: 420px;
    overflow: auto;
}

.vttb-history-entry {
    border-bottom: 1px solid var(--vttb-line);
}

.vttb-history-entry summary {
    gap: 9px;
    padding: 9px 2px;
    list-style: none;
    cursor: pointer;
}

.vttb-history-entry summary::-webkit-details-marker {
    display: none;
}

.vttb-history-icon {
    display: inline-grid;
    width: 28px;
    height: 28px;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 7px;
    background: var(--vttb-primary-soft);
    color: var(--vttb-primary);
}

.vttb-history-icon.is-archived {
    background: var(--vttb-danger-soft);
    color: var(--vttb-danger);
}

.vttb-history-icon.is-restored,
.vttb-history-icon.is-created {
    background: var(--vttb-success-soft);
    color: var(--vttb-success);
}

.vttb-history-main {
    display: grid;
    min-width: 0;
    flex: 1;
}

.vttb-history-main strong {
    font-size: 0.78rem;
}

.vttb-history-main span,
.vttb-history-entry time {
    overflow: hidden;
    color: var(--vttb-muted);
    font-size: 0.7rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vttb-history-details {
    display: grid;
    gap: 5px;
    padding: 0 0 10px 37px;
    color: var(--vttb-muted);
    font-size: 0.72rem;
}

.vttb-history-details pre {
    max-height: 120px;
    margin: 0;
    overflow: auto;
    padding: 8px;
    border-radius: 7px;
    background: var(--vttb-surface-muted);
    color: var(--vttb-text);
    font: 0.68rem/1.45 Consolas, monospace;
}

.vttb-history-entry-actions {
    justify-content: flex-end;
    margin-top: 3px;
}

.vttb-history-empty,
.vttb-muted-copy {
    padding: 18px 4px;
    color: var(--vttb-muted);
    font-size: 0.8rem;
}

.vttb-empty-state {
    display: grid;
    min-height: 220px;
    place-items: center;
    align-content: center;
    gap: 8px;
    padding: 24px;
    border: 1px dashed var(--vttb-line);
    border-radius: 9px;
    color: var(--vttb-muted);
    text-align: center;
}

.vttb-empty-state > svg {
    width: 34px;
    height: 34px;
    color: var(--vttb-primary);
}

.vttb-empty-state h3,
.vttb-empty-state p {
    margin: 0;
}

.vttb-empty-state h3 {
    color: var(--vttb-text);
    font-size: 0.98rem;
}

.vttb-empty-state p {
    font-size: 0.8rem;
}

.vttb-modal-backdrop {
    position: fixed;
    z-index: 30;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(10, 25, 35, 0.58);
}

.vttb-modal,
.vttb-confirm-modal {
    width: min(760px, 100%);
    max-height: calc(100vh - 36px);
    overflow: auto;
    padding: 20px;
    border: 1px solid var(--vttb-line);
    border-radius: 14px;
    background: var(--vttb-surface);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.vttb-confirm-modal {
    width: min(430px, 100%);
    text-align: center;
}

.vttb-modal-header {
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.vttb-modal-header h2,
.vttb-confirm-modal h2 {
    font-size: 1.2rem;
}

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

.vttb-editor-form label {
    display: grid;
    gap: 6px;
    color: var(--vttb-muted);
    font-size: 0.76rem;
    font-weight: 700;
}

.vttb-editor-form input,
.vttb-editor-form select,
.vttb-editor-form textarea {
    padding: 9px 10px;
}

.vttb-editor-form textarea {
    resize: vertical;
}

.vttb-span-2 {
    grid-column: 1 / -1;
}

.vttb-custom-fields {
    margin-top: 18px;
    padding-top: 15px;
    border-top: 1px solid var(--vttb-line);
}

.vttb-inline-heading {
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.vttb-inline-heading h3 {
    font-size: 0.96rem;
}

.vttb-custom-field-row {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) 38px;
    gap: 7px;
    margin-bottom: 7px;
}

.vttb-custom-field-row input {
    padding: 8px 9px;
}

.vttb-form-error {
    margin: 14px 0 0;
    color: var(--vttb-danger);
    font-size: 0.8rem;
    font-weight: 700;
}

.vttb-modal-actions {
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.vttb-confirm-icon {
    display: inline-grid;
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    place-items: center;
    border-radius: 50%;
    background: var(--vttb-warning-soft);
    color: var(--vttb-warning);
}

.vttb-confirm-modal p {
    margin: 10px 0 0;
    color: var(--vttb-muted);
    font-size: 0.85rem;
    line-height: 1.55;
}

.vttb-confirm-password-field {
    display: grid;
    gap: 6px;
    margin-top: 16px;
    color: var(--vttb-muted);
    font-size: 0.76rem;
    font-weight: 750;
    text-align: left;
}

.vttb-confirm-password-field input {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--vttb-line);
    border-radius: 9px;
    background: var(--vttb-surface-muted);
    color: var(--vttb-text);
    outline: 0;
}

.vttb-confirm-password-field input:focus {
    border-color: var(--vttb-primary);
    box-shadow: 0 0 0 3px var(--vttb-primary-soft);
}

.vttb-access-denied {
    display: grid;
    min-height: 100vh;
    place-items: center;
    align-content: center;
    gap: 10px;
    padding: 24px;
    background: var(--vttb-bg);
    text-align: center;
}

.vttb-access-denied > svg {
    width: 48px;
    height: 48px;
    color: var(--vttb-danger);
}

.vttb-access-denied h1,
.vttb-access-denied p {
    margin: 0;
}

.vttb-access-denied h1 {
    font-size: 1.4rem;
}

.vttb-access-denied p {
    color: var(--vttb-muted);
}

@media (max-width: 680px) {
    .vttb-toast {
        top: auto;
        right: 10px;
        bottom: 12px;
        width: calc(100vw - 20px);
    }

    .vttb-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .vttb-top-actions {
        justify-content: flex-start;
        flex-wrap: nowrap;
        width: 100%;
        padding-bottom: 2px;
        overflow-x: auto;
    }

    .vttb-category-bar {
        grid-template-columns: minmax(0, 1fr) max-content;
        gap: 8px;
        padding-bottom: 10px;
    }

    .vttb-category-label,
    .vttb-category-tabs {
        display: none;
    }

    .vttb-category-select {
        display: block;
        min-width: 0;
    }

    .vttb-connection {
        margin-right: 0;
    }

    .vttb-main {
        width: min(100% - 20px, 1600px);
        padding-top: 18px;
    }

    .vttb-form-grid {
        grid-template-columns: 1fr;
    }

    .vttb-summary-card {
        min-width: 116px;
    }

    .vttb-toolbar,
    .vttb-history-filters,
    .vttb-scoped-history-filters,
    .vttb-device-history-modal .vttb-scoped-history-filters {
        grid-template-columns: 1fr;
    }

    .vttb-bulk-toolbar,
    .vttb-bulk-summary {
        align-items: stretch;
        flex-direction: column;
    }

    .vttb-bulk-toolbar-actions {
        width: 100%;
    }

    .vttb-bulk-toolbar-actions > button {
        flex: 1;
    }

    .vttb-modal-header {
        align-items: flex-start;
    }

    .vttb-modal-header > div:first-child {
        flex: 1;
    }

    .vttb-modal-header-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .vttb-modal-header-actions .vttb-small-button {
        padding-inline: 8px;
    }

    .vttb-category-form,
    .vttb-category-manager-row {
        grid-template-columns: 1fr;
    }

    .vttb-category-form-actions,
    .vttb-category-manager-row .vttb-row-actions {
        justify-content: stretch;
    }

    .vttb-category-form-actions > button,
    .vttb-category-manager-row .vttb-row-actions > button {
        flex: 1;
    }

    .vttb-table-scrollbar,
    .vttb-table-wrap {
        border: 0;
        overflow: visible;
    }

    .vttb-table-scrollbar {
        display: none;
    }

    .vttb-table {
        min-width: 0;
    }

    .vttb-table thead {
        display: none;
    }

    .vttb-table,
    .vttb-table tbody,
    .vttb-table tr,
    .vttb-table td {
        display: block;
        width: 100%;
    }

    .vttb-table tr {
        margin-bottom: 9px;
        overflow: hidden;
        border: 1px solid var(--vttb-line);
        border-radius: 9px;
        background: var(--vttb-surface);
    }

    .vttb-table td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 10px;
        padding: 8px 10px;
        border-bottom: 1px solid var(--vttb-line);
        text-align: right;
    }

    .vttb-table td::before {
        flex: 0 0 38%;
        color: var(--vttb-muted);
        content: attr(data-label);
        font-size: 0.68rem;
        font-weight: 800;
        text-align: left;
        text-transform: uppercase;
    }

    .vttb-table td:last-child {
        border-bottom: 0;
    }

    .vttb-table td[data-label="Tên TB"],
    .vttb-table td[data-label="Ghi chú"],
    .vttb-table td[data-label="Certificate No."],
    .vttb-table td[data-label="Chứng chỉ tem điện"] {
        align-items: flex-start;
    }

    .vttb-table td.vttb-selection-column {
        align-items: center;
    }

    .vttb-item-name {
        max-width: 62%;
        text-align: right;
    }

    .vttb-note-cell {
        max-width: 62%;
        text-align: right;
    }

    .vttb-calibration-cell {
        max-width: 62%;
        text-align: right;
    }

    .vttb-table td > .vttb-row-actions {
        justify-content: flex-end;
    }

    .vttb-location-cell {
        max-width: 62%;
        justify-content: flex-end;
        text-align: right;
    }

    .vttb-location-cell .vttb-assignment-cell {
        min-width: 0;
    }

    .vttb-custom-field-row {
        grid-template-columns: 1fr 1fr 38px;
    }

    .vttb-modal-backdrop {
        padding: 10px;
    }

    .vttb-modal {
        padding: 15px;
    }

    .vttb-modal-actions {
        position: sticky;
        bottom: -15px;
        padding: 10px 0 0;
        background: var(--vttb-surface);
    }

    .vttb-bulk-actions {
        flex-wrap: wrap;
    }

    .vttb-bulk-actions .vttb-actions-spacer {
        display: none;
    }

    .vttb-scoped-history-title {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .vttb-toast {
        transition: none;
        animation: none;
    }
}

@media (max-width: 430px) {
    .vttb-main {
        width: calc(100% - 14px);
    }

    .vttb-topbar {
        padding-inline: 12px;
    }

    .vttb-inventory-panel,
    .vttb-history-panel {
        padding: 12px;
    }

    .vttb-custom-field-row {
        grid-template-columns: 1fr 38px;
    }

    .vttb-custom-field-row input:first-child {
        grid-column: 1 / -1;
    }
}
