:root {
    --bg: #ffffff;
    --panel: #ffffff;
    --ink: #17181a;
    --muted: #6b7280;
    --line: #e5e5e8;
    --blue: #111111;
    --blue-dark: #000000;
    --orange: #111111;
    --green: #16a34a;
    --red: #dc2626;
    --yellow: #d97706;
    --shadow: 0 8px 24px rgba(17, 17, 17, .06);
    --soft-bg: #f6f6f7;
    --tint-neutral: #f0f0f2;
    --tint-success: #ecfdf3;
    --tint-warning: #fef3e2;
    --tint-danger: #fef2f2;
    --text-2: #374151;
    --text-3: #4b5563;
    --text-faint: #9ca3af;
    --text-success: #15803d;
    --text-warning: #92400e;
    --text-danger: #b91c1c;
    --radius-lg: 14px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--ink);
    background: var(--bg);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.wrap {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 0 24px;
}

.topbar {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-inner {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.app-body {
    display: flex;
    align-items: flex-start;
}

.side-nav {
    width: 220px;
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 22px 14px;
    position: sticky;
    top: 64px;
    align-self: flex-start;
    min-height: calc(100vh - 64px);
}

.side-nav-title {
    padding: 0 10px 12px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.side-nav-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.side-nav-link {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-sm, 8px);
    color: var(--text-2);
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background .15s ease, color .15s ease;
}

.side-nav-link.active,
.side-nav-link:hover {
    color: #ffffff;
    background: var(--blue);
}

.app-content {
    flex: 1;
    min-width: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 260px;
}

.brand-mark {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: linear-gradient(135deg, var(--orange), var(--blue-dark));
    font-weight: 800;
    font-size: 13px;
    letter-spacing: .02em;
    border-radius: 10px;
}

.brand-title {
    font-size: 21px;
    font-weight: 800;
}

.brand-subtitle {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 2px;
    overflow-x: auto;
}

.nav a {
    color: var(--text-2);
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 8px;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease;
}

.nav a.active,
.nav a:hover {
    color: #ffffff;
    background: var(--blue);
}

.identity {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    white-space: nowrap;
}

.status-dot {
    width: 9px;
    height: 9px;
    display: inline-block;
    border-radius: 50%;
    background: var(--muted);
}

.status-dot.ok { background: var(--green); }
.status-dot.warn { background: var(--yellow); }
.status-dot.danger { background: var(--red); }

.workspace {
    padding: 22px 0 40px;
}

.command-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 16px;
    margin-bottom: 16px;
}

.search-panel,
.usage-panel,
.signal-card,
.side-panel,
.main-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.search-panel {
    padding: 16px;
    border-radius: 8px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.tabs button {
    border: 1px solid var(--line);
    background: var(--soft-bg);
    color: var(--text-2);
    padding: 7px 12px;
    border-radius: 5px;
}

.tabs button.active {
    color: #ffffff;
    border-color: var(--orange);
    background: var(--orange);
}

.search-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 120px 120px;
    gap: 10px;
}

.search-row input,
.search-row select,
.inline-filter input,
.inline-filter select,
.email-add-row input,
.table-tools select,
.full-control {
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 0 12px;
    background: var(--panel);
}

.inline-filter,
.email-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-filter input {
    width: 230px;
}

.email-panel {
    margin-top: 16px;
}

.search-results-panel {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    overflow-x: auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
}

.search-results-panel .table-head {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
}

.search-results-panel .table-head h1 {
    font-size: 16px;
    margin: 0 0 3px;
}

.search-results-panel .table-head p {
    margin: 0;
    font-size: 13px;
}

.search-result-row {
    min-width: 1120px;
    display: grid;
    grid-template-columns: 230px 110px 90px 110px 150px 80px 135px 130px 120px;
    gap: 8px;
    align-items: center;
    min-height: 60px;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
}

.search-results-panel.no-frequency .search-result-row {
    min-width: 980px;
    grid-template-columns: 250px 110px 100px 120px 170px 90px 150px 130px;
}

.search-results-panel.no-frequency .frequency-col {
    display: none;
}

.search-results-panel:not(.has-distributor) .search-result-row {
    grid-template-columns: 250px 100px 120px 170px 90px 150px 130px 120px;
}

.search-results-panel:not(.has-distributor).no-frequency .search-result-row {
    grid-template-columns: 250px 100px 120px 170px 90px 150px 130px;
}

.search-results-panel:not(.has-distributor) .distributor-col {
    display: none;
}

.search-results-panel:not(.has-limit).has-distributor .search-result-row {
    grid-template-columns: 250px 130px 100px 170px 90px 150px 130px 120px;
}

.search-results-panel:not(.has-limit).has-distributor.no-frequency .search-result-row {
    grid-template-columns: 250px 130px 100px 170px 90px 150px 130px;
}

.search-results-panel:not(.has-limit):not(.has-distributor) .search-result-row {
    grid-template-columns: 270px 100px 180px 90px 150px 130px 120px;
}

.search-results-panel:not(.has-limit):not(.has-distributor).no-frequency .search-result-row {
    grid-template-columns: 270px 100px 180px 90px 150px 130px;
}

.search-results-panel:not(.has-limit) .limit-col {
    display: none;
}

.search-result-row:not(.search-result-header) {
    background: var(--panel);
}

.search-result-row:not(.search-result-header):hover {
    background: var(--soft-bg);
}

.search-result-header {
    min-height: 42px;
    background: var(--soft-bg);
    color: var(--muted);
    font-weight: 700;
}

.search-result-row b,
.search-result-row small {
    display: block;
}

.search-result-row small {
    margin-top: 4px;
    color: var(--muted);
}

.auth-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin-top: 6px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--tint-success);
    color: var(--text-success);
    font-size: 12px;
    font-style: normal;
    font-weight: 800;
}

.search-result-row .auth-sources {
    color: var(--text-3);
    font-size: 12px;
    line-height: 1.45;
}

.search-result-row input,
.search-result-row select {
    width: 100%;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 10px;
    background: var(--soft-bg);
    color: var(--ink);
    font-weight: 650;
    outline: none;
}

.search-result-row input:focus,
.search-result-row select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(17, 17, 17, .12);
    background: var(--panel);
}

.search-result-row .primary-btn {
    width: 100%;
    min-height: 36px;
}

.search-price small {
    margin-top: 3px;
}

.result-json {
    grid-column: 1 / -1;
    margin: 0 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--soft-bg);
}

.result-json summary {
    cursor: pointer;
    padding: 9px 12px;
    color: var(--blue);
    font-weight: 750;
}

.result-json pre {
    max-height: 320px;
    overflow: auto;
    margin: 0;
    padding: 12px;
    border-top: 1px solid var(--line);
    color: var(--ink);
    background: var(--panel);
    font-size: 12px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.limit-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 5px;
    background: var(--tint-warning);
    color: var(--yellow);
    font-style: normal;
    font-weight: 700;
    white-space: nowrap;
}

.price-cell {
    display: inline-grid;
    grid-template-columns: auto auto;
    align-items: center;
    gap: 3px 6px;
    min-width: 96px;
    max-width: 150px;
    line-height: 1.15;
}

.price-cell b {
    color: var(--ink);
    font-size: 15px;
    line-height: 1.1;
    white-space: nowrap;
}

.price-cell em {
    display: inline-flex;
    align-items: center;
    min-height: 21px;
    padding: 0 6px;
    border-radius: 4px;
    background: var(--tint-neutral);
    color: var(--blue);
    font-size: 12px;
    font-style: normal;
    white-space: nowrap;
}

.price-cell i {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 0 6px;
    border-radius: 4px;
    background: var(--tint-warning);
    color: var(--yellow);
    font-size: 12px;
    font-style: normal;
    white-space: nowrap;
}

.price-cell small {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
}

.price-cell.empty {
    color: var(--muted);
}

.time-cell b,
.time-cell small {
    display: block;
}

.time-cell b {
    color: var(--ink);
    font-size: 13px;
    font-weight: 750;
    line-height: 1.25;
}

.time-cell small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
}

.api-panel {
    margin-top: 16px;
}

.collapsible-head {
    cursor: pointer;
}

.collapse-toggle {
    min-width: 72px;
}

.collapsible-body {
    border-top: 1px solid var(--line);
}

.collapsible-panel.is-collapsed .table-head {
    border-bottom: 0;
}

.panel-foot-link {
    padding: 0 18px 18px;
}

.panel-foot-link a {
    color: var(--blue);
    text-decoration: none;
    font-weight: 700;
}

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

.api-settings-link {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.api-mini-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border-top: 1px solid var(--line);
}

.api-mini-grid div {
    padding: 14px 18px;
    border-right: 1px solid var(--line);
}

.api-mini-grid div:last-child {
    border-right: 0;
}

.api-mini-grid span,
.api-mini-grid b {
    display: block;
}

.api-mini-grid span {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
}

