:root {
    color-scheme: light;
    --bg: #edf3f7;
    --panel: rgba(255, 255, 255, 0.92);
    --panel-strong: #ffffff;
    --panel-soft: #f7fafc;
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.14);
    --text: #17212b;
    --text-soft: #586779;
    --text-muted: #7b8897;
    --primary: #005f73;
    --primary-soft: #dff4f5;
    --primary-strong: #0a9396;
    --accent: #ee9b00;
    --danger: #c0392b;
    --danger-soft: #fdecea;
    --success: #1b7f5c;
    --success-soft: #e7f6ef;
    --warning: #c97a00;
    --warning-soft: #fff4e0;
    --shadow: 0 12px 34px rgba(12, 31, 56, 0.07);
    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --header-height: 78px;
    --shell-gap: 14px;
    --panel-padding: 16px;
    --control-height: 38px;
    --button-height: 38px;
    --tiny-button-height: 30px;
    --font-sans: "Be Vietnam Pro", sans-serif;
    --font-mono: "JetBrains Mono", monospace;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-size: 15px;
    background:
        radial-gradient(circle at top left, rgba(10, 147, 150, 0.10), transparent 22%),
        radial-gradient(circle at top right, rgba(238, 155, 0, 0.10), transparent 28%),
        linear-gradient(180deg, #f7fbfd 0%, var(--bg) 100%);
    color: var(--text);
    font-family: var(--font-sans);
}

body {
    min-height: 100vh;
}

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

button {
    cursor: pointer;
}

a {
    color: inherit;
}

.app-shell {
    max-width: 1680px;
    margin: 0 auto;
    padding: 16px;
    display: grid;
    gap: var(--shell-gap);
}

