:root {
    --bg: #0b1017;
    --bg-soft: #121a26;
    --panel: #182230;
    --panel-soft: #1f2b3c;
    --panel-strong: #243347;
    --border: rgba(128, 152, 181, 0.2);
    --border-strong: rgba(128, 152, 181, 0.36);
    --text: #ecf2f8;
    --muted: #95a5bb;
    --accent: #4cc38a;
    --accent-strong: #33a86f;
    --accent-soft: rgba(76, 195, 138, 0.16);
    --info: #52a8ff;
    --info-soft: rgba(82, 168, 255, 0.14);
    --warning: #f2b766;
    --danger: #ff7f7f;
    --success: #67d39b;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", "Noto Sans", sans-serif;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(82, 168, 255, 0.08), transparent 20%),
        radial-gradient(circle at top right, rgba(76, 195, 138, 0.08), transparent 18%),
        linear-gradient(180deg, #090d13 0%, #0c1219 100%);
}

.numeric-cell,
.totals-value,
.metric-value,
.running-balance,
.amount-debit,
.amount-credit {
    font-variant-numeric: tabular-nums;
    font-family: "Consolas", "SFMono-Regular", monospace;
}

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

button,
input,
select {
    font: inherit;
}

button {
    color: inherit;
}

.erp-shell {
    display: grid;
    grid-template-columns: 286px minmax(0, 1fr);
    min-height: 100vh;
}

.erp-shell.is-sidebar-collapsed {
    grid-template-columns: 92px minmax(0, 1fr);
}

.erp-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 18px 14px;
    border-right: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(11, 16, 23, 0.98), rgba(15, 21, 30, 0.98));
}

.sidebar-brand,
.sidebar-link,
.sidebar-footer,
.metric-card,
.panel,
.detail-panel,
.hero-bar {
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(24, 34, 48, 0.72);
}

.brand-mark,
.user-avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-weight: 700;
}

.brand-mark {
    background: linear-gradient(135deg, #4cc38a, #2c8f63);
    color: #04110c;
}

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

.brand-copy span,
.topbar-subtitle,
.hero-copy p,
.section-copy,
.metric-trend,
.sidebar-group-title,
.sidebar-link small,
.sidebar-footer p,
.user-meta span,
label,
.empty-state,
.empty-cell {
    color: var(--muted);
}

.sidebar-toggle {
    margin-left: auto;
}

.sidebar-scroll {
    display: grid;
    gap: 18px;
    margin-top: 18px;
    overflow: auto;
}

.sidebar-group {
    display: grid;
    gap: 8px;
}

.sidebar-group-title {
    padding: 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(20, 28, 39, 0.74);
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.sidebar-link:hover,
.sidebar-link.is-active {
    transform: translateX(2px);
    border-color: rgba(76, 195, 138, 0.34);
    background: rgba(32, 45, 60, 0.95);
}

.sidebar-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(76, 195, 138, 0.14);
    color: #9de2bf;
    font-size: 11px;
    font-weight: 700;
}

.sidebar-link-copy {
    display: grid;
    min-width: 0;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px;
    border-radius: 16px;
    background: rgba(24, 34, 48, 0.68);
}

.sidebar-footer-title {
    margin-bottom: 6px;
    font-weight: 600;
}

.erp-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.erp-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 16px;
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 12, 18, 0.9);
    backdrop-filter: blur(16px);
}

.topbar-left,
.topbar-actions,
.topbar-user,
.hero-badges,
.panel-header,
.toolbar,
.panel-toolbar,
.order-toolbar,
.document-grid,
.summary-item,
.detail-list div,
.tab-strip {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
}

.topbar-actions {
    justify-content: flex-end;
}

.topbar-user {
    padding-left: 16px;
    border-left: 1px solid var(--border);
}

.user-avatar {
    background: linear-gradient(135deg, #52a8ff, #2f73c8);
}

.user-meta {
    display: grid;
}

.erp-content {
    padding: 20px 22px 30px;
}

.hero-bar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 16px 18px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(27, 39, 54, 0.94), rgba(16, 24, 34, 0.94));
}

.hero-copy h1,
.panel-header h2 {
    margin: 0;
}

.hero-copy h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.hero-badges {
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: flex-end;
}

.hero-badge,
.tag,
.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(31, 43, 60, 0.88);
}

.hero-badge {
    background: rgba(82, 168, 255, 0.12);
    color: #b9d9ff;
}

.metric-grid,
.workspace-grid,
.double-grid,
.shortcut-grid,
.form-grid,
.split-layout {
    display: grid;
    gap: 16px;
    margin-bottom: 18px;
}

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

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

.workspace-grid,
.split-layout {
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.95fr);
}

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

.order-workspace,
.finance-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.9fr) 320px;
    gap: 16px;
}

.metric-card,
.panel,
.detail-panel {
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(24, 34, 48, 0.94), rgba(16, 23, 33, 0.96));
}

.metric-card {
    padding: 16px;
}