.api-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 18px;
}

.api-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 16px;
}

.api-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.api-card h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.api-card small {
    color: var(--muted);
}

.api-card-fields {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.api-card-fields label span,
.api-card-fields label em {
    display: block;
}

.api-card-fields label span {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 13px;
}

.api-card-fields label em {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}

.api-card-fields input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 0 10px;
}

.email-add-row {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--soft-bg);
}

.email-add-row input[type="email"] {
    width: min(360px, 38vw);
}

.email-add-row input[type="text"] {
    width: 180px;
}

.primary-btn,
.soft-btn,
.ghost-btn,
.danger-btn,
.full-btn,
.mini-btn,
.icon-btn {
    border: 0;
    border-radius: 5px;
    min-height: 36px;
    padding: 0 14px;
    transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease, background .12s ease;
}

.primary-btn:hover,
.soft-btn:hover,
.danger-btn:hover,
.full-btn:hover,
.mini-btn:hover {
    box-shadow: 0 4px 12px rgba(17, 17, 17, .12);
}

.primary-btn:active,
.soft-btn:active,
.ghost-btn:active,
.danger-btn:active,
.full-btn:active,
.mini-btn:active,
.icon-btn:active {
    transform: scale(.97);
    box-shadow: none;
}

.primary-btn {
    background: var(--orange);
    color: #ffffff;
    font-weight: 700;
}

.soft-btn {
    background: var(--tint-neutral);
    color: var(--blue);
    font-weight: 700;
}

.ghost-btn {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.danger-btn {
    background: var(--tint-danger);
    color: var(--red);
}

.usage-panel {
    padding: 15px;
    border-radius: 8px;
}

.usage-title {
    font-weight: 800;
    margin-bottom: 12px;
}

.usage-line {
    display: grid;
    grid-template-columns: 74px 1fr auto;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
    font-size: 13px;
}

meter {
    width: 100%;
    height: 10px;
}

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

.signal-card {
    text-align: left;
    padding: 15px;
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease;
}

.signal-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(17, 17, 17, .10);
}

.signal-card.active {
    border: 2px solid var(--ink);
}

.signal-card strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
    color: var(--orange);
}

.signal-card small,
.signal-label {
    color: var(--muted);
}

.monitor-section {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
}

.monitor-section:not(.has-rule-panel) {
    grid-template-columns: minmax(0, 1fr);
}

.side-panel,
.main-panel {
    border-radius: 8px;
}

.side-panel {
    padding: 16px;
}

.panel-title {
    font-weight: 800;
    margin-bottom: 12px;
}

.panel-title.compact {
    margin-top: 24px;
}

.health-list {
    display: grid;
    gap: 10px;
}

.health-list div {
    display: grid;
    grid-template-columns: 14px 1fr;
    gap: 4px 8px;
    padding: 10px;
    background: var(--soft-bg);
    border-radius: 6px;
}

.health-list small {
    grid-column: 2;
    color: var(--muted);
}

.field-label {
    display: block;
    margin: 10px 0 6px;
    color: var(--muted);
    font-size: 13px;
}

.full-control,
.full-btn {
    width: 100%;
}

.switch-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 12px 0;
    color: var(--text-2);
}

.full-btn {
    margin-top: 8px;
    background: var(--blue);
    color: #ffffff;
}

.rule-box {
    margin: 14px 0 4px;
    padding: 12px;
    border: 1px solid var(--soft-bg);
    background: var(--soft-bg);
    border-radius: 6px;
}

.rule-title {
    margin-bottom: 8px;
    font-weight: 800;
    color: var(--blue-dark);
}

.limit-row {
    display: grid;
    grid-template-columns: 1fr 72px;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
}

.limit-row input {
    width: 72px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 0 8px;
}

.main-panel {
    overflow: hidden;
}

.table-head {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
}

.table-head h1 {
    margin: 0;
    font-size: 20px;
}

.table-head p {
    margin: 5px 0 0;
    color: var(--muted);
}

.table-tools {
    display: flex;
    gap: 8px;
}

.ti-auto-order-selecting .monitor-table .monitor-row span:first-child,
.ti-auto-order-selecting .monitor-table .table-header span:first-child {
    background: #eff6ff;
    border-radius: 6px;
}

.ti-auto-order-selecting .monitor-table .monitor-row {
    background: linear-gradient(90deg, rgba(239,246,255,.82), transparent 18%);
}

.monitor-table {
    overflow-x: auto;
}

.empty-state {
    padding: 28px;
    color: var(--muted);
    text-align: center;
    border-bottom: 1px solid var(--line);
}

.empty-note {
    padding: 10px;
    color: var(--muted);
    background: var(--soft-bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    line-height: 1.5;
}

.table-row {
    min-width: 1160px;
    display: grid;
    grid-template-columns: 42px 220px 105px 86px 86px 105px 150px 112px 116px 82px 130px;
    align-items: center;
    min-height: 62px;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
    gap: 8px;
    transition: background .12s ease;
}

.monitor-table.no-order-limit .table-row {
    min-width: 1060px;
    grid-template-columns: 42px 240px 105px 92px 92px 160px 132px 122px 82px 130px;
}

.monitor-table.no-platform .table-row {
    min-width: 1060px;
    grid-template-columns: 42px 250px 92px 92px 105px 160px 132px 122px 82px 130px;
}

.monitor-table.no-platform.no-order-limit .table-row {
    min-width: 960px;
    grid-template-columns: 42px 260px 96px 96px 170px 136px 124px 82px 130px;
}

.monitor-table.no-schedule .table-row {
    min-width: 1060px;
    grid-template-columns: 42px 220px 105px 86px 86px 105px 150px 132px 82px 130px;
}

.monitor-table.no-order-limit.no-schedule .table-row {
    min-width: 960px;
    grid-template-columns: 42px 240px 105px 92px 92px 170px 142px 82px 130px;
}

.monitor-table.no-platform.no-schedule .table-row {
    min-width: 960px;
    grid-template-columns: 42px 270px 96px 96px 120px 170px 142px 82px 130px;
}

.monitor-table.no-platform.no-order-limit.no-schedule .table-row {
    min-width: 860px;
    grid-template-columns: 42px 280px 100px 100px 190px 150px 82px 130px;
}

.email-row {
    min-width: 1320px;
    display: grid;
    grid-template-columns: 240px 120px 90px repeat(7, 105px) 160px;
    align-items: center;
    min-height: 58px;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
    gap: 8px;
}

.single-email-platform .email-row {
    min-width: 720px;
    grid-template-columns: 260px 140px 110px 120px 160px;
}

.email-header {
    min-height: 42px;
    background: var(--soft-bg);
    color: var(--muted);
    font-weight: 700;
}

.email-row b,
.email-row small {
    display: block;
}

.email-row small {
    margin-top: 4px;
    color: var(--muted);
}

.mini-danger {
    min-height: 30px;
    padding: 0 10px;
    font-size: 12px;
}

.table-header {
    min-height: 42px;
    background: var(--soft-bg);
    color: var(--muted);
    font-weight: 700;
}

.sortable-head {
    cursor: pointer;
    user-select: none;
}

.sortable-head::after {
    content: "↕";
    margin-left: 4px;
    color: var(--text-faint);
    font-size: 11px;
}

.sortable-head[data-dir="desc"]::after {
    content: "↓";
    color: var(--blue);
}

.sortable-head[data-dir="asc"]::after {
    content: "↑";
    color: var(--blue);
}

.monitor-row:nth-child(odd) {
    background: var(--soft-bg);
}

.monitor-row:hover {
    background: var(--soft-bg);
}

.monitor-row.saved-row {
    background: var(--tint-success);
}

.monitor-row b,
.monitor-row small {
    display: block;
}

.monitor-row small {
    margin-top: 4px;
    color: var(--muted);
}

.vendor,
.pill,
.mail {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 0 8px;
    border-radius: 4px;
    font-style: normal;
    font-size: 12px;
}

.vendor.ti { color: var(--blue-dark); background: var(--tint-neutral); }
.vendor.dk { color: var(--text-warning); background: var(--tint-warning); }
.vendor.tp { color: var(--text-success); background: var(--tint-success); }
.vendor.op { color: var(--text-2); background: var(--bg); }

.stock {
    font-weight: 800;
}

.stock.up { color: var(--green); }
.stock.zero { color: var(--red); }
.stock.warn { color: var(--red); }

.limit {
    color: var(--green);
    font-weight: 700;
}

.limit.strong {
    color: var(--red);
}

.pill.normal { background: var(--tint-neutral); color: var(--blue); }
.pill.urgent { background: var(--tint-danger); color: var(--red); }
.pill.low { background: var(--bg); color: var(--muted); }
.pill.limited { background: var(--tint-warning); color: var(--yellow); }

.mail.on { background: var(--tint-success); color: var(--green); }
.mail.off { background: var(--bg); color: var(--muted); }

.mini-btn {
    color: var(--blue);
    background: var(--tint-neutral);
}

.monitor-row > span:last-child {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
}

.mini-danger {
    min-height: 30px;
    padding: 0 10px;
    background: var(--tint-danger);
    color: var(--red);
    white-space: nowrap;
}

.monitor-row .mini-btn,
.monitor-row .mini-danger {
    min-width: 52px;
    height: 30px;
    line-height: 30px;
    padding: 0 10px;
    font-size: 12px;
    text-align: center;
    white-space: nowrap;
}

.history-chip {
    min-height: 26px;
    min-width: 46px;
    border: 0;
    border-radius: 5px;
    color: var(--text-2);
    background: var(--soft-bg);
    font-weight: 700;
}

.history-chip:hover {
    color: var(--blue);
    background: var(--tint-neutral);
}

.editable-chip {
    border: 0;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .12s ease, box-shadow .12s ease;
}

.editable-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(17, 17, 17, .12);
}