.topbar {
    position: sticky;
    top: 12px;
    z-index: 30;
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.topbar-main {
    display: grid;
    gap: 0;
}

@media (min-width: 981px) {
    .topbar {
        grid-template-columns: minmax(220px, 292px) minmax(0, 1fr);
        grid-template-areas:
            "main actions"
            "search controls";
        align-items: start;
    }

    .topbar-main {
        grid-area: main;
        min-width: 0;
    }

    .topbar .toolbar {
        display: contents;
    }

    .topbar .search-box {
        grid-area: search;
    }

    .topbar .control-group {
        grid-area: controls;
        width: max-content;
        max-width: 100%;
        grid-template-columns: repeat(3, minmax(124px, 146px));
        justify-content: end;
        justify-self: end;
        align-items: center;
    }

    .topbar .toolbar-actions {
        grid-area: actions;
        justify-self: end;
        align-self: start;
    }

    .topbar .control-field {
        gap: 0;
    }

    .topbar .control-field label {
        display: none;
    }

    .topbar .filter-row {
        display: none;
    }
}

.brand {
    display: grid;
    gap: 0;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: nowrap;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #0a9396, #005f73);
    color: #ffffff;
    box-shadow: 0 8px 22px rgba(0, 95, 115, 0.18);
}

.brand-title {
    margin: 0;
    font-size: clamp(1.18rem, 1.7vw, 1.55rem);
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.brand-subtitle {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.86rem;
    max-width: 820px;
    display: none;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.topbar .status-row {
    display: none;
}

.status-chip,
.metric-badge,
.filter-chip,
.tag,
.tab-button,
.tiny-button,
.action-button,
.ghost-button {
    border-radius: 999px;
    border: 1px solid transparent;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px;
    background: var(--panel-soft);
    border-color: var(--border);
    font-size: 0.8rem;
    color: var(--text-soft);
}

.status-chip strong {
    font-weight: 700;
    color: var(--text);
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 0 0 0 4px rgba(123, 136, 151, 0.14);
}

.status-live .status-dot {
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(27, 127, 92, 0.15);
}

.status-syncing .status-dot {
    background: var(--primary-strong);
    box-shadow: 0 0 0 4px rgba(10, 147, 150, 0.16);
}

.status-offline .status-dot,
.status-error .status-dot {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.14);
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 0.92fr) minmax(420px, 1.08fr) auto;
    gap: 8px;
    align-items: center;
}

.search-box,
.control-group,
.toolbar-actions,
.sidebar-toolbar,
.tab-toolbar,
.empty-state,
.overview-card,
.panel,
.table-card,
.inline-editor,
.notice,
.modal-card {
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.topbar .search-box,
.topbar .control-group,
.topbar .toolbar-actions,
.topbar .filter-row {
    box-shadow: none;
}

.topbar .control-group,
.topbar .toolbar-actions {
    background: transparent;
    border: 0;
    padding: 0;
}

.topbar .control-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.topbar .control-field {
    min-width: 0;
}

.topbar .toolbar-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 4px;
}

.topbar .search-box {
    min-height: 40px;
    max-width: 360px;
    width: 100%;
}

.topbar .filter-row {
    display: none;
}

.topbar .action-button,
.topbar .ghost-button {
    white-space: nowrap;
    min-height: 34px;
    padding-inline: 10px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 14px;
}

.search-box input {
    border: 0;
    outline: 0;
    width: 100%;
    background: transparent;
    color: var(--text);
    font-size: 0.92rem;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.control-group {
    display: flex;
    gap: 8px;
    padding: 6px;
    border-radius: 14px;
    flex-wrap: wrap;
}

.control-field {
    min-width: 140px;
    flex: 1;
    display: grid;
    gap: 5px;
}

.control-field label,
.field label,
.modal-section-title,
.panel-heading {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.control-field select,
.field input,
.field select,
.field textarea,
.inline-input,
.inline-select {
    min-height: var(--control-height);
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: #ffffff;
    color: var(--text);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field textarea {
    min-height: 96px;
    resize: vertical;
}

.control-field select:focus,
.field input:focus,
.field select:focus,
.field textarea:focus,
.inline-input:focus,
.inline-select:focus {
    border-color: rgba(10, 147, 150, 0.65);
    box-shadow: 0 0 0 4px rgba(10, 147, 150, 0.12);
}

.toolbar-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 6px;
    border-radius: 14px;
}

.action-button,
.ghost-button,
.tiny-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: var(--button-height);
    padding: 0 14px;
    font-weight: 700;
    font-size: 0.84rem;
    border: 1px solid transparent;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.action-button:disabled,
.ghost-button:disabled,
.tiny-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    box-shadow: none;
}

.action-button {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #ffffff;
    box-shadow: 0 12px 30px rgba(0, 95, 115, 0.22);
}

.action-button.secondary {
    background: linear-gradient(135deg, #dd6b20, #ee9b00);
    box-shadow: 0 12px 30px rgba(221, 107, 32, 0.24);
}

.ghost-button {
    background: #ffffff;
    color: var(--text-soft);
    border-color: var(--border);
}

.action-button:hover,
.ghost-button:hover,
.tiny-button:hover {
    transform: translateY(-1px);
}

.overview-grid {
    display: block;
}

.overview-strip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    align-items: stretch;
}

.overview-metrics {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
}

.overview-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    border-radius: 12px;
    padding: 7px 10px;
    position: relative;
    overflow: hidden;
    box-shadow: none;
    background: #ffffff;
}

.overview-card::after {
    display: none;
}

.overview-label {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overview-value {
    margin: 0;
    font-size: clamp(1.04rem, 1.35vw, 1.28rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    text-align: right;
    flex: 0 0 auto;
}

.overview-note {
    display: none;
}

.overview-picker {
    display: grid;
    align-content: center;
    gap: 4px;
    min-width: 210px;
    max-width: 240px;
    padding: 7px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #ffffff;
    box-shadow: none;
}

.overview-picker-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.overview-picker select,
.overview-picker-button {
    min-height: 34px;
    width: 100%;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: #ffffff;
    color: var(--text);
    font-size: 0.84rem;
}

.overview-picker-button {
    display: inline-flex;
    align-items: center;
}

.overview-picker.is-disabled {
    opacity: 0.7;
}

.workspace {
    display: grid;
    grid-template-columns: 324px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.panel,
.table-card,
.empty-state {
    border-radius: 20px;
}

.sidebar {
    position: sticky;
    top: calc(var(--header-height) + 22px);
    max-height: calc(100vh - 122px);
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.sidebar-toolbar,
.detail-panel {
    border-radius: 20px;
    padding: 14px;
}

.sidebar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 0 2px;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.sidebar-toolbar .panel-title,
.sidebar-toolbar .panel-description,
.sidebar-toolbar .notice,
.sidebar-caption {
    display: none;
}

.sidebar-list {
    padding: 4px 6px 8px;
    overflow: auto;
    display: grid;
    gap: 8px;
}

.rig-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #ffffff;
    text-align: left;
    color: inherit;
    font: inherit;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.rig-row:hover {
    transform: translateY(-1px);
    border-color: rgba(0, 95, 115, 0.26);
    box-shadow: 0 8px 18px rgba(0, 95, 115, 0.07);
}

.rig-row.is-selected {
    border-color: rgba(10, 147, 150, 0.38);
    background: linear-gradient(180deg, #ffffff 0%, #f3fbfb 100%);
    box-shadow: 0 10px 20px rgba(10, 147, 150, 0.1);
}

.rig-row-main {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.rig-row-title {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rig-row-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.rig-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    flex: 0 0 8px;
    background: #b8c2d0;
}

.rig-status-dot.is-active {
    background: #1f9d55;
}

.rig-status-dot.is-idle {
    background: #9ca3af;
}

.rig-row-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex: 0 0 auto;
}

.rig-card {
    display: grid;
    gap: 10px;
    padding: 13px;
    border-radius: 15px;
    border: 1px solid var(--border);
    background: #ffffff;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.rig-card:hover {
    transform: translateY(-1px);
    border-color: rgba(0, 95, 115, 0.3);
    box-shadow: 0 10px 26px rgba(0, 95, 115, 0.08);
}

.rig-card.is-selected {
    border-color: rgba(10, 147, 150, 0.45);
    box-shadow: 0 12px 28px rgba(10, 147, 150, 0.13);
    background: linear-gradient(180deg, #ffffff 0%, #f3fbfb 100%);
}

.rig-header-row,
.rig-meta-row,
.detail-title-row,
.detail-header-actions,
.detail-summary-row,
.tab-toolbar,
.documents-list-item,
.history-item,
.modal-header,
.modal-footer,
.confirm-body,
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.rig-name,
.detail-title,
.empty-title {
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.rig-name {
    font-size: 0.92rem;
}

.rig-code,
.mono {
    font-family: var(--font-mono);
}

.rig-code {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    border-radius: 999px;
    background: #edf7f8;
    color: var(--primary);
    font-size: 0.74rem;
    font-weight: 700;
}

.rig-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.stat-cell {
    border-radius: 12px;
    background: var(--panel-soft);
    padding: 8px 10px;
    display: grid;
    gap: 3px;
}

.stat-value {
    font-size: 0.96rem;
    font-weight: 800;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.tag,
.filter-chip,
.metric-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text-soft);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-chip {
    background: var(--panel-soft);
}

.filter-chip.is-active,
.tab-button.is-active {
    background: var(--primary);
    color: #ffffff;
    border-color: rgba(0, 95, 115, 0.45);
}

.detail-panel {
    min-height: 560px;
    display: grid;
    gap: 10px;
}

.detail-header {
    display: grid;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid var(--border);
}

.detail-title-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: flex-start;
    gap: 8px;
}

.detail-title-row > div:first-child {
    min-width: 0;
    display: grid;
    gap: 4px;
    flex: 1;
}

.detail-title {
    font-size: clamp(1rem, 1.18vw, 1.24rem);
}

.detail-subtitle {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.8rem;
}

.detail-summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-start;
    align-items: center;
}

.detail-summary-row .tag,
.detail-summary-row .metric-badge {
    padding: 5px 9px;
    font-size: 0.7rem;
}

.detail-header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    align-items: center;
}

.detail-header-actions .ghost-button {
    min-height: 32px;
    padding-inline: 9px;
    font-size: 0.76rem;
    white-space: nowrap;
}

.detail-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    padding-top: 2px;
}

.tab-button {
    min-height: 32px;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    color: var(--text-soft);
    border-color: var(--border);
    font-weight: 700;
    font-size: 0.78rem;
}

.tab-content {
    display: grid;
    gap: 10px;
}

.panel {
    padding: 12px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.panel-title {
    margin: 0 0 4px;
    font-size: 0.96rem;
    font-weight: 800;
}

.panel-description {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.84rem;
}

.detail-panel .panel-description {
    display: none;
}

.metrics-grid,
.inventory-grid,
.overview-split,
.two-column-grid,
.documents-grid {
    display: grid;
    gap: 12px;
}

.metrics-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.overview-split {
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
    gap: 8px;
}

.two-column-grid,
.inventory-grid,
.documents-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.metric-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfc 100%);
    border: 1px solid var(--border);
}

.metric-panel .overview-label {
    margin: 0;
}

.metric-panel .overview-value {
    margin-top: 0;
    text-align: right;
}

.metric-panel .overview-note {
    display: none;
}

.notice {
    border-radius: 12px;
    padding: 10px 12px;
}

.notice.info {
    background: #eef8fb;
    border-color: rgba(0, 95, 115, 0.14);
}

.notice.warning {
    background: var(--warning-soft);
    border-color: rgba(201, 122, 0, 0.16);
}

.notice.error {
    background: var(--danger-soft);
    border-color: rgba(192, 57, 43, 0.16);
}

.empty-state {
    padding: 28px;
    text-align: center;
}

.empty-title {
    font-size: 1.08rem;
    margin-bottom: 8px;
}

.empty-copy {
    margin: 0;
    color: var(--text-soft);
}

.table-card {
    overflow: hidden;
}

.table-toolbar {
    padding: 10px 12px 0;
    align-items: flex-end;
    flex-wrap: wrap;
}

.task-filter-toolbar {
    display: grid;
    grid-template-columns: minmax(180px, 240px) repeat(3, minmax(132px, 1fr));
    gap: 8px;
    align-items: end;
}

.task-filter-toolbar .search-box,
.task-filter-toolbar .control-field.compact {
    min-height: 40px;
}

.task-filter-toolbar .search-box.compact {
    max-width: none;
}

.task-filter-toolbar .control-field.compact {
    min-width: 0;
}

.table-scroller {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    text-align: left;
    vertical-align: top;
}

th {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: rgba(236, 243, 247, 0.75);
}

tbody tr:hover {
    background: rgba(0, 95, 115, 0.03);
}

.task-title {
    display: grid;
    gap: 6px;
}

.task-detail {
    color: var(--text-soft);
    font-size: 0.79rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.progress-track {
    width: 100%;
    height: 8px;
    background: #e6edf1;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), var(--primary-strong));
}

.tiny-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tiny-button {
    min-height: var(--tiny-button-height);
    padding: 0 10px;
    background: #ffffff;
    border-color: var(--border);
    color: var(--text-soft);
    font-size: 0.74rem;
}

.tiny-button.primary {
    background: var(--primary-soft);
    border-color: rgba(0, 95, 115, 0.12);
    color: var(--primary);
}

.tiny-button.danger {
    background: var(--danger-soft);
    border-color: rgba(192, 57, 43, 0.12);
    color: var(--danger);
}

.documents-list,
.history-list,
.shift-list {
    display: grid;
    gap: 10px;
}

.documents-list-item,
.history-item,
.shift-item {
    border-radius: 15px;
    padding: 13px;
    background: #ffffff;
    border: 1px solid var(--border);
    align-items: flex-start;
}

.shift-item,
.history-item {
    display: grid;
    gap: 8px;
}

.documents-list-item {
    align-items: center;
}

.list-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
}

.list-copy {
    margin: 6px 0 0;
    color: var(--text-soft);
    font-size: 0.82rem;
    line-height: 1.42;
}

.list-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.76rem;
}

.history-layout {
    grid-template-columns: minmax(0, 1.28fr) minmax(300px, 0.72fr);
    align-items: start;
}

.history-main-panel,
.history-side-panel {
    min-height: 100%;
}

.history-side-section {
    display: grid;
    gap: 10px;
}

.history-side-divider {
    height: 1px;
    margin: 14px 0;
    background: rgba(15, 23, 42, 0.08);
}

.section-label {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.comparison-list,
.audit-change-list {
    display: grid;
    gap: 8px;
}

.comparison-item {
    display: grid;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid var(--border);
}

.comparison-top,
.audit-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.comparison-note,
.audit-empty {
    color: var(--text-soft);
    font-size: 0.8rem;
    line-height: 1.42;
}

.audit-entry {
    gap: 10px;
}

.audit-entry .list-copy {
    margin-top: 0;
    white-space: pre-wrap;
}

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

.audit-block {
    display: grid;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #f8fbfc;
    border: 1px solid var(--border);
}

.audit-block strong {
    font-size: 0.8rem;
}

.audit-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 6px;
    color: var(--text-soft);
    font-size: 0.8rem;
}

.audit-list li {
    line-height: 1.42;
}

.audit-change-item {
    display: grid;
    gap: 5px;
    padding: 9px 10px;
    border-radius: 10px;
    background: #fffaf2;
    border: 1px solid rgba(201, 122, 0, 0.14);
}

.snapshot-details {
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    padding: 10px 12px;
    background: #f8fafc;
}

.snapshot-details summary {
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-soft);
}

.snapshot-pre {
    margin: 10px 0 0;
    max-height: 320px;
    overflow: auto;
    padding: 12px;
    border-radius: 10px;
    background: #16202b;
    color: #eef5f7;
    font-size: 0.72rem;
    line-height: 1.5;
}

.compact-history-list .history-item {
    padding: 10px 12px;
}

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

.field-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
    display: grid;
    gap: 6px;
}

