/* Nexus SalesHub backoffice theme: Betesda-inspired whites, muted navy actions and restrained selection accents. */
:root {
    --primary: #123f73;
    --primary-hover: #0c315d;
    --primary-light: #eef3f8;
    --primary-glow: rgba(18, 63, 115, 0.16);
    --success: #128264;
    --success-light: #e5f5ef;
    --warning: #9a5a08;
    --warning-light: #fff2dc;
    --danger: #b42318;
    --danger-light: #fdecea;
    --info: #123f73;
    --info-light: #eef3f8;
    --bg: #eef4f7;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-hover: #f3f6f8;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --surface-soft: #f8fafc;
    --border: #d9e0e7;
    --border-light: #e9edf1;
    --border-strong: #b4c5dc;
    --text: #122033;
    --text-secondary: #475569;
    --text-muted: #5c6b7c;
    --sidebar-bg: #ffffff;
    --sidebar-text: #475569;
    --sidebar-text-active: #0c315d;
    --sidebar-hover: #f3f6f8;
    --sidebar-active-bg: #eef3f8;
    --sidebar-width: 236px;
    --sidebar-collapsed: 72px;
    --topbar-height: 58px;
    --radius: 7px;
    --radius-sm: 6px;
    --radius-xs: 5px;
    --shadow: 0 1px 2px rgba(18, 35, 61, 0.07), 0 8px 24px rgba(18, 35, 61, 0.05);
    --shadow-md: 0 1px 2px rgba(18, 35, 61, 0.08), 0 12px 30px rgba(18, 35, 61, 0.07);
    --shadow-lg: 0 2px 5px rgba(18, 35, 61, 0.1), 0 18px 48px rgba(18, 35, 61, 0.12);
    --accent: #123f73;
    --graphite: #24272c;
}

html {
    background: var(--bg);
}

body {
    min-width: 320px;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI Variable Text", "Aptos", "Segoe UI", Arial, sans-serif;
    font-feature-settings: "tnum" 1;
    font-size: 14px;
    line-height: 1.35;
    text-rendering: optimizeLegibility;
}

body,
button,
input,
select,
textarea,
h1,
h2,
h3,
h4,
h5,
h6,
.eyebrow,
[class*="kicker"],
[class*="label"] {
    letter-spacing: 0 !important;
}

::selection {
    background: var(--primary-light);
    color: var(--primary-hover);
}

* {
    scrollbar-color: #a9b7ca #eef2f6;
    scrollbar-width: thin;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: #eef2f6;
}

*::-webkit-scrollbar-thumb {
    border: 2px solid #eef2f6;
    border-radius: 5px;
    background: #a9b7ca;
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid #2f6ead;
    outline-offset: 2px;
}

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 100000;
    transform: translateY(-160%);
    border-radius: 5px;
    background: var(--primary-hover);
    color: #fff;
    padding: 0.55rem 0.8rem;
    font-weight: 700;
    text-decoration: none;
}

.skip-link:focus {
    transform: translateY(0);
}

/* Login */
.login-container {
    border-top: 4px solid var(--primary);
    background: var(--bg);
    padding: 1rem;
}

.login-card {
    width: min(390px, calc(100vw - 2rem));
    border-color: #bac7d8;
    padding: 1.45rem;
    box-shadow: var(--shadow-lg);
}

.login-brand {
    display: block;
    margin-bottom: 1.2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.login-logo {
    width: min(250px, 100%);
    height: auto;
    margin: 0 auto 0.65rem;
    border-radius: 0;
    box-shadow: none;
}

.login-brand h1 {
    align-self: end;
    color: var(--text);
    font-size: 1.18rem;
    font-weight: 750;
}

.login-brand p {
    align-self: start;
    margin-top: 0.05rem;
    color: var(--text-secondary);
    font-size: 0.76rem;
}

.login-card .form-group {
    margin-bottom: 0.9rem;
}

.login-card label,
.form-group label {
    color: #526078;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: none;
}

.login-card input {
    min-height: 40px;
    border-color: #c4cfdd;
    background: #fff;
    padding: 0.65rem 0.75rem;
}

.login-card input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.login-card .btn-full {
    min-height: 40px;
    margin-top: 0.2rem;
}

/* Application shell */
#dashboard-layout {
    background: var(--bg);
}

.sidebar {
    border-right-color: #c5cfdd;
    background: var(--sidebar-bg);
    box-shadow: inset -1px 0 #fff, 5px 0 20px rgba(20, 39, 68, 0.03);
}

.sidebar-brand {
    min-height: 62px;
    gap: 0.65rem;
    border-bottom-color: #cfd8e5;
    padding: 0.75rem;
}

.sidebar-brand-wordmark {
    width: 108px;
}

.sidebar-brand-mark {
    width: 34px;
    height: 34px;
}

