:root {
    --bg: #050607;
    --bg-soft: #0b0d10;
    --panel: rgba(13, 16, 19, 0.95);
    --panel-alt: rgba(18, 22, 26, 0.92);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(170, 181, 168, 0.3);
    --text: #edf0ec;
    --muted: #8b948f;
    --accent: #97ab7d;
    --accent-soft: rgba(151, 171, 125, 0.18);
    --accent-strong: #c3d5a5;
    --danger: #d07878;
    --success: #86b980;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(96, 110, 82, 0.16), transparent 28%),
        radial-gradient(circle at bottom right, rgba(121, 85, 48, 0.12), transparent 24%),
        linear-gradient(135deg, #030405 0%, #050607 40%, #090b0d 100%);
    color: var(--text);
    font-family: 'Inter', sans-serif;
}

body {
    min-height: 100vh;
}

body.theme-light {
    --bg: #f3f5f7;
    --bg-soft: #e8edf2;
    --panel: rgba(255, 255, 255, 0.96);
    --panel-alt: rgba(248, 251, 255, 0.96);
    --line: rgba(16, 24, 32, 0.12);
    --line-strong: rgba(77, 95, 114, 0.3);
    --text: #11171e;
    --muted: #506071;
    --accent: #3f6a4f;
    --accent-soft: rgba(63, 106, 79, 0.14);
    --accent-strong: #2f5840;
    --danger: #b44d4d;
    --success: #3f7f51;
    --shadow: 0 18px 36px rgba(26, 35, 46, 0.12);
}

body.theme-light {
    background:
        radial-gradient(circle at top left, rgba(94, 130, 103, 0.12), transparent 32%),
        radial-gradient(circle at bottom right, rgba(94, 119, 160, 0.1), transparent 28%),
        linear-gradient(135deg, #eef3f8 0%, #f5f8fb 45%, #ecf2f7 100%);
}

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

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

.sidebar {
    display: flex;
    flex-direction: column;
    padding: 28px 22px;
    border-right: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(9, 11, 14, 0.98), rgba(4, 5, 7, 0.98));
    position: sticky;
    top: 0;
    align-self: start;
    min-height: 100vh;
    z-index: 120;
    overflow: visible;
}

.shell.sidebar-collapsed .sidebar {
    padding: 18px 10px;
    align-items: center;
}

.sidebar-footer-auth {
    margin-top: auto;
    padding-top: 14px;
}

.sidebar-logout-button {
    display: inline-flex;
}

body.theme-light .sidebar {
    background: linear-gradient(180deg, rgba(244, 248, 252, 0.98), rgba(235, 241, 247, 0.98));
}

.brand {
    display: grid;
    place-items: center;
    margin-bottom: 32px;
    width: 240px;
    height: 240px;
    padding: 14px;
    border: 0.5px solid var(--line);
    border-radius: 50%;
    background:
        linear-gradient(145deg, rgba(151, 171, 125, 0.12), rgba(255, 255, 255, 0.03)),
        rgba(7, 10, 12, 0.75);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.25);
}

.shell.sidebar-collapsed .brand {
    width: 58px;
    height: 58px;
    padding: 6px;
    margin-bottom: 12px;
    border-radius: 16px;
}

.shell.sidebar-collapsed .brand-logo {
    max-width: 44px;
}

body.theme-light .brand {
    background:
        linear-gradient(145deg, rgba(151, 171, 125, 0.14), rgba(255, 255, 255, 0.45)),
        rgba(255, 255, 255, 0.8);
}

.brand-logo {
    display: block;
    width: 100%;
    max-width: 210px;
    height: auto;
    margin: 0 auto;
    border-radius: 50%;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 1.7rem;
    letter-spacing: 0.08em;
    color: var(--accent-strong);
    background: linear-gradient(145deg, rgba(151, 171, 125, 0.14), rgba(255, 255, 255, 0.02));
}

.brand-eyebrow,
.kicker,
.hero-overline,
.panel-breadcrumb,
.sidebar-label {
    margin: 0;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
}

.brand h1,
.topbar h2,
.hero-card h3,
.panel-heading h3,
.orders-header h4,
.overview-card h3,
.empty-state h3 {
    margin: 0;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.topbar h2 {
    display: none;
}

.brand h1 {
    font-size: 2rem;
}

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
}