.editable-chip.limit {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 0 8px;
    border-radius: 4px;
    background: var(--tint-success);
    color: var(--green);
    font-size: 13px;
    font-weight: 800;
}

.readonly-chip.limit {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 0 8px;
    border-radius: 4px;
    background: var(--tint-success);
    color: var(--green);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.readonly-chip.limit.strong {
    background: var(--tint-danger);
    color: var(--red);
}

.editable-chip.limit.strong {
    background: var(--tint-danger);
    color: var(--red);
}

.edit-popover {
    position: fixed;
    z-index: 90;
    display: none;
    min-width: 190px;
    max-width: min(260px, calc(100vw - 24px));
    padding: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 36px rgba(17, 17, 17, .18);
}

.edit-popover.open {
    display: grid;
    gap: 6px;
}

.edit-popover button {
    min-height: 32px;
    border: 0;
    border-radius: 5px;
    background: var(--bg);
    color: var(--ink);
    text-align: left;
    padding: 0 10px;
}

.edit-popover button:hover {
    background: var(--tint-neutral);
    color: var(--blue);
}

.popover-input-row {
    display: grid;
    grid-template-columns: 1fr 54px;
    gap: 6px;
}

.popover-input-row input {
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 0 8px;
}

.popover-input-row button {
    text-align: center;
    background: var(--blue);
    color: #ffffff;
}

.detail-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(430px, 92vw);
    height: 100vh;
    background: var(--panel);
    border-left: 1px solid var(--line);
    box-shadow: -20px 0 50px rgba(17, 17, 17, .16);
    transform: translateX(105%);
    transition: transform .22s ease;
    z-index: 20;
}

.detail-drawer.open {
    transform: translateX(0);
}

.history-modal {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(17, 17, 17, .36);
}

.history-modal.open {
    display: flex;
}

.today-release-modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, .42);
}

.today-release-modal.open {
    display: flex;
}

.today-release-card {
    width: min(680px, 96vw);
    max-height: min(720px, 90vh);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 28px 90px rgba(15, 23, 42, .28);
}

.today-release-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 10px;
}

.today-release-head small,
.today-release-sub {
    color: var(--muted);
}

.today-release-head h2 {
    margin: 2px 0 0;
    font-size: 22px;
}

.today-release-close {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft-bg);
    color: var(--ink);
    font-size: 22px;
    line-height: 1;
}

.today-release-sub {
    margin: 0;
    padding: 0 20px 12px;
    border-bottom: 1px solid var(--line);
}

.today-release-list {
    display: grid;
    gap: 6px;
    max-height: 430px;
    overflow: auto;
    padding: 14px 20px;
}

.today-release-row {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) 90px 92px 56px;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--soft-bg);
}

.today-release-row b {
    color: var(--ink);
}

.today-release-row span {
    color: var(--green);
    font-weight: 800;
    text-align: right;
}

.today-release-row small {
    color: var(--blue);
    font-weight: 750;
    text-align: center;
}

.today-release-row em {
    color: var(--muted);
    font-style: normal;
    text-align: right;
}

.today-release-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    background: var(--soft-bg);
}

.today-release-dash-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 18px;
}

.today-release-dash-control h2 {
    margin-bottom: 6px;
}

.today-release-dash-control p {
    margin: 0;
    color: var(--muted);
}

.today-release-dash-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.today-release-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    white-space: nowrap;
}

.today-release-toggle input {
    width: 16px;
    height: 16px;
}

@media (max-width: 640px) {
    .today-release-modal {
        align-items: flex-end;
        padding: 12px;
    }

    .today-release-row {
        grid-template-columns: 1fr auto;
        padding: 8px 10px;
    }

    .today-release-row small,
    .today-release-row em {
        text-align: left;
    }

    .today-release-actions {
        flex-direction: column;
    }

    .today-release-dash-control {
        align-items: flex-start;
        flex-direction: column;
    }

    .today-release-dash-actions {
        justify-content: flex-start;
        width: 100%;
    }
}

.history-modal-card {
    width: min(760px, 96vw);
    max-height: min(720px, 90vh);
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(17, 17, 17, .28);
}

.history-modal-body {
    max-height: 560px;
    overflow: auto;
    padding: 14px 18px 18px;
}

.batch-add-card {
    width: min(720px, 96vw);
}

.batch-add-body {
    display: grid;
    gap: 14px;
}

.batch-add-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.batch-add-grid label,
.batch-textarea-label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
}

.batch-textarea {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    font: inherit;
    color: var(--ink);
    background: var(--panel);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
    background: var(--soft-bg);
}

.stock-form-panel {
    margin-bottom: 16px;
}

.stock-edit-form,
.stock-partner-form {
    display: grid;
    gap: 10px;
    padding: 16px;
}

.stock-edit-form {
    grid-template-columns: 1.3fr repeat(3, .75fr) 1.2fr 1.2fr 110px;
}

.stock-partner-form {
    grid-template-columns: 1fr 1fr 90px;
}

.stock-edit-form input,
.stock-edit-form select,
.stock-partner-form input,
.inline-stock-form input,
.table-tools input {
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 0 10px;
    background: var(--panel);
}

.stock-edit-form select {
    height: 72px;
    padding: 6px 10px;
}

.stock-partner-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 16px;
}

.partner-card {
    display: grid;
    grid-template-columns: minmax(110px, auto) minmax(90px, 170px) auto;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--soft-bg);
}

.partner-card.saved-row {
    background: var(--tint-success);
}

.partner-name-chip {
    color: var(--blue);
    background: var(--tint-neutral);
}

.partner-note-chip {
    color: var(--muted);
    background: var(--panel);
    font-weight: 500;
}

.item-partner-chip {
    color: var(--text-success);
    background: var(--tint-success);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edit-popover.wide {
    min-width: 300px;
}

.partner-check-list {
    display: grid;
    gap: 6px;
    max-height: 220px;
    overflow: auto;
    padding: 2px;
}

.partner-check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 0 8px;
    border-radius: 5px;
    background: var(--soft-bg);
}

.popover-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.partner-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--soft-bg);
    color: var(--text-2);
    font-size: 12px;
}

.stock-table {
    overflow-x: auto;
}

.stock-row {
    min-width: 1180px;
    display: grid;
    grid-template-columns: 180px 90px 90px 150px 110px 160px 130px 180px 160px 80px;
    gap: 8px;
    align-items: center;
    min-height: 58px;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
}

.stock-data-row:hover {
    background: var(--soft-bg);
}

.stock-header {
    min-height: 42px;
    background: var(--soft-bg);
    color: var(--muted);
    font-weight: 700;
}

.stock-row b,
.stock-row small {
    display: block;
}

.stock-edit-chip {
    border: 0;
    border-radius: 5px;
    min-height: 30px;
    padding: 0 9px;
    background: transparent;
    color: var(--ink);
    font-weight: 700;
    text-align: left;
    max-width: 100%;
}

.stock-edit-chip:hover {
    background: var(--tint-neutral);
    color: var(--blue);
}

.stock-edit-chip.part-chip {
    font-size: 15px;
}

.stock-edit-chip.money-chip {
    color: var(--text-2);
    background: var(--soft-bg);
}

.stock-edit-chip.money-chip.sale {
    color: var(--green);
    background: var(--tint-success);
}

.stock-edit-chip.qty-chip {
    color: var(--orange);
    background: var(--tint-warning);
    font-size: 16px;
}

.stock-edit-chip.note-chip {
    color: var(--text-3);
    font-weight: 500;
}

.stock-money {
    color: var(--ink);
    font-weight: 800;
}

.stock-money.strong,
.stock-row [data-stock-total] {
    color: var(--orange);
}