.brand-copy {
    display: grid;
    min-width: 0;
    gap: 0.05rem;
}

.brand-text {
    color: var(--text);
    font-size: 0.94rem;
    font-weight: 750;
}

.brand-copy small {
    color: #68758a;
    font-size: 0.7rem;
    font-weight: 600;
}

.sidebar-section-label {
    color: #68758a;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.9rem 1.05rem 0.35rem;
}

.sidebar-nav {
    padding: 0 0.65rem;
}

.sidebar-groups {
    display: grid;
    gap: 0.18rem;
    padding-top: 0.2rem;
}

.sidebar-nav li,
.sidebar-groups li {
    position: relative;
    min-height: 38px;
    gap: 0.55rem;
    margin: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #39465d;
    padding: 0.45rem 0.6rem;
    font-size: 0.84rem;
    font-weight: 600;
}

.sidebar-nav li:hover {
    border-color: #d5deea;
    background: #eef3f9;
    color: var(--text);
}

.sidebar-nav li.active {
    border-color: #aebfd5;
    background: var(--sidebar-active-bg);
    color: var(--primary-hover);
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.75);
}

.sidebar-nav li.active::before {
    content: "";
    position: absolute;
    top: 5px;
    bottom: 5px;
    left: -1px;
    width: 3px;
    border-radius: 3px;
    background: var(--primary);
}

.sidebar-nav li i {
    width: 20px;
    color: #526078;
}

.sidebar-nav li.active i {
    color: var(--primary);
}

.sidebar-footer {
    border-top-color: #cfd8e5;
    padding: 0.75rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 7px;
    background: #31415c;
    box-shadow: 0 3px 10px rgba(22, 39, 67, 0.16);
}

.user-meta span:first-child {
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 700;
}

.user-role {
    color: #68758a;
}

.main-content {
    background: var(--bg);
}

.topbar {
    border-bottom-color: #cbd5e3;
    background: rgba(255, 255, 255, 0.97);
    padding: 0 1rem;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.topbar-left {
    gap: 0.7rem;
}

.topbar-heading {
    display: grid;
    gap: 0.03rem;
}

.topbar-heading > span {
    color: #738096;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
}

.topbar-left h1 {
    color: #17233a;
    font-size: 1rem;
    font-weight: 750;
}

.topbar-right {
    gap: 0.9rem;
}

.app-current-datetime {
    color: #526078;
    font-size: 0.72rem;
}

.sap-status {
    min-height: 30px;
    border: 1px solid #b8dcd8;
    border-radius: 16px;
    background: var(--success-light);
    color: #086c70;
    padding: 0.3rem 0.7rem;
}

.sap-status.error {
    border-color: #efc5c0;
}

.status-dot {
    width: 7px;
    height: 7px;
    animation: none;
}

.sidebar-toggle {
    width: 32px;
    height: 32px;
    border: 1px solid #c6d3e7;
    border-radius: 6px;
    background: #fff;
    color: #526078;
    padding: 0;
}

.sidebar-toggle:hover {
    border-color: #aebfd5;
    background: #edf3fb;
    color: var(--primary-hover);
}

.group-tabs {
    padding: 0.75rem 1rem 0;
}

.group-tabs-inner {
    gap: 0.2rem;
    border-color: #cbd5e3;
    border-radius: 7px;
    background: #dde4ed;
    padding: 0.25rem;
    box-shadow: 0 1px 2px rgba(18, 35, 61, 0.04);
}

.group-tab {
    min-height: 34px;
    border-radius: 5px;
    color: #526078;
    padding: 0.38rem 0.65rem;
    font-size: 0.79rem;
    font-weight: 700;
}

.group-tab:hover {
    background: rgba(255, 255, 255, 0.56);
    color: #17233a;
}

.group-tab.active {
    border-color: #b8c6d8;
    background: #fff;
    color: var(--primary-hover);
    box-shadow: 0 1px 3px rgba(18, 35, 61, 0.1);
}

.group-tab.active i {
    color: var(--primary);
}

.view-container,
.view-container:has(.otc-dashboard) {
    padding: 1rem 1.1rem 1.5rem;
}

/* Shared controls */
.btn {
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.45rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: none;
}

.btn-primary {
    border-color: var(--primary);
    background: var(--primary);
}

.btn-primary:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(18, 63, 115, 0.16);
}

.btn-ghost {
    border-color: #c6d3e2;
    background: #fff;
    color: #3f4d64;
}

.btn-ghost:hover {
    border-color: #9eafc4;
    background: #edf3f9;
    color: var(--primary-hover);
}

.btn-sm {
    min-height: 30px;
    padding: 0.3rem 0.58rem;
    font-size: 0.74rem;
}

.btn-icon {
    display: inline-flex;
    min-width: 32px;
    min-height: 32px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 6px;
}