.shell.sidebar-collapsed .sidebar-profile {
    width: 100%;
    justify-content: center;
    padding: 8px 6px;
}

.shell.sidebar-collapsed .sidebar-profile-avatar {
    width: 34px;
    height: 34px;
}

.shell.sidebar-collapsed .sidebar-profile-meta {
    display: none;
}

.sidebar-profile-stack {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.sidebar-profile-chip {
    position: relative;
    display: inline-flex;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    overflow: hidden;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.sidebar-profile-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.28);
    border-color: rgba(173, 214, 255, 0.72);
}

.sidebar-profile-chip .sidebar-profile-avatar {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
}

.sidebar-profile-chip.is-active {
    border-color: rgba(108, 214, 137, 0.9);
    box-shadow: 0 0 0 2px rgba(108, 214, 137, 0.25), 0 10px 18px rgba(0, 0, 0, 0.28);
}

.sidebar-profile-chip.is-active::after {
    content: 'A';
    position: absolute;
    right: 3px;
    bottom: 3px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: 999px;
    background: #6cd689;
    color: #10261a;
    font-size: 9px;
    font-weight: 800;
    line-height: 14px;
    text-align: center;
}

.sidebar-account-menu {
    position: relative;
}

.sidebar-account-menu > summary {
    list-style: none;
}

.sidebar-account-menu > summary::-webkit-details-marker {
    display: none;
}

.sidebar-profile-chip-menu {
    display: grid;
    place-items: center;
    cursor: pointer;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.03));
}

.sidebar-profile-chip-menu-icon {
    font-size: 20px;
    line-height: 1;
    color: #f5f9ff;
    transform: translateY(-1px);
}

.sidebar-account-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 170px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(15, 20, 30, 0.98);
    box-shadow: 0 14px 26px rgba(0, 0, 0, 0.35);
    z-index: 5000;
}

.sidebar-account-switcher .sidebar-account-menu-panel {
    min-width: 240px;
}

.sidebar-profile-chip-switch {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    padding: 0;
    cursor: pointer;
}

.sidebar-profile-chip-switch .sidebar-profile-avatar {
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: 0;
}

.sidebar-profile-chip-switch-caret {
    position: absolute;
    right: 4px;
    bottom: 2px;
    min-width: 14px;
    height: 14px;
    border-radius: 999px;
    background: rgba(10, 18, 28, 0.82);
    color: #f2f7ff;
    font-size: 10px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
}