.popover-title {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.inline-stock-form {
    display: flex;
    gap: 6px;
    align-items: center;
}

.inline-stock-form input {
    width: 78px;
}

.history-table {
    display: grid;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}

.history-table > div {
    display: grid;
    grid-template-columns: 190px 110px 130px 1fr;
    gap: 10px;
    align-items: center;
    min-height: 42px;
    padding: 0 12px;
    border-bottom: 1px solid var(--line);
}

.history-table > div:first-child {
    background: var(--soft-bg);
    color: var(--muted);
}

.history-table > div:last-child {
    border-bottom: 0;
}

.drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 22px;
    border-bottom: 1px solid var(--line);
}

.drawer-head small {
    color: var(--muted);
}

.drawer-head h2 {
    margin: 6px 0 0;
    font-size: 22px;
}

.icon-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 24px;
    background: var(--bg);
}

.drawer-body {
    padding: 18px 22px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.detail-grid div {
    padding: 13px;
    background: var(--soft-bg);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.detail-grid span,
.detail-grid b {
    display: block;
}

.detail-grid span {
    color: var(--muted);
    font-size: 12px;
}

.detail-grid b {
    margin-top: 6px;
    font-size: 18px;
}

.drawer-body h3 {
    margin: 22px 0 10px;
    font-size: 16px;
}

.history-list {
    margin: 0;
    padding-left: 18px;
}

.history-list li {
    margin: 12px 0;
}

.history-list b,
.history-list span {
    display: block;
}

.history-list span {
    color: var(--muted);
    margin-top: 3px;
}

.drawer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 80;
    max-width: min(360px, calc(100vw - 44px));
    padding: 12px 16px;
    color: #ffffff;
    background: rgba(17, 17, 17, .94);
    border-radius: 6px;
    box-shadow: 0 12px 32px rgba(17, 17, 17, .22);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.admin-workspace {
    gap: 18px;
}

.admin-panel {
    overflow: hidden;
}

.account-table {
    min-width: 1080px;
}

.account-row {
    display: grid;
    grid-template-columns: 70px 1.35fr 1.55fr 150px 120px 190px 260px;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-top: 1px solid var(--line);
}

.account-header {
    color: var(--muted);
    background: var(--soft-bg);
    font-weight: 700;
}

.account-row b,
.account-row small {
    display: block;
}

.account-row small {
    margin-top: 4px;
    color: var(--muted);
}

.compact-control {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    outline: none;
}

.compact-control:focus,
.admin-inline-form input:focus,
.admin-form-grid input:focus,
.admin-form-grid select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(17, 17, 17, .12);
}

.account-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    color: var(--text-2);
    background: var(--tint-neutral);
    border-radius: 6px;
    font-style: normal;
}

.account-badge.ok {
    color: var(--text-success);
    background: var(--tint-success);
}

.account-badge.danger {
    color: var(--text-danger);
    background: var(--tint-danger);
}

.row-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-inline-form {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px 18px;
}

.admin-inline-form input {
    min-width: 220px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

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

.admin-form-grid label span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.admin-modal-card {
    max-width: 620px;
}

.admin-perm-card {
    max-width: 760px;
}

.permission-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.permission-groups {
    display: grid;
    gap: 12px;
}

.permission-group {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.permission-group-title {
    margin-bottom: 10px;
    color: var(--ink);
    font-weight: 800;
}

.permission-item {
    display: grid;
    grid-template-columns: 20px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px dashed var(--soft-bg);
}

.permission-item:first-of-type {
    border-top: 0;
}

.permission-item small {
    color: var(--muted);
    font-size: 12px;
}

.nav-admin-form {
    padding: 0 18px 18px;
}

.template-admin-form {
    padding: 0 18px 18px;
}

.template-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.template-option {
    display: grid;
    grid-template-columns: 22px 1fr;
    align-items: start;
    gap: 10px;
    padding: 16px;
    cursor: pointer;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.template-option.selected,
.template-option:has(input:checked) {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(17, 17, 17, .12);
}

.template-option input {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--orange);
}

.template-option b,
.template-option small {
    display: block;
}

.template-option small {
    margin-top: 5px;
    color: var(--muted);
}

.email-template-panel {
    overflow: hidden;
}

.template-editor-head {
    align-items: center;
}

.template-editor-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 620px;
    border-top: 1px solid var(--line);
}

.template-platform-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px;
    background: var(--soft-bg);
    border-right: 1px solid var(--line);
}

.template-platform-btn {
    display: grid;
    gap: 6px;
    width: 100%;
    min-height: 72px;
    padding: 14px 16px;
    text-align: left;
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: none;
    cursor: pointer;
}

.template-platform-btn b {
    font-size: 17px;
    line-height: 1.2;
}

.template-platform-btn small {
    color: var(--muted);
    font-weight: 700;
}

.template-platform-btn.active {
    border-color: rgba(255, 111, 23, .42);
    box-shadow: 0 10px 24px rgba(17, 17, 17, .08);
}

.template-platform-btn.active b {
    color: var(--orange);
}

.template-editor-main {
    display: grid;
    gap: 16px;
    min-width: 0;
    padding: 18px;
}

.template-vars-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.template-vars-bar b {
    margin-right: 4px;
    color: var(--ink);
}

.template-vars-bar button {
    min-height: 34px;
    padding: 0 12px;
    color: var(--text-2);
    background: var(--soft-bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    font: 700 13px/1.1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    cursor: pointer;
}

.template-vars-bar button:hover {
    border-color: rgba(30, 111, 255, .35);
    color: var(--blue);
}

.template-vars-bar .template-help-btn {
    margin-left: auto;
    color: var(--blue);
    background: rgba(30, 111, 255, .08);
    border-color: rgba(30, 111, 255, .18);
    font-family: inherit;
}

.template-var-modal {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, .42);
}

.template-var-modal.open {
    display: flex;
}

.template-var-card {
    width: min(920px, 100%);
    max-height: min(760px, 90vh);
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}

.template-var-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.template-var-head h2 {
    margin: 0;
    color: var(--ink);
}

.template-var-head p {
    margin: 5px 0 0;
    color: var(--muted);
}