.field.full {
    grid-column: 1 / -1;
}

.validation {
    margin-top: 4px;
    color: var(--danger);
    font-size: 0.8rem;
    min-height: 1rem;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(17, 24, 39, 0.45);
    backdrop-filter: blur(10px);
}

.modal-card {
    width: min(920px, calc(100vw - 24px));
    max-height: calc(100vh - 40px);
    overflow: auto;
    border-radius: 24px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.96);
}

.modal-card.wide {
    width: min(1360px, calc(100vw - 24px));
}

.modal-card.compact {
    width: min(560px, calc(100vw - 24px));
}

.activity-history-modal {
    display: grid;
    gap: 12px;
}

.activity-history-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.activity-history-layout {
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.7fr);
    gap: 12px;
}

.activity-history-list {
    max-height: calc(100vh - 280px);
    overflow: auto;
    padding-right: 4px;
}

.activity-history-side {
    box-shadow: none;
}

.history-summary-stamp {
    font-size: 0.82rem;
    text-align: left;
}

.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(10, 18, 28, 0.56);
    backdrop-filter: blur(10px);
}

.auth-card {
    width: min(420px, calc(100vw - 28px));
    padding: 24px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow);
}

.auth-title {
    margin: 0 0 8px;
    font-size: 1.28rem;
    font-weight: 800;
}

