:root {
    --pf-bg: #f8faff;
    --pf-panel: #ffffff;
    --pf-panel-soft: #eff4ff;
    --pf-panel-mid: #e5eeff;
    --pf-border: #e2e8f0;
    --pf-border-strong: #cbd5e1;
    --pf-text: #0f172a;
    --pf-muted: #475569;
    --pf-faint: #94a3b8;
    --pf-navy: #131b2e;
    --pf-blue: #2563eb;
    --pf-green: #059669;
    --pf-amber: #d97706;
    --pf-red: #dc2626;
}

html,
body {
    background: var(--pf-bg);
    color: var(--pf-text);
    font-family: Inter, Segoe UI, sans-serif;
    font-size: 13px;
    line-height: 18px;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: 22px;
    line-height: 28px;
    font-weight: 700;
}

h2 {
    font-size: 18px;
    line-height: 24px;
    font-weight: 600;
}

code,
.numeric,
.scanner-field input,
.link-code {
    font-family: "JetBrains Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

.topbar {
    border-bottom: 1px solid var(--pf-border);
    height: 48px;
}

.mobile-menu-button {
    display: none !important;
}

.brand-mini,
.drawer-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-mini .material-symbols-outlined,
.drawer-header .material-symbols-outlined {
    color: #b4c5ff;
}

.brand-mini div,
.drawer-header div {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.brand-mini small,
.drawer-header small {
    color: #b4c5ff;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.scanner-field {
    align-items: center;
    background: var(--pf-panel-soft);
    border: 1px solid var(--pf-border);
    border-radius: 4px;
    display: flex;
    gap: 6px;
    margin-right: 8px;
    max-width: 430px;
    min-width: 300px;
    padding: 3px 8px;
}

.scanner-field input {
    background: transparent;
    border: 0;
    color: var(--pf-text);
    outline: 0;
    width: 100%;
}

.nav-drawer {
    background: var(--pf-navy) !important;
    color: #eaf1ff !important;
}

.mobile-nav-drawer {
    display: none !important;
}

.drawer-header {
    background: #0f172a;
    height: 48px;
    padding: 0 16px;
}

.nav-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 8px;
}

.nav-section {
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 600;
    margin: 14px 8px 4px;
    text-transform: uppercase;
}

.nav-stack a {
    align-items: center;
    border-radius: 4px;
    color: #cbd5e1;
    display: flex;
    gap: 8px;
    min-height: 30px;
    padding: 5px 8px;
    text-decoration: none;
}

.nav-stack a.active {
    background: var(--pf-blue);
    color: #ffffff;
    font-weight: 600;
}

.nav-stack .material-symbols-outlined,
.status-footer .material-symbols-outlined {
    font-size: 16px;
}

.drawer-foot {
    align-items: center;
    background: #213145;
    bottom: 0;
    display: flex;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 12px;
    justify-content: space-between;
    left: 0;
    padding: 9px 12px;
    position: absolute;
    right: 0;
}

.drawer-foot span {
    align-items: center;
    display: flex;
    gap: 4px;
}

.user-menu-name {
    color: var(--pf-muted);
    font-size: 12px;
    min-width: 180px;
    padding: 10px 16px 4px;
}

.main-shell {
    background: var(--pf-bg);
    min-height: calc(100vh - 32px);
    padding: 64px 16px 48px;
}

.status-footer {
    align-items: center;
    background: var(--pf-panel-soft);
    border-top: 1px solid var(--pf-border);
    bottom: 0;
    color: var(--pf-muted);
    display: flex;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 11px;
    gap: 20px;
    height: 32px;
    left: 240px;
    padding: 0 16px;
    position: fixed;
    right: 0;
    z-index: 1200;
}

.status-footer span {
    align-items: center;
    display: inline-flex;
    gap: 4px;
}

.footer-shortcuts {
    margin-left: auto;
}

.command-strip,
.page-band,
.toolbar-band,
.entity-header,
.panel,
.warehouse-card {
    background: var(--pf-panel);
    border: 1px solid var(--pf-border);
    border-radius: 4px;
}

.command-strip,
.page-band,
.entity-header {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 16px;
}

.page-band p,
.command-strip p,
.entity-header p,
.workflow-panel p {
    color: var(--pf-muted);
    margin-top: 4px;
}

.page-band.compact {
    justify-content: flex-start;
    margin-top: 16px;
}

.eyebrow {
    color: var(--pf-blue);
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.kpi-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-bottom: 16px;
}

.kpi-grid.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
    border: 1px solid var(--pf-border);
    border-radius: 4px;
    min-height: 104px;
    overflow: hidden;
    padding: 12px;
    position: relative;
}