.template-var-head .icon-btn {
    width: 36px;
    height: 36px;
    color: var(--muted);
    background: var(--soft-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.template-var-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    max-height: calc(90vh - 110px);
    overflow: auto;
    padding: 16px 20px 20px;
    background: var(--soft-bg);
}

.template-var-item {
    display: grid;
    gap: 6px;
    padding: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.template-var-item code {
    width: fit-content;
    padding: 4px 7px;
    color: var(--blue);
    background: rgba(30, 111, 255, .08);
    border: 1px solid rgba(30, 111, 255, .12);
    border-radius: 6px;
    font: 800 13px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.template-var-item b {
    color: var(--ink);
}

.template-var-item span {
    color: var(--text-2);
    line-height: 1.5;
}

.template-var-item small {
    color: var(--muted);
    line-height: 1.5;
}

.template-editor-form {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.template-editor-form[hidden] {
    display: none;
}

.template-editor-toolbar,
.template-original-title,
.template-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.template-editor-toolbar {
    min-height: 72px;
    padding: 16px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.template-editor-toolbar h2,
.template-original-title h3 {
    margin: 0;
    color: var(--ink);
}

.template-editor-toolbar small,
.template-original-title p {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.template-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-2);
    font-weight: 800;
    white-space: nowrap;
}

.template-switch input {
    width: 18px;
    height: 18px;
    accent-color: var(--orange);
}

.template-original-panel {
    padding: 16px 18px;
    background: var(--soft-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.template-original-title span {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-weight: 900;
}

.template-original-subject {
    margin-top: 12px;
    color: var(--ink);
    font-size: 16px;
    font-weight: 900;
}

.template-original-panel pre,
.template-preview pre {
    overflow: auto;
    max-height: 300px;
    margin: 12px 0 0;
    padding: 14px;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    font: 700 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap;
}

.template-meta-grid {
    display: grid;
    grid-template-columns: minmax(220px, .9fr) minmax(280px, 1.7fr) minmax(170px, .55fr);
    gap: 14px;
    align-items: end;
}

.template-field {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 800;
}

.template-field input,
.template-field select,
.template-bottom-bar input {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
}

.template-editor-tabs {
    display: inline-flex;
    width: fit-content;
    padding: 4px;
    background: var(--soft-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.template-editor-tabs button {
    min-height: 38px;
    padding: 0 20px;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 6px;
    font-weight: 900;
    cursor: pointer;
}

.template-editor-tabs button.active {
    color: var(--ink);
    background: var(--panel);
    box-shadow: 0 6px 16px rgba(17, 17, 17, .10);
}

.template-code-pane {
    display: none;
    min-width: 0;
}

.template-code-pane.active {
    display: block;
}

.template-code-editor {
    width: 100%;
    min-height: 360px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: 700 14px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.CodeMirror {
    min-height: 420px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: 700 14px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.tox.tox-tinymce {
    min-height: 430px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.tox .tox-toolbar__primary,
.tox .tox-toolbar-overlord,
.tox .tox-statusbar {
    background: var(--panel);
}

.tox .tox-tbtn,
.tox .tox-mbtn {
    border-radius: 6px;
}

.tox .tox-edit-area::before {
    border: 0;
}

.template-bottom-bar {
    padding: 14px;
    background: var(--soft-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.template-bottom-bar input {
    max-width: 360px;
}

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

.template-preview {
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.template-editor-form.custom-disabled .template-meta-grid,
.template-editor-form.custom-disabled .template-editor-tabs,
.template-editor-form.custom-disabled .template-code-pane,
.template-editor-form.custom-disabled .template-bottom-bar {
    opacity: .62;
}

.nav-admin-fold {
    overflow: hidden;
}

.nav-admin-summary {
    cursor: pointer;
    list-style: none;
}

.nav-admin-summary::-webkit-details-marker {
    display: none;
}

.nav-summary-action::after {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform .16s ease;
}

.compact-tool {
    min-width: 0;
    min-height: 34px;
    padding: 0 12px;
    white-space: nowrap;
}

.nav-admin-fold[open] .nav-summary-action::after {
    transform: rotate(225deg) translateY(-2px);
}

.nav-admin-fold[open] .nav-summary-action {
    color: var(--orange);
    background: var(--tint-warning);
}

.nav-config-table {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.nav-config-row {
    display: grid;
    grid-template-columns: 130px minmax(180px, 1fr) 110px 90px minmax(160px, .8fr);
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
}

.nav-config-row:first-child {
    border-top: 0;
}

.nav-config-header {
    color: var(--muted);
    background: var(--soft-bg);
    font-weight: 800;
}

.nav-config-row b,
.nav-config-row small {
    display: block;
}

.nav-config-row small {
    color: var(--muted);
}

.nav-order-input {
    max-width: 96px;
}

.nav-switch {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.nav-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.nav-switch em {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--line);
    border-radius: 999px;
    transition: background .16s ease;
}

.nav-switch em::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--panel);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(17, 17, 17, .18);
    transition: transform .16s ease;
}

.nav-switch input:checked + em {
    background: var(--orange);
}

.nav-switch input:checked + em::after {
    transform: translateX(20px);
}

.nav-admin-actions {
    margin-top: 14px;
}

.profile-workspace {
    gap: 18px;
}

.profile-shell {
    display: grid;
    grid-template-columns: minmax(260px, 340px) 1fr;
    gap: 18px;
    align-items: start;
}

.profile-card {
    position: sticky;
    top: 88px;
    padding: 24px;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(17, 17, 17, .10), rgba(255, 255, 255, 0) 38%),
        var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.profile-avatar {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin-bottom: 16px;
    color: #ffffff;
    background: var(--orange);
    border-radius: 8px;
    font-size: 32px;
    font-weight: 900;
    box-shadow: 0 12px 26px rgba(17, 17, 17, .22);
}

.profile-name {
    color: var(--ink);
    font-size: 24px;
    line-height: 1.2;
    font-weight: 900;
}

.profile-user {
    margin-top: 5px;
    color: var(--muted);
    font-weight: 700;
}

.profile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.profile-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    color: var(--text-2);
    background: var(--tint-neutral);
    border-radius: 6px;
    font-weight: 800;
}

.profile-badge.ok {
    color: var(--text-success);
    background: var(--tint-success);
}

.profile-badge.danger {
    color: var(--text-danger);
    background: var(--tint-danger);
}

.profile-meta {
    display: grid;
    gap: 10px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.profile-meta div {
    padding: 10px 0;
}

.profile-meta span,
.profile-meta small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.profile-meta b {
    display: block;
    margin-top: 4px;
    color: var(--ink);
    font-size: 15px;
}

.profile-panel {
    overflow: hidden;
}

.profile-form {
    padding: 18px 18px 20px;
}

.profile-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--ink);
    font-size: 16px;
    font-weight: 900;
}

.profile-section-title::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 18px;
    background: var(--orange);
    border-radius: 4px;
}

.profile-password {
    margin-top: 24px;
    padding: 18px;
    background: var(--soft-bg);
    border-top: 1px solid var(--line);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.profile-switch-row {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 10px;
    align-items: start;
    padding: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.profile-maintenance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
    padding: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.profile-maintenance-stat span,
.profile-maintenance-stat small {
    display: block;
    color: var(--muted);
}

.profile-maintenance-stat b {
    display: block;
    margin: 3px 0;
    color: var(--orange);
    font-size: 28px;
    line-height: 1;
}

.profile-clean-btn {
    white-space: nowrap;
}

.profile-switch-row input {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--orange);
}

.profile-switch-row b,
.profile-switch-row small {
    display: block;
}

.profile-switch-row small {
    margin-top: 4px;
    color: var(--muted);
}

.profile-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.profile-alert {
    margin: 18px 18px 0;
    padding: 12px 14px;
    border-radius: 6px;
    font-weight: 700;
}

.profile-alert.ok {
    color: var(--text-success);
    background: var(--tint-success);
}

.profile-alert.danger {
    color: var(--text-danger);
    background: var(--tint-danger);
}

.purchase-workspace {
    gap: 18px;
}

.hot-workspace {
    gap: 18px;
}

.hot-panel {
    overflow: hidden;
}

.hot-add-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 10px;
    padding: 18px;
    border-top: 1px solid var(--line);
}

.hot-add-row .primary-btn {
    min-width: 96px;
}

.hot-add-row input,
.hot-batch-row textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    outline: none;
}

.hot-add-row input {
    height: 42px;
    padding: 0 12px;
}

.hot-batch-row {
    display: grid;
    gap: 10px;
    padding: 0 18px 18px;
}

.hot-batch-row[hidden] {
    display: none;
}

.hot-batch-row textarea {
    min-height: 118px;
    padding: 12px;
    resize: vertical;
}

.hot-batch-row > div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hot-batch-row #batchResult {
    color: var(--muted);
    font-size: 13px;
}

.hot-list {
    border-top: 1px solid var(--line);
}

.hot-item {
    display: grid;
    grid-template-columns: minmax(210px, 1fr) 110px auto;
    align-items: center;
    gap: 14px;
    padding: 13px 18px;
    border-top: 1px solid var(--line);
}

.hot-item:first-child {
    border-top: 0;
}

.hot-part {
    color: var(--ink);
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0;
}

.copy-part-text {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 3px;
    transition: color .15s ease, text-decoration-color .15s ease;
}

.copy-part-text:hover {
    color: var(--blue);
    text-decoration-color: currentColor;
}

.hot-item .row-actions {
    justify-content: flex-end;
}

.hot-item .mini-btn,
.hot-item .mini-danger {
    min-width: 52px;
    min-height: 30px;
    padding: 0 10px;
}

.stock-part-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.copy-part-btn {
    cursor: pointer;
    min-height: 28px;
    padding: 0 8px;
    font-size: 12px;
}

.hot-owner {
    color: var(--muted);
    font-size: 13px;
}

.hot-item:hover {
    background: var(--soft-bg);
}

.purchase-panel {
    overflow: hidden;
}

.purchase-table {
    min-width: 1060px;
}

.purchase-row {
    display: grid;
    grid-template-columns: 70px 130px 1.35fr 150px 1.35fr 130px 210px;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-top: 1px solid var(--line);
    transition: background .12s ease;
}

.purchase-row:not(.purchase-header):hover {
    background: var(--soft-bg);
}

.purchase-header,
.orders-header {
    color: var(--muted);
    background: var(--soft-bg);
    font-weight: 800;
}

.purchase-sort {
    cursor: pointer;
    user-select: none;
}

.purchase-sort::after {
    content: "↕";
    margin-left: 5px;
    color: var(--text-faint);
    font-size: 12px;
}

.purchase-sort[data-dir="asc"]::after {
    content: "↑";
    color: var(--blue);
}

.purchase-sort[data-dir="desc"]::after {
    content: "↓";
    color: var(--blue);
}

.purchase-row b {
    display: block;
}

.purchase-status-label {
    position: relative;
    display: inline-block;
    width: 100%;
    cursor: pointer;
}

.purchase-row .purchase-status-label .purchase-status {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    border: 0;
    padding: 0;
}

.purchase-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    min-height: 28px;
    padding: 4px 8px;
    border-radius: 7px;
    font-weight: 800;
}

.purchase-status-badge .status-mark {
    position: relative;
    display: inline-block;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border-radius: 50%;
}

.signal-status {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
}

.signal-status .status-mark {
    position: relative;
    display: inline-block;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    border-radius: 50%;
}

.signal-status.normal .status-mark {
    background: var(--green);
}

.signal-status.review .status-mark {
    background: var(--blue-dark);
}

.signal-status.recycle .status-mark {
    background: var(--blue-dark);
}

.signal-status.blocked .status-mark {
    background: var(--red);
}

.signal-status.normal .status-mark::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 3px;
    width: 5px;
    height: 9px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(42deg);
}

.signal-status.review .status-mark::before,
.signal-status.review .status-mark::after {
    content: "";
    position: absolute;
    left: 7px;
    background: var(--panel);
    border-radius: 2px;
}

.signal-status.review .status-mark::before {
    top: 4px;
    width: 2px;
    height: 6px;
}

.signal-status.review .status-mark::after {
    top: 12px;
    width: 2px;
    height: 2px;
}

.signal-status.recycle .status-mark::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 4px;
    width: 7px;
    height: 7px;
    border: 2px solid #ffffff;
    border-right-color: transparent;
    border-radius: 50%;
}

.signal-status.recycle .status-mark::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 8px;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-right: 5px solid #ffffff;
}

.signal-status.blocked .status-mark::before,
.signal-status.blocked .status-mark::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 7px;
    width: 9px;
    height: 2px;
    background: var(--panel);
    border-radius: 2px;
}

.signal-status.blocked .status-mark::before {
    transform: rotate(45deg);
}

.signal-status.blocked .status-mark::after {
    transform: rotate(-45deg);
}

.purchase-status-badge.normal {
    color: var(--text-success);
    background: var(--tint-success);
}

.purchase-status-badge.normal .status-mark {
    background: var(--green);
}

.purchase-status-badge.normal .status-mark::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 3px;
    width: 6px;
    height: 10px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(42deg);
}

.purchase-status-badge.review {
    color: var(--text-warning);
    background: var(--tint-warning);
}

.purchase-status-badge.review .status-mark {
    background: var(--blue-dark);
}

.purchase-status-badge.review .status-mark::before,
.purchase-status-badge.review .status-mark::after {
    content: "";
    position: absolute;
    left: 8px;
    background: var(--panel);
    border-radius: 2px;
}

.purchase-status-badge.review .status-mark::before {
    top: 4px;
    width: 2px;
    height: 7px;
}

.purchase-status-badge.review .status-mark::after {
    top: 13px;
    width: 2px;
    height: 2px;
}

.purchase-status-badge.recycle {
    color: var(--blue);
    background: var(--tint-neutral);
}

.purchase-status-badge.recycle .status-mark {
    background: var(--blue-dark);
}

.purchase-status-badge.recycle .status-mark::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 4px;
    width: 8px;
    height: 8px;
    border: 2px solid #ffffff;
    border-right-color: transparent;
    border-radius: 50%;
}

.purchase-status-badge.recycle .status-mark::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 9px;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-right: 5px solid #ffffff;
}