button.sidebar-account-entry,
button.sidebar-account-more-item {
    border: none;
    background: none;
    font: inherit;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.sidebar-account-entry {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 7px 8px;
    border-radius: 8px;
    color: #e7f0fb;
    text-decoration: none;
    white-space: nowrap;
}

.sidebar-account-entry img {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    object-fit: cover;
    flex: 0 0 28px;
}

.sidebar-account-entry span,
.sidebar-account-entry .sidebar-account-name {
    font-size: 0.89rem;
    font-weight: 600;
    color: inherit;
    display: inline-block;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.sidebar-account-entry small {
    margin-left: auto;
    color: #7ef0a8;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sidebar-account-entry:hover,
.sidebar-account-entry.is-active {
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-account-more-wrap {
    position: relative;
    margin-top: 4px;
}

.sidebar-account-more-trigger {
    width: 100%;
    min-height: 34px;
    border: 1px dashed rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    color: #d9e6fb;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.sidebar-account-more-trigger:hover {
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-account-more-grid {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 6000;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(12, 18, 28, 0.98);
    box-shadow: 0 14px 26px rgba(0, 0, 0, 0.35);
    grid-auto-flow: column;
    grid-template-rows: repeat(3, minmax(0, auto));
    gap: 6px;
    max-height: 320px;
}

.sidebar-account-more-wrap:hover .sidebar-account-more-grid,
.sidebar-account-more-wrap:focus-within .sidebar-account-more-grid {
    display: grid;
}

.sidebar-account-more-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 190px;
    padding: 6px 8px;
    border-radius: 8px;
    text-decoration: none;
    color: #e7f0fb;
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-account-more-item:hover,
.sidebar-account-more-item.is-active {
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-account-more-item img {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.28);
}

.sidebar-account-more-item span {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.84rem;
    font-weight: 600;
}

.sidebar-account-menu-divider {
    height: 1px;
    margin: 6px 2px;
    background: rgba(255, 255, 255, 0.15);
}

.sidebar-account-menu-panel a {
    display: block;
    padding: 8px 10px;
    color: #e7f0fb;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
}

.sidebar-account-menu-action {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    color: #e7f0fb;
    background: transparent;
    border: 0;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.9rem;
}

.sidebar-account-menu-action:hover,
.sidebar-account-menu-panel a:hover {
    background: rgba(255, 255, 255, 0.12);
}

body.theme-light .sidebar-profile {
    background: rgba(26, 41, 58, 0.03);
}

.sidebar-profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--line);
    object-fit: cover;
    flex: 0 0 auto;
}

.sidebar-profile-meta {
    min-width: 0;
}

.sidebar-profile-meta strong {
    display: block;
    font-size: 0.95rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-meta span {
    color: var(--muted);
    font-size: 0.78rem;
}

.menu {
    display: grid;
    gap: 8px;
    margin-bottom: 28px;
}

.shell.sidebar-collapsed .menu {
    width: 100%;
}

.menu-group-label {
    margin: 10px 10px 2px;
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    text-align: center;
    font-weight: 800;
}

.shell.sidebar-collapsed .menu-group-label {
    display: none;
}

.menu a,
.button-primary {
    transition: 180ms ease;
}

.button-icon {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    object-fit: contain;
}

.menu a {
    color: var(--muted);
    text-decoration: none;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.01);
    display: flex;
    align-items: center;
    font-weight: 600;
}

.shell.sidebar-collapsed .menu a {
    justify-content: center;
    padding: 10px 8px;
    font-size: 0;
    position: relative;
}

.menu a::before {
    content: none;
}

.shell.sidebar-collapsed .menu a::before {
    margin-right: 0;
}

.menu-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    justify-content: center;
    align-items: center;
    margin-right: 8px;
    flex: 0 0 18px;
}

.menu-icon svg {
    width: 18px;
    height: 18px;
    stroke: #a855f7;
    fill: none;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 4px rgba(168, 85, 247, 0.35));
}

.shell.sidebar-collapsed .menu-icon {
    margin-right: 0;
}

.shell.sidebar-collapsed .sidebar-profile-chip-switch {
    width: 52px;
    min-height: 52px;
    padding: 0;
}

.shell.sidebar-collapsed .sidebar-profile-chip-switch .sidebar-profile-avatar {
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: 0;
}

.shell.sidebar-collapsed .sidebar-account-menu {
    position: relative;
    z-index: 5001;
}

.shell.sidebar-collapsed .sidebar-account-menu-panel {
    left: calc(100% + 10px);
    top: 0;
}

.shell.sidebar-collapsed .sidebar-profile-active-summary,
.shell.sidebar-collapsed .sidebar-profile-chip-switch-caret {
    display: none;
}

.sidebar-profile-active-summary {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-self: center;
    gap: 2px;
    flex: 1 1 auto;
    padding-top: 1px;
}

.sidebar-profile-active-summary strong,
.sidebar-profile-active-summary small {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-profile-active-summary strong {
    font-size: 0.92rem;
    color: #f4f7ff;
    font-weight: 700;
}

.sidebar-profile-active-summary small {
    font-size: 0.74rem;
    color: #9fb2d7;
}

body.theme-light .menu a {
    background: rgba(26, 41, 58, 0.02);
}

.menu a:hover,
.menu a.active {
    color: var(--text);
    border-color: var(--line);
    background: linear-gradient(90deg, rgba(151, 171, 125, 0.16), transparent);
}

body.theme-light .menu a:hover,
body.theme-light .menu a.active {
    background: linear-gradient(90deg, rgba(63, 106, 79, 0.16), transparent);
}

.sidebar-card,
.overview-card,
.stat-card,
.hero-card,
.market-panel,
.history-panel,
.notice,
.empty-state {
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    border-radius: 22px;
}

.sidebar-card {
    padding: 16px;
    margin-bottom: 14px;
}

.sidebar-card strong,
.overview-card strong,
.stat-card strong {
    display: block;
    margin: 6px 0;
}

.sidebar-card span,
.panel-summary span,
.stat-card span,
.overview-card span,
.topbar-meta span,
.orders-header span {
    color: var(--muted);
    font-size: 0.9rem;
}

.sidebar-note {
    display: block;
    margin-top: 8px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.86rem;
}

.shell.sidebar-collapsed .sidebar-footer-auth {
    width: 100%;
    display: grid;
    place-items: center;
}

.shell.sidebar-collapsed .sidebar-logout-button {
    font-size: 0;
    padding: 9px;
}

.shell.sidebar-collapsed .sidebar-logout-button::before {
    content: '⎋';
    font-size: 18px;
}

.sidebar-toggle-btn {
    min-width: 42px;
    padding: 8px 10px;
    border-radius: 10px;
}

.sidebar-toggle-btn-left {
    align-self: flex-start;
    margin-right: 4px;
}

.stat-card .stat-note {
    display: block;
    margin-top: 4px;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.3;
}


.content {
    padding: 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
    margin-bottom: 24px;
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.topbar-meta .button-primary {
    padding: 8px 12px;
    border-radius: 10px;
}

.topbar h2 {
    font-size: clamp(2.4rem, 3vw, 3.4rem);
}

.notice {
    padding: 14px 18px;
    margin-bottom: 20px;
}

.notice.success {
    border-color: rgba(134, 185, 128, 0.36);
    background: rgba(36, 62, 38, 0.52);
}

.notice.error {
    border-color: rgba(208, 120, 120, 0.36);
    background: rgba(69, 31, 31, 0.5);
}

.hero-card {
    padding: 26px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 24px;
    background:
        linear-gradient(120deg, rgba(151, 171, 125, 0.08), transparent 45%),
        var(--panel);
}

.hero-card p:last-child,
.overview-card p,
.empty-state p {
    color: var(--muted);
    line-height: 1.6;
}

.button-primary {
    border: 1px solid rgba(151, 171, 125, 0.45);
    background: linear-gradient(135deg, rgba(151, 171, 125, 0.28), rgba(151, 171, 125, 0.1));
    color: var(--text);
    padding: 12px 18px;
    border-radius: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.button-primary:hover {
    transform: translateY(-1px);
    border-color: rgba(195, 213, 165, 0.8);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.button-primary.ghost {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.18);
    margin-left: 8px;
}

body.theme-light .button-primary.ghost {
    background: rgba(19, 33, 50, 0.03);
    border-color: rgba(30, 49, 70, 0.22);
}

.inline-button {
    margin-top: 10px;
}

.sec-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 8px;
    vertical-align: middle;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.sync-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.input-dark {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(8, 10, 12, 0.92);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 10px;
    min-width: 130px;
    font: inherit;
    font-size: 0.88rem;
}

body.theme-light .input-dark {
    border-color: rgba(31, 49, 68, 0.25);
    background: rgba(255, 255, 255, 0.95);
}

.input-dark:focus {
    outline: none;
    border-color: rgba(151, 171, 125, 0.8);
}

.check-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.84rem;
}

.autocomplete-wrap {
    position: relative;
    min-width: 280px;
}

.autocomplete-wrap .input-dark {
    width: 100%;
}

.autocomplete-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: rgba(7, 9, 11, 0.98);
    border: 1px solid rgba(151, 171, 125, 0.35);
    border-radius: 12px;
    padding: 4px;
    z-index: 35;
    max-height: 280px;
    overflow-y: auto;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
}

body.theme-light .autocomplete-list {
    background: rgba(255, 255, 255, 0.99);
    border-color: rgba(31, 49, 68, 0.22);
    box-shadow: 0 14px 26px rgba(21, 34, 50, 0.14);
}

.autocomplete-item {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.83rem;
    cursor: pointer;
}

.autocomplete-item:hover {
    background: rgba(151, 171, 125, 0.18);
}

body.theme-light .autocomplete-item:hover {
    background: rgba(63, 106, 79, 0.14);
}

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

.inline-crud-form {
    margin: 0;
}

.tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.tab-btn {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(7, 9, 11, 0.7);
    color: var(--muted);
    border-radius: 12px;
    padding: 9px 14px;
    cursor: pointer;
    font: inherit;
    font-size: 0.86rem;
    transition: 180ms ease;
}

body.theme-light .tab-btn {
    border-color: rgba(31, 49, 68, 0.22);
    background: rgba(248, 251, 255, 0.95);
}

.tab-btn:hover {
    color: var(--text);
    border-color: rgba(151, 171, 125, 0.5);
}

.tab-btn.active {
    color: var(--text);
    border-color: rgba(151, 171, 125, 0.8);
    background: linear-gradient(120deg, rgba(151, 171, 125, 0.22), rgba(151, 171, 125, 0.08));
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.form-label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    color: var(--muted);
    font-size: 0.84rem;
}

.full {
    width: 100%;
}

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

.stats-grid,
.overview-grid {
    display: grid;
    gap: 18px;
    margin-bottom: 24px;
}

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

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

.overview-card,
.stat-card {
    padding: 20px;
}

.overview-card.wide {
    grid-column: span 3;
    padding: 28px;
}

.stat-card strong {
    font-size: 2rem;
    font-family: 'Barlow Condensed', sans-serif;
    letter-spacing: 0.04em;
}

.market-panel,
.history-panel,
.empty-state {
    padding: 22px;
    margin-bottom: 24px;
}

.panel-heading,
.orders-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
    margin-bottom: 16px;
}

.panel-heading h3 {
    font-size: 2.6rem;
}

.item-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.item-icon {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(7, 9, 10, 0.8);
    object-fit: cover;
    flex: 0 0 auto;
}

.orders-block + .orders-block {
    margin-top: 22px;
}

.table-shell {
    overflow: auto;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(4, 5, 6, 0.75);
}

body.theme-light .table-shell {
    background: rgba(255, 255, 255, 0.92);
}

.table-shell.autocomplete-shell {
    overflow: visible;
}

.buyers-shell {
    background: rgba(4, 5, 6, 0.75);
}

body.theme-light .buyers-shell {
    background: rgba(255, 255, 255, 0.92);
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

.orders-table th,
.orders-table td {
    padding: 7px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: nowrap;
    font-size: 0.82rem;
    line-height: 1.15;
}

body.theme-light .orders-table th,
body.theme-light .orders-table td {
    border-bottom-color: rgba(21, 35, 51, 0.1);
}

.orders-table th {
    color: var(--muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.68rem;
    background: rgba(255, 255, 255, 0.02);
    position: sticky;
    top: 0;
}

body.theme-light .orders-table th {
    background: rgba(44, 61, 83, 0.06);
}

.orders-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

body.theme-light .orders-table tbody tr:hover {
    background: rgba(35, 54, 79, 0.045);
}

.buyers-table tbody tr {
    background: rgba(255, 255, 255, 0.02);
}

.buyers-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

body.theme-light .buyers-table tbody tr {
    background: rgba(44, 61, 83, 0.06);
}

body.theme-light .buyers-table tbody tr:nth-child(even) {
    background: rgba(35, 54, 79, 0.045);
}

.price {
    color: var(--accent-strong);
    font-weight: 600;
}

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

.final-materials-table .group-head th {
    font-size: 0.66rem;
    letter-spacing: 0.08em;
}

.final-materials-table .group-head .group-live,
.final-materials-table th:nth-child(3),
.final-materials-table th:nth-child(4),
.final-materials-table th:nth-child(5),
.final-materials-table td:nth-child(3),
.final-materials-table td:nth-child(4),
.final-materials-table td:nth-child(5),
.final-materials-table tfoot .col-live {
    background: rgba(151, 171, 125, 0.08);
}

.final-materials-table .group-head .group-init,
.final-materials-table th:nth-child(6),
.final-materials-table th:nth-child(7),
.final-materials-table th:nth-child(8),
.final-materials-table td:nth-child(6),
.final-materials-table td:nth-child(7),
.final-materials-table td:nth-child(8),
.final-materials-table tfoot .col-init {
    background: rgba(93, 121, 170, 0.09);
}

.final-materials-table th:nth-child(6),
.final-materials-table td:nth-child(6) {
    border-left: 2px solid rgba(255, 255, 255, 0.12);
}

body.theme-light .final-materials-table .group-head .group-live,
body.theme-light .final-materials-table th:nth-child(3),
body.theme-light .final-materials-table th:nth-child(4),
body.theme-light .final-materials-table th:nth-child(5),
body.theme-light .final-materials-table td:nth-child(3),
body.theme-light .final-materials-table td:nth-child(4),
body.theme-light .final-materials-table td:nth-child(5),
body.theme-light .final-materials-table tfoot .col-live {
    background: rgba(94, 136, 100, 0.12);
}

body.theme-light .final-materials-table .group-head .group-init,
body.theme-light .final-materials-table th:nth-child(6),
body.theme-light .final-materials-table th:nth-child(7),
body.theme-light .final-materials-table th:nth-child(8),
body.theme-light .final-materials-table td:nth-child(6),
body.theme-light .final-materials-table td:nth-child(7),
body.theme-light .final-materials-table td:nth-child(8),
body.theme-light .final-materials-table tfoot .col-init {
    background: rgba(91, 123, 168, 0.14);
}

body.theme-light .final-materials-table th:nth-child(6),
body.theme-light .final-materials-table td:nth-child(6) {
    border-left-color: rgba(31, 49, 68, 0.2);
}

.compact .orders-table {
    min-width: 720px;
}

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

.instance-editor-box {
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(9, 11, 13, 0.72);
}

.progress-shell {
    height: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(8, 10, 12, 0.9);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, rgba(151, 171, 125, 0.8), rgba(195, 213, 165, 0.9));
}

.tree-node {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(10, 12, 14, 0.78);
}

.tree-subhead {
    font-weight: 600;
}

.tree-subhead-bp {
    background: rgba(151, 171, 125, 0.08);
    color: var(--accent-strong);
}

.tree-subhead-raw {
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
}

.tree-children {
    margin-top: 8px;
    border-left: 2px solid rgba(151, 171, 125, 0.35);
    padding-left: 10px;
}

.status-icon {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-pending {
    color: #e1b663;
}

.status-in-progress {
    color: #7eb0f2;
}

.status-done {
    color: #8ad18f;
}

.status-blocked {
    color: #e19191;
}

.status-icon.status-pending {
    background: #e1b663;
}

.status-icon.status-in-progress {
    background: #7eb0f2;
}

.status-icon.status-done {
    background: #8ad18f;
}

.status-icon.status-blocked {
    background: #e19191;
}

body.theme-light .status-pending {
    color: #8a5b14;
}

body.theme-light .status-in-progress {
    color: #1f5fa9;
}

body.theme-light .status-done {
    color: #267d36;
}

body.theme-light .status-blocked {
    color: #a93333;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(5, 8, 12, 0.45);
    backdrop-filter: blur(6px);
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal-card {
    width: min(460px, 100%);
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 16px;
    display: grid;
    gap: 12px;
}

.modal-card h3 {
    margin: 0;
    font-family: 'Barlow Condensed', sans-serif;
    letter-spacing: 0.04em;
}

.modal-card p {
    margin: 0;
    color: var(--muted);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.tree-icon {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: rgba(6, 8, 10, 0.75);
    vertical-align: middle;
    margin-right: 6px;
}

body.theme-light .tree-icon {
    background: rgba(255, 255, 255, 0.92);
}

body.theme-light .instance-editor-box {
    border-color: rgba(31, 49, 68, 0.2);
    background: rgba(255, 255, 255, 0.88);
}

body.theme-light .progress-shell {
    border-color: rgba(31, 49, 68, 0.24);
    background: rgba(232, 240, 248, 0.95);
}

body.theme-light .progress-fill {
    background: linear-gradient(90deg, rgba(63, 106, 79, 0.75), rgba(92, 138, 108, 0.85));
}

body.theme-light .tree-node {
    border-color: rgba(31, 49, 68, 0.2);
    background: rgba(255, 255, 255, 0.9);
}

body.theme-light .tree-subhead-bp {
    background: rgba(63, 106, 79, 0.12);
}

body.theme-light .tree-subhead-raw {
    background: rgba(27, 45, 66, 0.05);
}

body.theme-light .tree-children {
    border-left-color: rgba(63, 106, 79, 0.4);
}

/* Execute BP - subtle premium grouping by BP blocks */
.bp-group-row td {
    background: color-mix(in srgb, var(--bp-accent, #6fb8ff) 11%, transparent);
    border-top: 1px solid color-mix(in srgb, var(--bp-accent, #6fb8ff) 34%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--bp-accent, #6fb8ff) 22%, transparent);
}

.bp-group-row td:first-child {
    border-left: 3px solid color-mix(in srgb, var(--bp-accent, #6fb8ff) 75%, #ffffff 25%);
}

.bp-group-row .bp-toggle {
    border-color: color-mix(in srgb, var(--bp-accent, #6fb8ff) 45%, rgba(255,255,255,0.25));
}

.bp-step-row td {
    background: color-mix(in srgb, var(--bp-accent, #6fb8ff) 4.5%, transparent);
}

.bp-step-row td:first-child {
    border-left: 2px solid color-mix(in srgb, var(--bp-accent, #6fb8ff) 48%, transparent);
}

.bp-step-row:hover td,
.bp-group-row:hover td {
    background: color-mix(in srgb, var(--bp-accent, #6fb8ff) 13%, transparent) !important;
}

body.theme-light .bp-group-row td {
    background: color-mix(in srgb, var(--bp-accent, #6fb8ff) 14%, #ffffff 86%);
    border-top-color: color-mix(in srgb, var(--bp-accent, #6fb8ff) 32%, rgba(31,49,68,0.2));
    border-bottom-color: color-mix(in srgb, var(--bp-accent, #6fb8ff) 24%, rgba(31,49,68,0.16));
}

body.theme-light .bp-step-row td {
    background: color-mix(in srgb, var(--bp-accent, #6fb8ff) 6%, #ffffff 94%);
}

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

    .sidebar {
        position: static;
        min-height: auto;
    }

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

    .overview-card.wide {
        grid-column: span 2;
    }

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

@media (max-width: 720px) {
    .content,
    .sidebar {
        padding: 18px;
    }

    .topbar,
    .hero-card,
    .panel-heading,
    .orders-header {
        flex-direction: column;
        align-items: stretch;
    }

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

    .overview-card.wide {
        grid-column: span 1;
    }

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

    .panel-heading h3 {
        font-size: 2rem;
    }
}

.public-home {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.public-home-card {
    width: min(520px, 100%);
    text-align: center;
    margin-inline: auto;
    border-radius: 22px;
    padding: 28px 24px;
    background: rgba(13, 20, 35, 0.75);
    border: 1px solid rgba(143, 201, 255, 0.18);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.28);
}

.public-home-logo {
    display: block;
    width: min(340px, 78vw);
    height: auto;
    margin: 0 auto 12px;
}

.public-home-card h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 2.8rem);
}

.public-home-card p {
    margin: 10px 0 0;
}

.public-home-alert {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 110, 110, 0.15);
    border: 1px solid rgba(255, 130, 130, 0.35);
}

body.theme-light .public-home-card {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(31, 49, 68, 0.18);
}

.public-home-actions {
    margin-top: 14px;
    display: flex;
    justify-content: center;
}

.wh-graph {
    width: 100%;
    min-height: 260px;
    overflow: hidden;
    border-radius: 14px;
    border: 1px solid var(--line);
    background:
      linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px) 0 0 / 24px 24px,
      linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px) 0 0 / 24px 24px,
      rgba(9, 14, 22, 0.8);
    user-select: none;
    cursor: grab;
}

.mapper-kpi-bar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    margin: 0 0 8px;
    border: 1px solid rgba(173, 195, 218, 0.35);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(30, 44, 61, 0.92), rgba(24, 36, 50, 0.92));
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(4px);
}

.mapper-kpi-item {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(173, 195, 218, 0.25);
}

.mapper-kpi-label {
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #b8cadf;
}

.mapper-kpi-item strong {
    font-size: 1.05rem;
    color: #f6fbff;
}