.auth-copy {
    margin: 0 0 16px;
    color: var(--text-soft);
    line-height: 1.5;
}

.sr-only-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.modal-header {
    align-items: flex-start;
    margin-bottom: 14px;
}

.modal-title {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 800;
}

.modal-subtitle {
    margin: 0;
    color: var(--text-soft);
}

.close-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text-soft);
}

.modal-footer {
    margin-top: 14px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.modal-divider {
    height: 1px;
    margin: 14px 0;
    background: rgba(15, 23, 42, 0.08);
}

.form-stack {
    display: grid;
    gap: 14px;
}

.confirm-body {
    align-items: flex-start;
}

.confirm-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--danger-soft);
    color: var(--danger);
}

.toast-stack {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 70;
    display: grid;
    gap: 8px;
    width: min(360px, calc(100vw - 20px));
}

.toast {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 15px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    background: rgba(255, 255, 255, 0.98);
}

.toast.success {
    border-color: rgba(27, 127, 92, 0.18);
}

.toast.error {
    border-color: rgba(192, 57, 43, 0.2);
}

.toast.info {
    border-color: rgba(0, 95, 115, 0.16);
}

.muted {
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.status-ndt-active,
.status-task-done,
.status-stock-ok {
    background: var(--success-soft);
    color: var(--success);
    border-color: rgba(27, 127, 92, 0.15);
}

.status-ndt-idle {
    background: #f2f5f7;
    color: #566476;
}

.status-task-active {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(0, 95, 115, 0.14);
}

.status-task-paused,
.status-stock-low {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: rgba(201, 122, 0, 0.15);
}

.status-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(192, 57, 43, 0.16);
}