.purchase-status-badge.blocked {
    color: var(--text-danger);
    background: var(--tint-danger);
}

.purchase-status-badge.blocked .status-mark {
    background: var(--red);
}

.purchase-status-badge.blocked .status-mark::before,
.purchase-status-badge.blocked .status-mark::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 8px;
    width: 10px;
    height: 2px;
    background: var(--panel);
    border-radius: 2px;
}

.purchase-status-badge.blocked .status-mark::before {
    transform: rotate(45deg);
}

.purchase-status-badge.blocked .status-mark::after {
    transform: rotate(-45deg);
}

.orders-modal-card {
    max-width: 1080px;
}

/* ADI private portal: compact typography, buttons and workspace layout */
.adi-portal-shell {
    color: #263244;
    background: #f3f5f8;
}

.adi-portal-shell .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid #d9e0e8;
    background: rgba(255, 255, 255, .97);
    box-shadow: none;
}

.adi-portal-shell .topbar-inner {
    min-height: 64px;
}

.adi-portal-shell .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 7px;
    color: #ffffff;
    background: #172033;
    font-size: 12px;
    font-weight: 900;
}

.adi-portal-shell .brand-title {
    color: #172033;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0;
}

.adi-portal-shell .brand-subtitle {
    margin-top: 2px;
    color: #718096;
    font-size: 11px;
    letter-spacing: 0;
}

.adi-portal-shell .identity {
    color: #526174;
    font-size: 12px;
}

.adi-portal-shell .app-body {
    min-height: calc(100vh - 64px);
}

.adi-portal-shell .side-nav {
    width: 212px;
    padding: 20px 14px;
    border-right: 1px solid #d9e0e8;
    background: #ffffff;
}

.adi-portal-shell .side-nav-title {
    padding: 0 10px 9px;
    color: #8995a5;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0;
}

.adi-portal-shell .side-nav-list {
    gap: 5px;
}

.adi-portal-shell .side-nav-link {
    min-height: 40px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #526174;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
}

.adi-portal-shell .side-nav-link:hover {
    border-color: #d9e0e8;
    color: #172033;
    background: #f7f9fb;
}

.adi-portal-shell .side-nav-link.active {
    border-color: #bfd4f5;
    color: #174ea6;
    background: #edf4ff;
    box-shadow: inset 3px 0 0 #2563eb;
}

.adi-portal-shell .app-content {
    min-width: 0;
    background: #f3f5f8;
}

.adi-portal-shell .workspace {
    width: min(1480px, 100%);
    padding-top: 20px;
    padding-bottom: 40px;
}