.btn-icon:hover {
    border-color: #cad5e3;
    background: #edf3f9;
}

.btn-danger {
    border-color: #9f2118;
    background: var(--danger);
}

.btn-success {
    border-color: var(--primary);
    background: var(--primary);
}

.btn-success:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.btn-warning {
    border-color: #874b04;
    background: var(--warning);
}

button:disabled,
.btn:disabled,
[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.55;
    box-shadow: none !important;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="number"],
input[type="file"],
input[type="search"],
select,
textarea,
.form-control {
    min-height: 38px;
    border-color: #c4cfdd;
    border-radius: 6px;
    background-color: #fff;
    color: #17233a;
    padding: 0.52rem 0.7rem;
}

input:hover,
select:hover,
textarea:hover,
.form-control:hover {
    border-color: #aebdce;
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

input::placeholder,
textarea::placeholder {
    color: #8995a7;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--primary);
}

.card,
.dist-workbench,
.otc-hero,
.otc-metric,
.otc-stage,
.planning-card,
.monitor-card {
    border-color: #cbd5e3;
    border-radius: 7px;
    background: #fff;
    box-shadow: var(--shadow);
}

.card:hover {
    box-shadow: var(--shadow);
}

.hover-lift:hover {
    transform: none;
    box-shadow: var(--shadow-md);
}

.card-header {
    min-height: 50px;
    border-bottom-color: #dbe2ec;
    background: #f7f9fc;
    padding: 0.75rem 0.9rem;
}

.card-header h3 {
    color: #17233a;
    font-size: 0.9rem;
    font-weight: 750;
}

.card-header p {
    color: #68758a;
    font-size: 0.74rem;
}

.card-body,
.card-body.compact {
    padding: 0.9rem;
}

.kpi-grid,
.otc-metric-grid,
.dist-kpi-grid {
    gap: 0.65rem;
}

.kpi-card,
.otc-metric {
    min-height: 88px;
    border-top-width: 2px;
    padding: 0.72rem;
}

.kpi-icon,
.otc-icon,
.otc-stage-icon {
    border-radius: 6px;
}

.otc-dashboard,
.dist-shell {
    gap: 0.65rem;
}

.otc-hero {
    padding: 0.8rem 0.9rem;
}

.otc-hero h2,
.dist-page-header h2 {
    color: #17233a;
    font-size: 1.25rem;
    font-weight: 750;
}

.otc-kicker,
.dist-page-eyebrow {
    color: var(--accent);
    font-weight: 750;
}

.otc-business-date,
.dist-readonly-field {
    border-color: #cbd5e3;
    border-radius: 6px;
    background: #f6f8fb;
}

.otc-stage:hover {
    border-color: #8aa5c5;
    box-shadow: var(--shadow-md);
    transform: none;
}

/* Tables and dense workbenches */
.table-container,
.dist-orders-table-wrap {
    border-radius: 0 0 7px 7px;
}

table {
    font-variant-numeric: tabular-nums;
}

thead th,
.dist-table--planning th {
    border-bottom-color: #cbd5e3;
    background: #edf1f6;
    color: #526078;
    padding: 0.58rem 0.75rem;
    font-size: 0.68rem;
    font-weight: 750;
}

tbody td {
    border-bottom-color: #e3e8f0;
    padding: 0.62rem 0.75rem;
    font-size: 0.8rem;
}

tbody tr:nth-child(even) {
    background: rgba(246, 248, 251, 0.55);
}

tbody tr:hover,
.dist-click-row:hover {
    background: #edf3f9;
}

.dist-click-row.expanded,
tbody tr[aria-selected="true"] {
    background: var(--primary-light);
    box-shadow: inset 3px 0 var(--primary);
}

.item-master-table th,
.item-master-table td {
    padding-block: 0.58rem !important;
}

.item-master-table th:last-child,
.item-master-table td:last-child {
    min-width: 104px;
    text-align: right;
}

.item-master-table td:last-child > div {
    justify-content: flex-end;
}

/* Dense administration tables keep their actions visible without widening the page. */
.device-management-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.device-management-table th,
.device-management-table td {
    padding-inline: 0.7rem;
}

.device-management-table .device-model,
.device-management-table .device-id {
    max-width: 100%;
}

.device-management-table th:last-child,
.device-management-table td:last-child {
    text-align: right;
}

.device-management-table td:last-child .btn {
    max-width: 100%;
}

.payment-method-card {
    width: 100%;
    max-width: none !important;
}

.payment-method-table-wrap {
    position: relative;
    border-top: 1px solid var(--border);
    border-radius: 0 0 7px 7px;
    overflow-x: auto;
}

.payment-method-table-wrap:focus-visible {
    outline: 2px solid #2f6ead;
    outline-offset: -2px;
}

.payment-method-table {
    min-width: 1220px;
    table-layout: fixed;
}

.payment-method-table th:nth-child(1) { width: 170px; }
.payment-method-table th:nth-child(2) { width: 180px; }
.payment-method-table th:nth-child(3) { width: 92px; }
.payment-method-table th:nth-child(4) { width: 155px; }
.payment-method-table th:nth-child(5) { width: 125px; }
.payment-method-table th:nth-child(6) { width: 145px; }
.payment-method-table th:nth-child(7) { width: 175px; }
.payment-method-table th:nth-child(8) { width: 86px; }
.payment-method-table th:nth-child(9) { width: 82px; }

.payment-method-table input,
.payment-method-table select {
    min-width: 0;
    width: 100%;
}

.payment-method-table th:last-child,
.payment-method-table td:last-child {
    position: sticky;
    right: 0;
    z-index: 1;
    border-left: 1px solid var(--border);
    background: #fff;
    text-align: center;
    box-shadow: -8px 0 12px rgba(18, 35, 61, 0.05);
}

.payment-method-table thead th:last-child {
    z-index: 2;
    background: #edf1f6;
}

.payment-method-table tbody tr:nth-child(even) td:last-child {
    background: #f9fafc;
}

.payment-method-table tbody tr:hover td:last-child {
    background: #edf3f9;
}

.item-quick-filter-bar {
    border-bottom-color: #dbe2ec;
    background: #f6f8fb;
    padding: 0.65rem 1rem;
}

.item-quick-filter {
    border-radius: 15px;
}

/* Status and feedback */
.badge {
    min-height: 23px;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 0.16rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 700;
}

.badge-primary,
.badge-info {
    border-color: #bfd0e4;
}

.badge-success {
    border-color: #b8dcd8;
}

.badge-warning {
    border-color: #ead0a8;
}

.badge-danger {
    border-color: #efc5c0;
}

.badge-default {
    border-color: #d5dde8;
    background: #f0f3f7;
}

.alert,
.error-msg,
.dp-error-box {
    border-radius: 6px;
}

.alert-danger,
.dp-error-box {
    border-color: #efc5c0;
    background: #fff1ef;
    color: #8f1d14;
}

.loader,
.empty,
.dist-empty,
.otc-empty {
    color: #738096;
}

.toast {
    border: 1px solid #c5cfdd;
    border-left: 4px solid var(--primary);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
}

/* Modals */
.modal-overlay {
    background: rgba(15, 29, 51, 0.56);
    backdrop-filter: blur(2px);
}

.modal-card {
    border: 1px solid #b8c5d6;
    border-radius: 7px;
    box-shadow: var(--shadow-lg);
}

.modal-card {
    padding: 1.25rem;
}

/* Process-specific alignment */
.dist-flow {
    border-color: var(--graphite);
    border-radius: 7px;
    background: var(--graphite);
}

.dist-flow-step {
    border-radius: 5px;
}

.dist-flow-step.active {
    background: #fff;
    color: var(--graphite);
}

.dist-command-bar {
    border-color: #dbe2ec;
    background: #f6f8fb;
}

.dist-command-bar label,
.dist-detail-label,
.dp-meta-label {
    color: #68758a;
    font-weight: 750;
}

.dist-transfer-detail,
.dist-transfer-detail-row > td {
    background: #f6f8fb;
}

.dist-transfer-detail-grid > div,
.dist-detail-note,
.dist-transfer-detail-columns > div {
    border-color: #cbd5e3;
    border-radius: 6px;
}

/* Five-part operational summaries read as one process row on landscape screens. */
@media (min-width: 1181px) {
    #view-container[data-view="transfer-history"] .dist-kpi-grid,
    #view-container[data-view="dispatch-board"] .planning-kpi-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    }
}

.device-approval-guide {
    border-color: #c3d4f5;
    background: var(--primary-light);
    color: var(--primary-hover);
}

/* Responsive backoffice */
@media (min-width: 769px) {
    #dashboard-layout.sidebar-collapsed .sidebar-nav li.active::before {
        display: none;
    }
}

@media (max-width: 1280px) {
    .view-container,
    .view-container:has(.otc-dashboard) {
        padding-inline: 0.85rem;
    }

    .group-tabs {
        padding-inline: 0.85rem;
    }

    .topbar {
        padding-inline: 0.85rem;
    }

    .otc-main-grid {
        grid-template-columns: minmax(0, 1.45fr) minmax(310px, 0.75fr);
    }
}

@media (max-width: 1024px) {
    .otc-main-grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 768px) {
    .topbar-heading > span {
        display: none;
    }

    .group-tabs,
    .view-container,
    .view-container:has(.otc-dashboard) {
        padding-inline: 0.7rem;
    }
}

@media (max-width: 520px) {
    .otc-metric-grid,
    .otc-flow {
        grid-template-columns: 1fr;
    }

    .sap-status span:last-child {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