.metric-label {
    margin-bottom: 10px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.metric-trend {
    margin-top: 6px;
}

.panel,
.detail-panel {
    padding: 16px;
}

.panel-accent {
    background: linear-gradient(180deg, rgba(26, 40, 54, 0.98), rgba(16, 23, 33, 0.98));
}

.panel-soft {
    background: linear-gradient(180deg, rgba(29, 42, 58, 0.94), rgba(18, 28, 40, 0.96));
}

.panel-header {
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-toolbar {
    margin-bottom: 12px;
}

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

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

.shortcut-card {
    display: grid;
    gap: 6px;
    min-height: 100px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(31, 43, 60, 0.9);
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.shortcut-card:hover {
    transform: translateY(-2px);
    border-color: rgba(82, 168, 255, 0.36);
    background: rgba(38, 54, 75, 0.96);
}

.shortcut-card span {
    color: var(--muted);
}

.summary-stack {
    display: grid;
    gap: 12px;
}

.summary-item {
    justify-content: space-between;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(31, 43, 60, 0.72);
}

.tab-strip {
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.tab-button {
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(24, 34, 48, 0.85);
    cursor: pointer;
}

.tab-button.is-active {
    border-color: rgba(76, 195, 138, 0.36);
    background: rgba(76, 195, 138, 0.16);
    color: #bcf0d5;
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

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

.field-stack.grow {
    flex: 1 1 auto;
}

.field-stack-actions {
    align-self: end;
}

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

input,
select {
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: rgba(10, 16, 24, 0.9);
    color: var(--text);
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input::placeholder {
    color: #74869c;
}

input:focus,
select:focus {
    border-color: rgba(82, 168, 255, 0.6);
    box-shadow: 0 0 0 3px rgba(82, 168, 255, 0.12);
    background: rgba(7, 12, 18, 0.98);
}

.button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: rgba(31, 43, 60, 0.92);
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:hover,
.icon-button:hover {
    transform: translateY(-1px);
    border-color: rgba(82, 168, 255, 0.36);
}

.button-primary {
    background: linear-gradient(180deg, rgba(76, 195, 138, 0.32), rgba(44, 143, 99, 0.32));
    border-color: rgba(76, 195, 138, 0.38);
    color: #d9f8e7;
}

.button-secondary {
    background: rgba(31, 43, 60, 0.92);
}

.button-wide {
    min-width: 164px;
}

.icon-button {
    width: 36px;
    padding: 0;
}

.icon-button span,
.icon-button span::before,
.icon-button span::after {
    display: block;
    width: 14px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    content: "";
}

.icon-button span::before {
    transform: translateY(-5px);
}

.icon-button span::after {
    transform: translateY(3px);
}

.table-shell {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(10, 16, 24, 0.72);
    content-visibility: auto;
}

.table-shell-large {
    max-height: 62vh;
}

.data-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-grid th,
.data-grid td {
    padding: 8px 10px;
    border-right: 1px solid rgba(128, 152, 181, 0.16);
    border-bottom: 1px solid rgba(128, 152, 181, 0.16);
    white-space: nowrap;
}

.data-grid th:last-child,
.data-grid td:last-child {
    border-right: none;
}

.data-grid thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #172230;
    text-align: left;
    font-weight: 600;
    position: sticky;
}

.data-grid th {
    position: sticky;
}

.column-resizer {
    position: absolute;
    top: 0;
    right: -2px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
}

.data-grid tbody tr {
    transition: background 80ms ease;
}

.data-grid tbody td {
    background: rgba(11, 16, 23, 0.55);
}

.data-grid tbody tr:hover td,
.data-grid tbody tr.is-active td,
.data-grid tbody tr.is-selected td {
    background: rgba(82, 168, 255, 0.08);
}

.data-grid tbody td.is-active-cell,
.entry-grid td.is-active-cell {
    position: relative;
    background: rgba(76, 195, 138, 0.09);
    box-shadow: inset 0 0 0 1px rgba(76, 195, 138, 0.7);
}

.data-grid tbody tr.is-critical td {
    background: rgba(242, 183, 102, 0.05);
}

.entry-grid input {
    min-height: 30px;
    padding: 4px 6px;
    border-color: transparent;
    background: transparent;
    border-radius: 8px;
}

.entry-grid tr.is-active td {
    box-shadow: inset 0 0 0 999px rgba(76, 195, 138, 0.04);
}

.grid-footer-row td {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: #15202d;
    font-weight: 700;
}

.numeric-cell,
.w-numeric {
    text-align: right;
}

.w-code {
    width: 180px;
}

.w-unit {
    width: 110px;
}

.w-stock {
    width: 100px;
}

.w-numeric {
    width: 130px;
}

.order-toolbar,
.toolbar-spread {
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.customer-context-card,
.item-info-panel,
.summary-panel {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(25, 36, 50, 0.82);
}

.sticky-summary-panel {
    position: sticky;
    top: 100px;
    align-self: start;
}

.cell-info {
    color: #d7e2ee;
}

.totals-bar {
    min-width: 180px;
    padding: 10px 12px;
    border: 1px solid rgba(76, 195, 138, 0.24);
    border-radius: 12px;
    background: rgba(76, 195, 138, 0.1);
}

.totals-label {
    color: #b7ecd1;
}

.totals-value {
    font-size: 24px;
    font-weight: 700;
}

.autocomplete-shell {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 50;
    display: none;
    max-height: 260px;
    overflow: auto;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: #101822;
    box-shadow: var(--shadow);
}

.autocomplete-dropdown.is-open {
    display: block;
}

.autocomplete-option {
    display: grid;
    gap: 3px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(128, 152, 181, 0.12);
}

.autocomplete-option:last-child {
    border-bottom: none;
}

.autocomplete-option small {
    color: var(--muted);
}

.autocomplete-option mark {
    background: rgba(82, 168, 255, 0.2);
    color: #dcedff;
    padding: 0 2px;
    border-radius: 4px;
}

.muted-sep {
    color: #5c7088;
}

.autocomplete-option.is-active,
.autocomplete-option:hover {
    background: rgba(82, 168, 255, 0.12);
}

.loading-dot {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(82, 168, 255, 0.22);
    border-top-color: var(--info);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.detail-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.detail-list dt {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
}

.detail-list dd {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.detail-focus-card {
    min-height: 220px;
    padding: 18px;
    border: 1px dashed var(--border-strong);
    border-radius: 16px;
    background: rgba(20, 28, 39, 0.5);
}

.mini-grid-title {
    margin-top: 14px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.mini-grid {
    display: grid;
    gap: 8px;
}

.mini-grid-row {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr) 110px;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(18, 26, 38, 0.72);
}

.tag {
    min-height: 24px;
    padding: 0 8px;
    font-size: 12px;
}

.tag-success {
    background: rgba(76, 195, 138, 0.14);
    color: #bdebcf;
}

.tag-warning {
    background: rgba(242, 183, 102, 0.14);
    color: #ffdcae;
}

.tag-muted {
    background: rgba(128, 152, 181, 0.12);
    color: #c6d1de;
}

.amount-debit {
    color: #ff9f9f;
}

.amount-credit {
    color: #8ce5ae;
}

.running-balance {
    color: #d8e7f8;
}

.document-grid {
    flex-wrap: wrap;
    margin-top: 10px;
}

.command-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.sticky-column {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #121b27;
}

thead .sticky-column,
tfoot .sticky-column {
    z-index: 4;
    background: #172230;
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.alert-success {
    background: rgba(76, 195, 138, 0.12);
    border-color: rgba(76, 195, 138, 0.3);
    color: #d4f7e4;
}

.alert-error {
    background: rgba(255, 127, 127, 0.1);
    border-color: rgba(255, 127, 127, 0.3);
    color: #ffd6d6;
}

.empty-state,
.empty-cell {
    padding: 24px 12px;
    text-align: center;
}

.notification-root {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 100;
    display: grid;
    gap: 10px;
}

.notification {
    min-width: 280px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(18, 26, 38, 0.96);
    box-shadow: var(--shadow);
}

.notification.is-success {
    border-color: rgba(76, 195, 138, 0.32);
}

.notification.is-error {
    border-color: rgba(255, 127, 127, 0.32);
}

.global-loader {
    position: fixed;
    inset: auto 24px 24px auto;
    z-index: 110;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(12, 18, 26, 0.95);
    box-shadow: var(--shadow);
}

.loader-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(82, 168, 255, 0.2);
    border-top-color: var(--info);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.modal-root {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.55);
}

.modal-card {
    width: min(560px, calc(100vw - 32px));
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(17, 25, 35, 0.98);
    box-shadow: var(--shadow);
}

.desktop-only {
    display: inline-flex;
}

.mobile-only {
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1240px) {
    .metric-grid,
    .metric-grid-compact,
    .shortcut-grid-dashboard,
    .form-grid,
    .order-workspace,
    .finance-layout {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .workspace-grid,
    .split-layout,
    .double-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 920px) {
    .erp-shell {
        grid-template-columns: 1fr;
    }

    .erp-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 70;
        width: 286px;
        transform: translateX(-100%);
        transition: transform 160ms ease;
    }

    .erp-shell.is-sidebar-open .erp-sidebar {
        transform: translateX(0);
    }

    .erp-topbar {
        grid-template-columns: minmax(0, 1fr);
    }

    .topbar-actions,
    .topbar-user,
    .hero-bar,
    .toolbar,
    .order-toolbar {
        flex-wrap: wrap;
    }

    .mobile-only {
        display: inline-flex;
    }

    .desktop-only {
        display: none;
    }
}

@media (max-width: 640px) {
    .erp-content,
    .erp-topbar {
        padding-left: 14px;
        padding-right: 14px;
    }

    .metric-grid,
    .metric-grid-compact,
    .shortcut-grid,
    .shortcut-grid-dashboard,
    .form-grid,
    .order-workspace,
    .finance-layout {
        grid-template-columns: 1fr;
    }

    .button,
    .button-wide,
    .field-stack-actions .button {
        width: 100%;
    }
}