.adi-portal-shell .main-panel,
.adi-portal-shell .signal-card,
.adi-portal-shell .adi-visible-add-form,
.adi-portal-shell .adi-monitor-status,
.adi-portal-shell .adi-control-card,
.adi-portal-shell .adi-summary-box {
    border-color: #d9e0e8;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}

.adi-portal-shell .main-panel {
    padding: 20px;
}

.adi-portal-shell .table-head {
    gap: 16px;
    margin-bottom: 15px;
}

.adi-portal-shell .table-head h1,
.adi-portal-shell .table-head h2 {
    margin: 0;
    color: #172033;
    font-size: 19px;
    line-height: 1.35;
    letter-spacing: 0;
}

.adi-portal-shell .table-head p {
    max-width: 760px;
    margin-top: 4px;
    color: #718096;
    font-size: 12px;
    line-height: 1.6;
}

.adi-portal-shell .table-actions,
.adi-portal-shell .adi-monitor-actions,
.adi-portal-shell .adi-product-tools {
    gap: 8px;
}

.adi-portal-shell .primary-btn,
.adi-portal-shell .soft-btn,
.adi-portal-shell .ghost-btn,
.adi-portal-shell .danger-btn {
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 750;
    line-height: 1.25;
    letter-spacing: 0;
    white-space: nowrap;
}

.adi-portal-shell .primary-btn {
    border-color: #2563eb;
    background: #2563eb;
    box-shadow: none;
}

.adi-portal-shell .primary-btn:hover {
    border-color: #1d4ed8;
    background: #1d4ed8;
}

.adi-portal-shell .soft-btn,
.adi-portal-shell .ghost-btn {
    border-color: #cbd5e1;
    color: #334155;
    background: #ffffff;
    box-shadow: none;
}

.adi-portal-shell .soft-btn:hover,
.adi-portal-shell .ghost-btn:hover {
    border-color: #94a3b8;
    color: #172033;
    background: #f8fafc;
}

.adi-portal-shell .danger-btn {
    border-color: #dc2626;
    color: #ffffff;
    background: #dc2626;
    box-shadow: none;
}

.adi-portal-shell .primary-btn:focus-visible,
.adi-portal-shell .soft-btn:focus-visible,
.adi-portal-shell .ghost-btn:focus-visible,
.adi-portal-shell .danger-btn:focus-visible,
.adi-portal-shell button:focus-visible,
.adi-portal-shell a:focus-visible {
    outline: 3px solid rgba(37, 99, 235, .22);
    outline-offset: 2px;
}

.adi-portal-shell .adi-remote-tabs,
.adi-portal-shell .adi-page-tabs {
    gap: 4px;
    margin: 0 0 14px;
    padding: 4px;
    overflow-x: auto;
    border-color: #d9e0e8;
    border-radius: 7px;
    background: #e9edf2;
    box-shadow: none;
    scrollbar-width: thin;
}

.adi-portal-shell .adi-remote-tab,
.adi-portal-shell .adi-page-tab {
    min-width: 112px;
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 5px;
    color: #526174;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0;
    white-space: nowrap;
    box-shadow: none;
}

.adi-portal-shell .adi-remote-tab:hover,
.adi-portal-shell .adi-page-tab:hover {
    color: #172033;
    background: rgba(255, 255, 255, .7);
}

.adi-portal-shell .adi-remote-tab.active,
.adi-portal-shell .adi-page-tab.active {
    border-color: #172033;
    color: #ffffff;
    background: #172033;
    box-shadow: none;
}

.adi-portal-shell .signal-grid {
    gap: 10px;
    margin-bottom: 14px;
}

.adi-portal-shell .signal-card {
    min-height: 104px;
    padding: 15px 16px;
    background: #ffffff;
}

.adi-portal-shell .signal-label,
.adi-portal-shell .signal-card small {
    color: #718096;
    font-size: 11px;
    letter-spacing: 0;
}

.adi-portal-shell .signal-card strong {
    margin: 5px 0 2px;
    color: #172033;
    font-size: 25px;
    line-height: 1.2;
}

.adi-portal-shell .adi-portal-view {
    padding-top: 20px;
}

.adi-portal-shell .adi-monitor-command {
    grid-template-columns: minmax(0, 1fr) 292px;
    gap: 12px;
    margin-bottom: 14px;
}

.adi-portal-shell .adi-visible-add-form,
.adi-portal-shell .adi-monitor-status {
    padding: 16px;
}

.adi-portal-shell .adi-command-title {
    align-items: center;
    margin-bottom: 10px;
}

.adi-portal-shell .adi-command-title span {
    color: #b45309;
    font-size: 10px;
    letter-spacing: 0;
}

.adi-portal-shell .adi-command-title h2,
.adi-portal-shell .adi-monitor-status h3 {
    margin: 2px 0;
    color: #172033;
    font-size: 17px;
    line-height: 1.35;
    letter-spacing: 0;
}

.adi-portal-shell .adi-command-title p {
    color: #718096;
    font-size: 12px;
    line-height: 1.55;
}

.adi-portal-shell .adi-command-title .primary-btn {
    min-width: 112px;
    align-self: center;
    border-color: #2563eb;
    background: #2563eb;
    box-shadow: none;
}

.adi-portal-shell .adi-visible-add-form textarea,
.adi-portal-shell .adi-command-fields input,
.adi-portal-shell .adi-command-fields select,
.adi-portal-shell .adi-monitor-actions input,
.adi-portal-shell .adi-monitor-actions select,
.adi-portal-shell .adi-search input,
.adi-portal-shell .adi-config-form input,
.adi-portal-shell .adi-config-form select,
.adi-portal-shell .adi-config-form textarea {
    border-color: #cbd5e1;
    border-radius: 6px;
    color: #263244;
    background: #ffffff;
    font-size: 12px;
}

.adi-portal-shell .adi-visible-add-form textarea {
    min-height: 84px;
    padding: 11px 12px;
}

.adi-portal-shell .adi-command-fields {
    grid-template-columns: 100px 120px minmax(160px, 200px) minmax(180px, 1fr);
    gap: 8px;
    margin-top: 9px;
}

.adi-portal-shell .adi-command-fields label {
    gap: 5px;
    color: #64748b;
    font-size: 11px;
    letter-spacing: 0;
}

.adi-portal-shell .adi-monitor-status h3 {
    margin-bottom: 10px;
}

.adi-portal-shell .adi-monitor-status div {
    padding: 8px 0;
    border-color: #e7ebf0;
}

.adi-portal-shell .adi-monitor-status span,
.adi-portal-shell .adi-monitor-status b {
    font-size: 11px;
}

.adi-portal-shell .adi-portal-view .adi-monitor-panel {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}

.adi-portal-shell .adi-monitor-panel .table-head,
.adi-portal-shell .adi-products-panel .table-head,
.adi-portal-shell .adi-summary-panel .table-head {
    align-items: flex-start;
}

.adi-portal-shell .adi-monitor-actions input,
.adi-portal-shell .adi-monitor-actions select {
    min-height: 36px;
}

.adi-portal-shell .adi-remote-table thead th,
.adi-portal-shell .data-table thead th {
    padding-top: 10px;
    padding-bottom: 10px;
    color: #526174;
    background: #eef2f6;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0;
}

.adi-portal-shell .adi-portal-view .adi-remote-table tbody tr:nth-child(even) {
    background: #f7f9fb;
}

.adi-portal-shell .adi-portal-view .adi-remote-table tbody tr:nth-child(even):hover,
.adi-portal-shell .adi-remote-table tbody tr:hover,
.adi-portal-shell .data-table tbody tr:hover {
    background: #edf4ff;
}

.adi-portal-shell .adi-remote-table td,
.adi-portal-shell .data-table td {
    color: #334155;
    font-size: 12px;
    line-height: 1.45;
}

.adi-portal-shell .adi-part-number {
    font-size: 13px;
}

.adi-portal-shell .adi-hero-panel {
    padding: 18px 20px;
    border: 1px solid #d9e0e8;
    color: #263244;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}

.adi-portal-shell .adi-hero-panel .adi-hero-glow {
    display: none;
}

.adi-portal-shell .adi-hero-panel h1 {
    margin: 3px 0 5px;
    color: #172033;
    font-size: 20px;
    line-height: 1.35;
    letter-spacing: 0;
}

.adi-portal-shell .adi-hero-panel p {
    color: #718096;
    font-size: 12px;
}

.adi-portal-shell .adi-hero-panel .soft-btn {
    border-color: #cbd5e1;
    color: #334155;
    background: #ffffff;
}

.adi-portal-shell .adi-kicker,
.adi-portal-shell .adi-remote-kicker {
    color: #b45309;
    font-size: 10px;
    letter-spacing: 0;
}

.adi-portal-shell .adi-endpoint,
.adi-portal-shell .adi-remote-endpoint {
    margin: 10px 0;
    padding: 10px 12px;
    border-color: #d9e0e8;
    border-radius: 6px;
    background: #f7f9fb;
    font-size: 11px;
}

.adi-portal-shell .adi-filter-pills {
    gap: 3px;
    padding: 3px;
    border-color: #d9e0e8;
    border-radius: 6px;
    background: #eef2f6;
}

.adi-portal-shell .adi-filter-pill {
    min-height: 30px;
    padding: 6px 9px;
    border-radius: 4px;
    color: #526174;
    font-size: 11px;
    letter-spacing: 0;
}

.adi-portal-shell .adi-filter-pill.active {
    color: #174ea6;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

.adi-portal-shell .adi-cleanup-note {
    margin: -2px 0 14px;
    padding: 9px 11px;
    border-left: 3px solid #94a3b8;
    color: #64748b;
    background: #f7f9fb;
    font-size: 11px;
    line-height: 1.55;
}

@media (max-width: 1100px) {
    .adi-portal-shell .side-nav {
        width: 100%;
        padding: 10px 14px;
    }

    .adi-portal-shell .side-nav-title {
        display: none;
    }

    .adi-portal-shell .side-nav-list {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .adi-portal-shell .side-nav-link {
        min-width: 112px;
        justify-content: center;
        text-align: center;
        white-space: nowrap;
    }

    .adi-portal-shell .side-nav-link.active {
        box-shadow: inset 0 -3px 0 #2563eb;
    }

    .adi-portal-shell .adi-monitor-command {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .adi-portal-shell .topbar {
        position: static;
    }

    .adi-portal-shell .topbar-inner {
        min-height: 58px;
        gap: 10px;
    }

    .adi-portal-shell .brand-subtitle,
    .adi-portal-shell .identity > span:not(.status-dot) {
        display: none;
    }

    .adi-portal-shell .workspace,
    .adi-portal-shell .adi-portal-view {
        padding-top: 14px;
        padding-bottom: 28px;
    }

    .adi-portal-shell .main-panel,
    .adi-portal-shell .adi-visible-add-form,
    .adi-portal-shell .adi-monitor-status {
        padding: 14px;
    }

    .adi-portal-shell .adi-remote-tabs,
    .adi-portal-shell .adi-page-tabs {
        position: static;
        margin-bottom: 12px;
    }

    .adi-portal-shell .adi-remote-tab,
    .adi-portal-shell .adi-page-tab {
        flex: 0 0 auto;
        min-width: 96px;
    }

    .adi-portal-shell .adi-command-title {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .adi-portal-shell .adi-command-title .primary-btn {
        width: 100%;
        margin-top: 0;
    }

    .adi-portal-shell .adi-command-fields {
        grid-template-columns: 1fr 1fr;
    }

    .adi-portal-shell .adi-command-fields .command-note {
        grid-column: 1 / -1;
    }

    .adi-portal-shell .table-actions,
    .adi-portal-shell .adi-monitor-actions,
    .adi-portal-shell .adi-product-tools {
        width: 100%;
        align-items: stretch;
    }

    .adi-portal-shell .table-actions > *,
    .adi-portal-shell .adi-monitor-actions > * {
        flex: 1 1 128px;
    }

    .adi-portal-shell .adi-hero-panel {
        padding: 14px;
    }

    .adi-portal-shell .adi-endpoint code,
    .adi-portal-shell .adi-remote-endpoint code {
        overflow-wrap: anywhere;
    }
}

@media (max-width: 440px) {
    .adi-portal-shell .brand-title {
        font-size: 13px;
    }

    .adi-portal-shell .brand-mark {
        width: 34px;
        height: 34px;
    }

    .adi-portal-shell .identity .ghost-btn {
        min-height: 34px;
        padding: 7px 9px;
    }

    .adi-portal-shell .adi-command-fields {
        grid-template-columns: 1fr;
    }

    .adi-portal-shell .adi-command-fields .command-note {
        grid-column: auto;
    }

    .adi-portal-shell .table-actions > *,
    .adi-portal-shell .adi-monitor-actions > * {
        flex-basis: 100%;
        width: 100%;
    }
}

/* ADI shared notification template workbench */
.adi-template-workbench {
    overflow: visible;
    padding: 0;
}

.adi-template-head {
    margin: 0;
    padding: 22px 24px 18px;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
}

.adi-template-head h1 {
    margin-top: 4px;
}

.adi-template-eyebrow {
    display: block;
    color: #8a4b08;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.4;
    letter-spacing: 0;
}

.adi-template-head-actions,
.adi-template-actionbar,
.adi-template-actionbar .template-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.adi-template-sync {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: #475569;
    background: #f8fafc;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.adi-template-sync i {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #16a34a;
}

.adi-template-sync[data-state="dirty"] {
    color: #92400e;
    border-color: #f3c77b;
    background: #fffbeb;
}

.adi-template-sync[data-state="dirty"] i,
.adi-template-sync[data-state="saving"] i {
    background: #d97706;
}

.adi-template-sync[data-state="saving"] i {
    animation: adi-template-pulse 1s ease-in-out infinite;
}

.adi-template-sync[data-state="error"] {
    color: #b42318;
    border-color: #fecaca;
    background: #fef2f2;
}

.adi-template-sync[data-state="error"] i {
    background: #dc2626;
}

@keyframes adi-template-pulse {
    50% { opacity: .35; }
}

.adi-template-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr);
    gap: 0;
    align-items: start;
}

.adi-template-editor-column {
    min-width: 0;
    padding: 22px 24px 24px;
    border-right: 1px solid var(--line);
    background: #f8fafc;
}

.adi-template-edit-section {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.adi-template-edit-section + .adi-template-edit-section {
    margin-top: 14px;
}

.adi-template-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 15px;
}

.adi-template-section-head b,
.adi-preview-head b {
    display: block;
    color: #172033;
    font-size: 15px;
    line-height: 1.4;
}

.adi-template-section-head small,
.adi-preview-head small {
    display: block;
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.55;
}

.adi-template-field {
    display: block;
}

.adi-template-field + .adi-template-field {
    margin-top: 14px;
}

.adi-template-field > span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 7px;
}

.adi-template-field > span b {
    color: #334155;
    font-size: 13px;
}

.adi-template-field > span small {
    color: #94a3b8;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.adi-template-field input,
.adi-template-field textarea,
.adi-template-test-field input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: #172033;
    background: #ffffff;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.adi-template-field input,
.adi-template-test-field input {
    height: 42px;
    padding: 0 12px;
}

.adi-template-field textarea {
    min-height: 92px;
    padding: 11px 12px;
    resize: vertical;
    font-family: Consolas, "Microsoft YaHei", monospace;
    font-size: 13px;
    line-height: 1.65;
}

.adi-template-body-field textarea {
    min-height: 360px;
}

.adi-template-field.is-active input,
.adi-template-field.is-active textarea,
.adi-template-field input:focus,
.adi-template-field textarea:focus,
.adi-template-test-field input:focus {
    outline: 0;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.adi-variable-section {
    border-left: 3px solid #d97706;
}

.adi-variable-groups {
    display: grid;
    gap: 12px;
}

.adi-variable-group {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
}

.adi-variable-group > span {
    padding-top: 6px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.adi-variable-group > div {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.adi-variable-group button {
    min-height: 30px;
    padding: 4px 8px;
    border: 1px solid #d7dee8;
    border-radius: 5px;
    color: #334155;
    background: #f8fafc;
    font-family: Consolas, monospace;
    font-size: 11px;
    cursor: pointer;
}

.adi-variable-group button:hover,
.adi-variable-group button:focus-visible {
    border-color: #93c5fd;
    color: #1d4ed8;
    background: #eff6ff;
    outline: 0;
}

.adi-template-preview-column {
    position: sticky;
    top: 18px;
    min-width: 0;
    padding: 22px;
    background: #ffffff;
}

.adi-preview-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.adi-preview-head > span {
    padding: 4px 7px;
    border-radius: 4px;
    color: #166534;
    background: #dcfce7;
    font-size: 10px;
    font-weight: 800;
}

.adi-email-preview {
    overflow: hidden;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .08);
}

.adi-email-preview-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 13px;
    border-bottom: 1px solid #e2e8f0;
    color: #64748b;
    background: #f8fafc;
    font-size: 11px;
}

.adi-email-preview h3 {
    margin: 0;
    padding: 14px 15px 10px;
    color: #111827;
    font-size: 17px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.adi-email-preview pre {
    min-height: 280px;
    max-height: 520px;
    margin: 0;
    padding: 5px 15px 18px;
    overflow: auto;
    color: #334155;
    background: #ffffff;
    font-family: Arial, "Microsoft YaHei", sans-serif;
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.adi-fangtang-preview,
.adi-preview-sample {
    margin-top: 12px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #f8fafc;
}

.adi-fangtang-preview > span,
.adi-preview-sample > span {
    display: block;
    margin-bottom: 6px;
    color: #64748b;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.adi-fangtang-preview b,
.adi-preview-sample b {
    display: block;
    color: #172033;
    font-size: 13px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.adi-fangtang-preview p,
.adi-preview-sample small {
    display: block;
    margin: 4px 0 0;
    color: #64748b;
    font-size: 12px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.adi-template-actionbar {
    justify-content: flex-end;
    padding: 15px 24px;
    border-top: 1px solid var(--line);
    background: #ffffff;
}

.adi-template-save-note {
    margin-right: auto;
    color: #64748b;
    font-size: 12px;
}

.is-dirty .adi-template-save-note {
    color: #92400e;
    font-weight: 700;
}

.adi-template-test-field {
    width: min(280px, 100%);
}

.adi-template-feedback {
    margin: 0 24px 18px;
    border-radius: 6px;
}

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

    .adi-template-editor-column {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .adi-template-preview-column {
        position: static;
    }

    .adi-email-preview pre {
        min-height: 220px;
    }
}

@media (max-width: 640px) {
    .adi-template-head,
    .adi-template-editor-column,
    .adi-template-preview-column {
        padding: 16px;
    }

    .adi-template-head-actions,
    .adi-template-actionbar,
    .adi-template-actionbar .template-actions {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    .adi-template-head-actions .soft-btn,
    .adi-template-actionbar button {
        width: 100%;
        justify-content: center;
    }

    .adi-template-sync {
        justify-content: center;
        white-space: normal;
        text-align: center;
    }

    .adi-template-edit-section {
        padding: 14px;
    }

    .adi-variable-group {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .adi-variable-group > span {
        padding-top: 0;
    }

    .adi-template-body-field textarea {
        min-height: 300px;
    }

    .adi-template-actionbar {
        padding: 16px;
    }

    .adi-template-save-note {
        margin-right: 0;
        text-align: center;
    }

    .adi-template-test-field {
        width: 100%;
    }

    .adi-template-feedback {
        margin: 0 16px 16px;
    }
}

.orders-table {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.orders-row {
    display: grid;
    grid-template-columns: 1.2fr 1.25fr 80px 110px 110px 100px 110px 90px;
    align-items: center;
    gap: 10px;
    min-width: 880px;
    padding: 11px 12px;
    border-top: 1px solid var(--line);
}

.orders-row:first-child {
    border-top: 0;
}

.order-form-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

@media (max-width: 1100px) {
    .command-strip,
    .monitor-section {
        grid-template-columns: 1fr;
    }

    .app-body {
        flex-direction: column;
    }

    .side-nav {
        width: 100%;
        position: static;
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 14px;
    }

    .side-nav-list {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .profile-shell {
        grid-template-columns: 1fr;
    }

    .profile-card {
        position: static;
    }

    .profile-maintenance {
        align-items: stretch;
        flex-direction: column;
    }

    .nav-config-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

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

    .hot-add-row,
    .hot-item {
        grid-template-columns: 1fr;
    }

    .hot-batch-row > div {
        align-items: stretch;
        flex-direction: column;
    }

    .identity {
        justify-content: flex-start;
    }

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

@media (max-width: 640px) {
    .wrap {
        width: 100%;
        padding: 0 12px;
    }

    .search-row {
        grid-template-columns: 1fr;
    }

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

    .table-head {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }

    .table-tools {
        flex-direction: column;
    }

    .batch-add-grid {
        grid-template-columns: 1fr;
    }

    .inline-filter,
    .email-add-row {
        align-items: stretch;
        flex-direction: column;
    }

    .inline-filter input,
    .email-add-row input[type="email"],
    .email-add-row input[type="text"] {
        width: 100%;
    }

    .api-mini-grid {
        grid-template-columns: 1fr;
    }

    .api-mini-grid div {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .api-settings-grid {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .history-table > div {
        grid-template-columns: 1fr 70px 80px 70px;
        font-size: 12px;
    }

    .admin-inline-form,
    .admin-form-grid {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .admin-inline-form input {
        min-width: 0;
        width: 100%;
    }

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