.metric-card::after {
    background: var(--pf-blue);
    bottom: 0;
    content: "";
    height: 2px;
    left: 0;
    opacity: .35;
    position: absolute;
    right: 0;
}

.metric-card.warning::after {
    background: var(--pf-amber);
    opacity: 1;
}

.metric-card.critical::after {
    background: var(--pf-red);
    opacity: 1;
}

.metric-top {
    align-items: center;
    color: var(--pf-muted);
    display: flex;
    font-size: 11px;
    font-weight: 700;
    justify-content: space-between;
    text-transform: uppercase;
}

.metric-card strong {
    display: block;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 20px;
    line-height: 24px;
    margin-top: 12px;
}

.metric-card small {
    color: var(--pf-muted);
    display: block;
    font-size: 11px;
    margin-top: 4px;
}

.dashboard-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 7fr) minmax(320px, 5fr);
}

.side-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel {
    padding: 12px;
}

.panel-header,
.warehouse-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.panel-header > div {
    align-items: center;
    display: flex;
    gap: 6px;
}

.panel-header > span {
    color: var(--pf-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 11px;
}

.dense-table th {
    background: #f8fafc;
    border-bottom: 1px solid var(--pf-border-strong);
    color: var(--pf-muted) !important;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.dense-table td {
    border-bottom: 1px solid #f1f5f9;
    font-size: 12px;
    height: 36px;
}

.numeric {
    text-align: right !important;
}

.delta {
    font-weight: 700;
}

.status-chip {
    align-items: center;
    background: #f1f5f9;
    border: 1px solid var(--pf-border);
    border-radius: 4px;
    color: var(--pf-muted);
    display: inline-flex;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 10px;
    font-weight: 700;
    gap: 5px;
    padding: 2px 6px;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-chip span {
    background: var(--pf-muted);
    border-radius: 999px;
    height: 6px;
    width: 6px;
}

.status-chip.success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.status-chip.success span {
    background: var(--pf-green);
}

.status-chip.warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #b45309;
}

.status-chip.warning span {
    background: var(--pf-amber);
}

.status-chip.critical {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.status-chip.critical span {
    background: var(--pf-red);
}

.status-chip.reserved {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.status-chip.reserved span {
    background: var(--pf-blue);
}

.reorder-line {
    align-items: center;
    background: var(--pf-panel-soft);
    border-radius: 4px;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    margin-top: 8px;
    padding: 8px;
}

.reorder-line div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.reorder-line strong,
.product-cell strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reorder-line span,
.product-cell span {
    color: var(--pf-muted);
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 11px;
}

.scanner {
    background: #0f172a;
    color: #ffffff;
}

.scanner .panel-header > span,
.scanner p {
    color: #cbd5e1;
}

.rig-grid,
.warehouse-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 16px;
}

.rig-card {
    align-items: center;
    border: 1px solid var(--pf-border);
    border-radius: 4px;
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr auto auto;
    padding: 10px;
}

.rig-card.critical {
    background: #fef2f2;
    border-color: #fecaca;
}

.rig-card div,
.rig-meta {
    display: flex;
    flex-direction: column;
}

.rig-card span,
.rig-meta span {
    color: var(--pf-muted);
    font-size: 11px;
}

.toolbar-band {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(260px, 1fr) 220px;
    margin-bottom: 16px;
    padding: 10px;
}

.product-cell {
    align-items: center;
    display: flex;
    gap: 8px;
    min-width: 260px;
}

.product-cell img,
.entity-header img {
    background: var(--pf-panel-soft);
    border: 1px solid var(--pf-border);
    border-radius: 4px;
    height: 36px;
    object-fit: cover;
    width: 36px;
}

.entity-header img {
    height: 96px;
    width: 96px;
}

.link-code {
    color: var(--pf-blue);
    cursor: pointer;
    font-weight: 700;
}

.detail-tabs {
    background: var(--pf-panel);
    border: 1px solid var(--pf-border);
    border-radius: 4px;
    overflow: hidden;
    padding: 4px 12px 12px;
}

.spec-grid {
    display: grid;
    gap: 8px 16px;
    grid-template-columns: max-content 1fr;
    padding: 12px 0;
}

.spec-grid span {
    color: var(--pf-muted);
}

.spec-grid.tight {
    font-size: 12px;
    padding-bottom: 0;
}

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

.warehouse-card {
    padding: 14px;
}

.warehouse-card p {
    color: var(--pf-muted);
    margin-bottom: 10px;
}

.workflow-panel {
    max-width: 960px;
}

.workflow-steps {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 16px;
}

.workflow-steps span,
.icon-block {
    background: var(--pf-panel-soft);
    border: 1px solid var(--pf-border);
    border-radius: 4px;
    padding: 8px;
}

.icon-block {
    color: var(--pf-blue);
    display: grid;
    height: 40px;
    place-items: center;
    width: 40px;
}

.empty-state {
    background: var(--pf-panel);
    border: 1px solid var(--pf-border);
    border-radius: 4px;
    padding: 24px;
}

.login-shell {
    align-items: center;
    background: var(--pf-bg);
    display: grid;
    min-height: 100vh;
    padding: 24px;
    place-items: center;
}

.login-panel {
    background: var(--pf-panel);
    border: 1px solid var(--pf-border);
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .08);
    display: grid;
    gap: 20px;
    max-width: 420px;
    padding: 28px;
    width: 100%;
}

.login-brand {
    align-items: center;
    display: flex;
    gap: 10px;
}

.login-brand .material-symbols-outlined {
    background: var(--pf-navy);
    border-radius: 4px;
    color: #b4c5ff;
    display: grid;
    height: 42px;
    place-items: center;
    width: 42px;
}

.login-brand div {
    display: flex;
    flex-direction: column;
}

.login-brand strong {
    font-size: 18px;
}

.login-brand small,
.login-panel p,
.login-hint span {
    color: var(--pf-muted);
}

.login-form {
    display: grid;
    gap: 12px;
}

.login-hint {
    background: var(--pf-panel-soft);
    border: 1px solid var(--pf-border);
    border-radius: 4px;
    display: grid;
    gap: 4px;
    padding: 10px;
}

.login-hint code {
    color: var(--pf-text);
}

#blazor-error-ui {
    background: #fef2f2;
    border-top: 1px solid #fecaca;
    bottom: 0;
    color: #7f1d1d;
    display: none;
    left: 0;
    padding: .6rem 1.25rem;
    position: fixed;
    right: 0;
    z-index: 2000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: .75rem;
}

.loading-progress {
    display: block;
    height: 8rem;
    margin: 20vh auto 1rem;
    width: 8rem;
}

.loading-progress circle {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: .6rem;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.loading-progress circle:last-child {
    stroke: var(--pf-blue);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * .8), 500%;
}

.loading-progress-text {
    font-family: "JetBrains Mono", Consolas, monospace;
    text-align: center;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

@media (max-width: 1100px) {
    .kpi-grid,
    .kpi-grid.four,
    .rig-grid,
    .warehouse-grid,
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scanner-field,
    .footer-shortcuts {
        display: none;
    }
}

@media (max-width: 760px) {
    html,
    body {
        font-size: 12px;
        line-height: 17px;
    }

    h1 {
        font-size: 19px;
        line-height: 24px;
    }

    h2 {
        font-size: 16px;
        line-height: 22px;
    }

    .mobile-menu-button {
        display: inline-flex !important;
        margin-right: 4px;
    }

    .desktop-nav {
        display: none !important;
    }

    .mobile-nav-drawer {
        display: flex !important;
    }

    .brand-mini small {
        display: none;
    }

    .brand-mini strong {
        font-size: 13px;
        white-space: nowrap;
    }

    .topbar .mud-toolbar {
        gap: 4px;
        min-height: 48px;
        padding-left: 6px;
        padding-right: 6px;
    }

    .topbar .mud-button-root {
        min-width: 36px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .topbar .mud-menu {
        margin-left: 0;
    }

    .main-shell {
        margin-left: 0 !important;
        padding: 58px 8px 58px;
    }

    .status-footer {
        font-size: 10px;
        gap: 8px;
        height: 36px;
        left: 0;
        padding: 0 8px;
    }

    .status-footer span:nth-child(2) {
        display: none;
    }

    .command-strip,
    .page-band,
    .entity-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 12px;
        padding: 12px;
    }

    .page-band.compact {
        display: grid;
        grid-template-columns: 40px minmax(0, 1fr);
    }

    .page-band.compact .mud-spacer {
        display: none;
    }

    .page-band.compact .status-chip {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .action-row {
        justify-content: stretch;
        width: 100%;
    }

    .action-row .mud-button-root,
    .page-band > .mud-button-root,
    .entity-header > .mud-button-root {
        flex: 1 1 100%;
        width: 100%;
    }

    .kpi-grid,
    .kpi-grid.four,
    .rig-grid,
    .warehouse-grid,
    .dashboard-grid,
    .toolbar-band,
    .workflow-steps {
        grid-template-columns: 1fr;
    }

    .metric-card {
        min-height: 92px;
        padding: 10px;
    }

    .metric-card strong {
        font-size: 18px;
        line-height: 23px;
        overflow-wrap: anywhere;
    }

    .dashboard-grid,
    .rig-grid,
    .warehouse-grid {
        gap: 10px;
        margin-top: 12px;
    }

    .panel {
        padding: 10px;
    }

    .panel-header,
    .warehouse-head {
        align-items: flex-start;
        gap: 8px;
    }

    .panel-header > div,
    .warehouse-head > div {
        min-width: 0;
    }

    .panel-header > span {
        text-align: right;
    }

    .toolbar-band {
        gap: 8px;
        padding: 8px;
    }

    .product-cell {
        min-width: 0;
        width: 100%;
    }

    .product-cell div {
        min-width: 0;
    }

    .entity-header img {
        height: 72px;
        width: 72px;
    }

    .entity-header p {
        display: grid;
        gap: 2px;
    }

    .detail-tabs {
        padding: 0 8px 10px;
    }

    .login-shell {
        padding: 12px;
    }

    .login-panel {
        gap: 16px;
        padding: 20px;
    }

    .spec-grid {
        grid-template-columns: 1fr;
        gap: 3px;
    }

    .spec-grid strong {
        margin-bottom: 8px;
        overflow-wrap: anywhere;
    }

    .reorder-line {
        align-items: stretch;
        flex-direction: column;
    }

    .reorder-line .mud-button-root {
        width: 100%;
    }

    .rig-card {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .rig-meta {
        grid-column: 1 / -1;
    }

    .dense-table .mud-table-head {
        display: none;
    }

    .dense-table .mud-table-body,
    .dense-table .mud-table-row {
        display: block;
    }

    .dense-table .mud-table-row {
        background: var(--pf-panel);
        border: 1px solid var(--pf-border);
        border-radius: 4px;
        margin-bottom: 10px;
        overflow: hidden;
    }

    .dense-table .mud-table-cell {
        align-items: start;
        border-bottom: 1px solid #eef2f7;
        display: grid !important;
        gap: 8px;
        grid-template-columns: 92px minmax(0, 1fr);
        height: auto;
        min-height: 34px;
        padding: 8px 10px !important;
        text-align: left !important;
        white-space: normal;
    }

    .dense-table .mud-table-cell:last-child {
        border-bottom: 0;
    }

    .dense-table .mud-table-cell::before {
        color: var(--pf-muted);
        content: attr(data-label);
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
    }

    .dense-table .mud-table-cell code,
    .dense-table .mud-table-cell strong {
        overflow-wrap: anywhere;
    }

    .dense-table .mud-table-pagination {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }
}

@media (max-width: 420px) {
    .topbar .mud-chip-root {
        display: none;
    }

    .topbar .mud-button-root .mud-button-label {
        font-size: 0;
        gap: 0;
    }

    .topbar .mud-button-root .mud-icon-root {
        margin: 0;
    }

    .command-strip,
    .page-band,
    .entity-header,
    .panel,
    .warehouse-card {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
        margin-left: -8px;
        margin-right: -8px;
    }

    .dense-table .mud-table-cell {
        grid-template-columns: 82px minmax(0, 1fr);
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
}
