:root {
    color-scheme: light;
    --ops-ink: #191a24;
    --ops-muted: #616578;
    --ops-border: #dedfe9;
    --ops-neutral-hover: #e5e6ef;
    --ops-canvas: #f0f1f6;
    --ops-surface: #fff;
    --ops-surface-soft: #f7f7fb;
    --ops-blue: #5045ba;
    --ops-blue-hover: #3d339b;
    --ops-blue-light: #eeecff;
    --ops-blue-border: #d4cffb;
    --ops-graph: #7869e6;
    --ops-graph-alt: #a6afeb;
    --ops-rail: #171824;
    --ops-rail-text: #d3d4e5;
    --ops-radius: 14px;
    --ops-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    --ops-shadow: 0 1px 2px #2525450a, 0 3px 10px #28254406;
}

*, *::before, *::after { box-sizing: border-box; }

body.workspace {
    margin: 0;
    min-height: 100vh;
    color: var(--ops-ink);
    background: radial-gradient(ellipse at 16% 0%, #e8e5f7 0%, transparent 40%), #e3e5ed;
    font: 14px/1.55 var(--ops-font);
}

.workspace :where(h1, h2, h3, h4, p, ul, ol, figure, dl, dd, fieldset) { margin: 0; }
.workspace :where(ul, ol) { padding: 0; }
.workspace :where(a) { color: var(--ops-blue); text-decoration: none; }
.workspace :where(a:hover) { color: var(--ops-blue-hover); }
.workspace :where(button, select, input, textarea) { font-family: inherit; }
.workspace :where(:focus-visible), .operations-login :where(:focus-visible) {
    outline: 2px solid var(--ops-blue);
    outline-offset: 3px;
}
.sidebar :focus-visible { outline-color: #b6adff; outline-offset: 2px; }

.app-shell {
    --rail-width: 218px;
    --frame-gutter: 0px;
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: var(--rail-width) minmax(0, 1fr);
    align-items: start;
    min-height: 100dvh;
    margin: 0;
    width: 100%;
    background: var(--ops-rail);
}

.sidebar {
    position: sticky;
    top: var(--frame-gutter);
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: calc(100dvh - var(--frame-gutter) * 2);
    padding: 26px 13px 16px;
    color: var(--ops-rail-text);
}

.workspace-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 3px 10px 24px;
    color: white;
    flex-shrink: 0;
}

.workspace-brand:hover { color: white; }

.brand-mark {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    border-radius: 10px;
    background: linear-gradient(145deg, #8581fa, #5141b8);
    box-shadow: inset 0 1px 0 #ffffff69, 0 3px 10px #3a2e8e34;
}
.brand-mark::before {
    content: "";
    width: 17px;
    height: 17px;
    background: #fff;
    clip-path: polygon(50% 0, 64% 36%, 100% 50%, 64% 64%, 50% 100%, 36% 64%, 0 50%, 36% 36%);
}

.workspace-brand strong { display: block; line-height: 1.3; font-size: 21px; font-weight: 700; }
.workspace-brand small { color: #a9acc0; font-size: 11px; }

.workspace-menu { overflow: auto; scrollbar-width: thin; scrollbar-color: #504f6b transparent; padding: 3px; }
.nav-item + .nav-item { margin-top: 3px; }
.nav-link, .sub-link, .workspace-nav-footer a {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 42px;
    padding: 8px 10px;
    border-radius: 9px;
    color: inherit;
    transition: background-color .15s, color .15s;
}
.nav-link {
    width: 100%;
    border: 0;
    background: transparent;
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.nav-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.nav-label { flex: 1; }
.nav-arrow { line-height: 1; font-size: 18px; transition: transform .16s; }
.nav-arrow.expanded { transform: rotate(90deg); }
.nav-link:hover, .sub-link:hover, .workspace-nav-footer a:hover { color: #fff; background: #ffffff11; }
.nav-link.active { color: #fff; background: #3a326a; box-shadow: inset 0 0 0 1px #b2a4ff26; }
.nav-link[aria-current="page"]::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #c4baff; margin-right: 4px; }
.sub-menu { display: none; list-style: none; margin: 3px 0 6px; padding: 0; }
.sub-menu.open { display: block; }
.sub-link { min-height: 35px; padding-left: 39px; font-size: 13px; color: #b9bbce; }
.sub-link.active { color: #ded7ff; background: #ffffff0d; }
.sub-dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .8; }
.workspace-nav-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid #ffffff18; }
.workspace-nav-footer a { font-size: 13px; padding-inline: 13px; }
.workspace-nav-footer .workspace-password { display: none; }

.main-wrapper {
    min-width: 0;
    min-height: inherit;
    display: flex;
    flex-direction: column;
    border-radius: 25px 0 0 25px;
    background: var(--ops-canvas);
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    gap: 14px;
    min-height: 70px;
    padding: 12px clamp(18px, 2.3vw, 34px);
    border-radius: 25px 0 0 0;
    border-bottom: 1px solid #dfe1eb;
    background: #f8f8fc;
    position: relative;
    z-index: 2;
}
.top-bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.workspace-home { color: var(--ops-muted); white-space: nowrap; }
.workspace-divider { color: #9699aa; }
.workspace-location { font-weight: 650; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.workspace-account {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 4px 5px 4px 13px;
    border: 1px solid var(--ops-border);
    border-radius: 28px;
    background: #fff;
    color: var(--ops-ink);
}
.workspace-account:hover { border-color: var(--ops-blue-border); color: var(--ops-blue); }
.workspace-account-text { display: grid; line-height: 1.2; max-width: 120px; min-width: 0; }
.workspace-account-text strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace-account-text small { color: var(--ops-muted); font-size: 10px; margin-top: 2px; }
.workspace-avatar {
    display: grid;
    place-items: center;
    height: 30px;
    width: 30px;
    flex: 0 0 30px;
    background: var(--ops-blue-light);
    border-radius: 50%;
    color: var(--ops-blue);
    font-size: 13px;
    font-weight: 700;
}
.hamburger-btn { display: none; }
.sidebar-overlay { display: none; }
.main-content { width: 100%; max-width: 1450px; margin: 0 auto; padding: clamp(18px, 2.3vw, 34px); flex: 1; min-width: 0; }
.xn-footer { padding: 10px 24px 19px; text-align: center; color: var(--ops-muted); font-size: 11px; }

@media (max-width: 1000px) {
    .app-shell { --rail-width: 184px; }
    .sidebar { padding-inline: 9px; }
}

@media (max-width: 768px) {
    body.workspace { background: var(--ops-canvas); }
    .app-shell { display: block; width: 100%; min-height: 100dvh; margin: 0; box-shadow: none; border-radius: 0; isolation: auto; }
    .main-wrapper, .top-bar { border-radius: 0; }
    .top-bar { min-height: 56px; padding: 8px 14px; border-radius: 0; position: sticky; top: 0; z-index: 1000; }
    .workspace-home, .workspace-divider, .workspace-account-text { display: none; }
    .workspace-account { padding: 3px; }
    .hamburger-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; color: var(--ops-ink); background: var(--ops-blue-light); border: 0; cursor: pointer; }
    .sidebar {
        position: fixed;
        z-index: 999;
        top: 57px;
        left: 0;
        width: min(270px, 84vw);
        height: calc(100dvh - 57px);
        padding: 16px 12px;
        background: var(--ops-rail);
        visibility: hidden;
        transform: translateX(-100%);
        transition: transform .2s, visibility .2s;
    }
    .sidebar.open { visibility: visible; transform: translateX(0); }
    .sidebar-overlay.show { display: block; position: fixed; inset: 57px 0 0; background: #17182488; z-index: 998; }
    .workspace-nav-footer .workspace-password { display: flex; }
    .main-content { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar, .nav-link, .sub-link, .nav-arrow { transition: none; }
}

@media print {
    body.workspace, .app-shell, .main-wrapper { background: #fff; border-radius: 0; }
    .app-shell { display: block; width: 100%; margin: 0; box-shadow: none; }
    .sidebar, .sidebar-overlay, .top-bar, .xn-footer { display: none !important; }
    .main-content { padding: 0; }
}

/* Shared surfaces used by record lists, detail views, reports, and dialogs. */
.workspace .main-content :is(.filter-card, .filter-section, .data-table-card, .detail-card, .form-card, .pi-card, .kpi-card) {
    border-radius: var(--ops-radius);
    box-shadow: var(--ops-shadow);
}

.workspace .main-content :is(.table-wrapper, .data-table-wrapper, .us-table-wrap, .pi-table-wrap) {
    max-width: 100%;
    border-radius: var(--ops-radius);
    border-color: var(--ops-border);
    scrollbar-color: #aea9cb var(--ops-surface-soft);
}

.workspace .main-content :is(.data-table, .pi-table, .us-table) {
    font-variant-numeric: tabular-nums;
}

.workspace .main-content :is(.data-table, .pi-table, .us-table) th {
    background: var(--ops-surface-soft);
    color: var(--ops-ink);
    border-bottom-color: var(--ops-border);
}

.workspace .main-content :is(.data-table, .pi-table, .us-table) td {
    border-color: var(--ops-border);
}

.workspace .main-content :is(.filter-header, .modal-header, .us-modal-head, .card-header) {
    border-bottom-color: var(--ops-border);
}

.workspace .main-content :is(.form-control, .form-select, .form-input, .pi-form-control, .us-field input, .cp-field input) {
    background: var(--ops-surface);
    border-color: var(--ops-border);
    color: var(--ops-ink);
}

.workspace .main-content :is(.form-control, .form-select, .form-input, .pi-form-control, .us-field input, .cp-field input):focus {
    border-color: var(--ops-blue);
    box-shadow: 0 0 0 3px var(--ops-blue-light);
}

.workspace .main-content :is(.btn-primary, .pi-btn-primary, .us-btn-primary, .cp-btn-primary):not(:disabled) {
    background: var(--ops-blue);
    border-color: var(--ops-blue);
    color: #fff;
}

.workspace .main-content :is(.btn-primary, .pi-btn-primary, .us-btn-primary, .cp-btn-primary):not(:disabled):hover {
    background: var(--ops-blue-hover);
    border-color: var(--ops-blue-hover);
    transform: none;
    box-shadow: none;
}

.workspace .main-content :is(.btn-secondary, .pi-btn-outline, .us-btn-ghost) {
    background: var(--ops-surface-soft);
    border-color: var(--ops-border);
    color: var(--ops-ink);
}

.workspace .main-content :is(.btn-secondary, .pi-btn-outline, .us-btn-ghost):hover {
    background: var(--ops-blue-light);
    color: var(--ops-blue);
}

.workspace .main-content :is(.btn, .pi-btn, .us-btn, .cp-btn, .page-link) {
    border-radius: 8px;
}

.workspace .main-content :is(.modal-box, .modal-card, .modal-content, .us-modal-card) {
    border-radius: 16px;
    box-shadow: 0 25px 70px #1d1b3f40;
}

.workspace .main-content :is(.modal-overlay, .us-modal) {
    background-color: #17182480;
}

.workspace .main-content .report-container .page-header { text-align: start; }
.workspace .main-content .report-container .summary-cards {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 186px), 1fr));
}
.workspace .main-content .report-container .summary-cards .card {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 8px 10px;
    align-content: start;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--ops-border);
    box-shadow: var(--ops-shadow);
    transform: none;
}

.workspace .main-content .report-container .summary-cards .card-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--ops-blue-light);
    color: var(--ops-blue);
}

.workspace .main-content .report-container .summary-cards .card-content { display: contents; }
.workspace .main-content .report-container .summary-cards .card-title { margin: 0; color: var(--ops-muted); }
.workspace .main-content .report-container .summary-cards :is(.card-value, .card-subtitle) { grid-column: 1 / -1; margin: 0; }
.workspace .main-content .report-container .summary-cards .card-value {
    font-size: clamp(18px, 1.65vw, 24px);
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.workspace .main-content .report-container .summary-cards .card-subtitle { color: var(--ops-muted); }