@media (max-width: 1280px) {
    .overview-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .workspace {
        grid-template-columns: 300px minmax(0, 1fr);
    }

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .app-shell {
        padding: 14px;
    }

    .topbar .toolbar {
        display: grid;
    }

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

    .topbar .control-group {
        grid-template-columns: 1fr;
    }

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

    .sidebar {
        position: static;
        max-height: none;
    }

    .metrics-grid,
    .overview-split,
    .two-column-grid,
    .inventory-grid,
    .documents-grid,
    .activity-history-summary,
    .audit-handover-grid,
    .field-grid,
    .field-grid.compact {
        grid-template-columns: 1fr;
    }

    .task-filter-toolbar,
    .activity-history-layout {
        grid-template-columns: 1fr;
    }

    .overview-strip {
        grid-template-columns: 1fr;
    }

    .overview-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .overview-picker {
        min-width: 0;
    }
}

@media (max-width: 720px) {
    .topbar {
        position: static;
        padding: 15px;
    }

    .topbar-main,
    .toolbar-actions,
    .detail-title-row,
    .detail-header-actions,
    .table-toolbar,
    .modal-header,
    .modal-footer,
    .documents-list-item,
    .tab-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar .toolbar-actions {
        justify-content: stretch;
    }

    .task-filter-toolbar .control-group {
        grid-template-columns: 1fr;
    }

    .overview-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .rig-stats {
        grid-template-columns: 1fr;
    }

    th,
    td {
        padding: 10px;
    }
}

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

    .action-button,
    .ghost-button,
    .tiny-button,
    .tab-button {
        width: 100%;
    }

    .modal-card {
        padding: 16px;
        border-radius: 20px;
    }
}
