:root {
    --bg: #f5f5f7;
    --panel: rgba(255, 255, 255, 0.86);
    --text: #1d1d1f;
    --muted: #6e6e73;
    --line: #d7d7dc;
    --blue: #0071e3;
    --green: #248a3d;
    --amber: #b26a00;
    --red: #d70015;
    --shadow: 0 18px 46px rgba(29, 29, 31, 0.09);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    width: max-content;
    padding: 24px 18px;
    background: rgba(251, 251, 253, 0.9);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(24px);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand,
.logout-link,
.nav-item,
.toolbar,
.section-head,
.filters {
    display: flex;
    align-items: center;
}

.brand {
    gap: 0;
}

.brand strong {
    display: block;
    font-size: 18px;
}

.brand span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav-item,
.logout-link {
    gap: 10px;
    height: 42px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    text-decoration: none;
}

.nav-item.active,
.nav-item:hover,
.logout-link:hover {
    background: #ececf0;
    color: var(--text);
}

.logout-link {
    margin-top: auto;
}

.main {
    position: relative;
    padding: 30px;
    overflow: visible;
}

.app-loading {
    position: absolute;
    inset: 30px;
    z-index: 20;
    border-radius: 12px;
    background: rgba(245, 245, 247, 0.94);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

.app-loading.hidden {
    display: none;
}

.loading-shell {
    width: 100%;
    display: grid;
    gap: 18px;
}

.loading-line,
.loading-card,
.loading-chip,
.loading-table-row {
    position: relative;
    overflow: hidden;
    background: #e8e8ed;
}

.loading-line::after,
.loading-card::after,
.loading-chip::after,
.loading-table-row::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.8) 50%, transparent 100%);
    animation: shimmer 1.3s infinite;
}

.loading-line {
    border-radius: 999px;
}

.loading-line-eyebrow {
    width: 180px;
    height: 14px;
    margin-top: 6px;
}

.loading-line-title {
    width: min(420px, 70%);
    height: 40px;
}

.loading-summary-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

.loading-card {
    min-height: 78px;
    border-radius: 8px;
}

.loading-panel {
    flex: 1 1 auto;
    border-radius: 8px;
    border: 1px solid rgba(215, 215, 220, 0.75);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow);
    padding: 16px;
    display: grid;
    gap: 14px;
}

.loading-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.loading-line-section {
    width: 240px;
    height: 28px;
}

.loading-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.loading-chip {
    width: 108px;
    height: 36px;
    border-radius: 8px;
}

.loading-table {
    display: grid;
    gap: 8px;
}

.loading-table-row {
    height: 48px;
    border-radius: 8px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 13px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 34px;
    line-height: 1.1;
}

h2 {
    margin-bottom: 0;
    font-size: 22px;
}

.toolbar {
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.primary-button,
.secondary-button,
.icon-button {
    min-height: 40px;
    border-radius: 8px;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled {
    cursor: wait;
    opacity: 0.7;
}

#productsExpandAllButton:disabled:not(.is-loading),
#productsCollapseAllButton:disabled,
[data-order-expand-all]:disabled:not(.is-loading),
[data-order-collapse-all]:disabled {
    cursor: not-allowed;
}

.primary-button {
    padding: 0 16px;
    background: var(--blue);
    color: white;
    border-color: var(--blue);
}

.secondary-button {
    padding: 0 14px;
    background: white;
    color: var(--text);
    border-color: var(--line);
}

.icon-button {
    width: 40px;
    background: white;
    color: var(--text);
    border-color: var(--line);
}

svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.button-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(29, 29, 31, 0.18);
    border-top-color: var(--text);
    border-radius: 999px;
    animation: spin 0.8s linear infinite;
}

.secondary-button .button-spinner {
    border-color: rgba(29, 29, 31, 0.18);
    border-top-color: var(--text);
}

.secondary-button.is-loading .button-icon,
.primary-button.is-loading .button-icon {
    display: none;
}

.secondary-button.is-loading .button-spinner,
.primary-button.is-loading .button-spinner {
    display: inline-block;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.dashboard-summary,
.order-card,
.list-panel,
.table-wrap,
.supplier-card,
.settings-form,
.events-list {
    background: var(--panel);
    border: 1px solid rgba(215, 215, 220, 0.75);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.dashboard-summary {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 14px;
    margin-bottom: 20px;
    border-radius: 8px;
}

.summary-stat,
.summary-field {
    min-height: 62px;
    border-radius: 8px;
    background: rgba(245, 245, 247, 0.95);
    padding: 10px 12px;
}

.summary-stat {
    min-width: 112px;
}

.summary-stat span,
.summary-field span {
    color: var(--muted);
    font-size: 13px;
}

.field-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.help-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    border: 1px solid rgba(111, 111, 118, 0.35);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.85);
    font-size: 11px;
    line-height: 1;
    cursor: help;
}

.help-tip::after {
    content: attr(title);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    z-index: 30;
    width: min(280px, 72vw);
    padding: 9px 10px;
    border-radius: 8px;
    background: rgba(29, 29, 31, 0.96);
    color: #fff;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.help-tip::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(100% + 3px);
    z-index: 31;
    width: 9px;
    height: 9px;
    background: rgba(29, 29, 31, 0.96);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 4px) rotate(45deg);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.help-tip:hover::after,
.help-tip:hover::before,
.help-tip:focus-visible::after,
.help-tip:focus-visible::before {
    opacity: 1;
    transform: translate(-50%, 0);
}

.barcode-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.barcode-tooltip-bubble {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    z-index: 30;
    width: max-content;
    max-width: min(280px, 72vw);
    padding: 9px 10px;
    border-radius: 8px;
    background: rgba(29, 29, 31, 0.96);
    color: #fff;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.barcode-tooltip::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(100% + 3px);
    z-index: 31;
    width: 9px;
    height: 9px;
    background: rgba(29, 29, 31, 0.96);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 4px) rotate(45deg);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.barcode-tooltip:hover .barcode-tooltip-bubble,
.barcode-tooltip:focus-visible .barcode-tooltip-bubble,
.barcode-tooltip:hover::before,
.barcode-tooltip:focus-visible::before {
    opacity: 1;
    transform: translate(-50%, 0);
}

.summary-stat strong {
    display: block;
    margin-top: 6px;
    font-size: 20px;
    line-height: 1.1;
}

.summary-stat.accent strong {
    color: var(--green);
}

.summary-field {
    display: grid;
    gap: 6px;
    min-width: 150px;
}

.summary-check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 62px;
    border-radius: 8px;
    background: rgba(245, 245, 247, 0.95);
    padding: 10px 12px;
    min-width: 180px;
    color: var(--muted);
    font-size: 13px;
}

.summary-check input {
    margin: 0;
}

.summary-field input {
    min-height: 34px;
    padding: 0 10px;
}

.summary-button {
    min-width: 126px;
    min-height: 62px;
}

.order-tabs-shell,
.order-panel {
    background: var(--panel);
    border: 1px solid rgba(215, 215, 220, 0.75);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    border-radius: 8px;
}

.order-tabs-shell {
    overflow: visible;
}

.order-tabs {
    display: flex;
    gap: 8px;
    padding: 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    background: rgba(251, 251, 253, 0.92);
}

.order-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--order-tab-color, white);
    color: #3a3a3c;
    white-space: nowrap;
}

.order-tab.active {
    border-color: rgba(29, 29, 31, 0.35);
    box-shadow: inset 0 0 0 1px rgba(29, 29, 31, 0.12);
    color: #1d1d1f;
}

.order-tab-badge {
    min-width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    padding: 0 6px;
    font-size: 12px;
    background: rgba(29, 29, 31, 0.08);
    color: inherit;
}

.order-tab.active .order-tab-badge {
    background: rgba(29, 29, 31, 0.12);
}

.order-panel {
    border: 0;
    box-shadow: none;
    border-radius: 0;
    padding: 16px;
}

.order-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.order-panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.order-panel-title {
    display: grid;
    gap: 4px;
}

.order-panel-title h3 {
    margin: 0;
    font-size: 18px;
}

.order-panel-meta {
    color: var(--muted);
    font-size: 13px;
}

.order-table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: visible;
}

.order-table {
    width: 100%;
    border-collapse: collapse;
}

.order-table th,
.order-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}

.order-table tbody tr.is-alt-row {
    background: #f3f4f6;
}

.order-table .folder-cell,
.order-table th:first-child {
    white-space: nowrap;
}

.order-table .name-cell {
    min-width: 260px;
}

.order-empty {
    padding: 14px 2px 4px;
    color: var(--muted);
    font-size: 14px;
}

.order-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 12px;
}

.pagination-button {
    min-width: 96px;
}

.order-pagination-meta {
    color: var(--muted);
    font-size: 13px;
}

.orders-grid,
.supplier-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.order-card,
.supplier-card {
    border-radius: 8px;
    padding: 18px;
}

.order-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.order-head h3,
.supplier-card h3 {
    margin: 0;
    font-size: 18px;
}

.status {
    align-self: flex-start;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    color: white;
}

.status.ready {
    background: var(--green);
}

.status.draft {
    background: var(--amber);
}

.order-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.order-summary div {
    border-radius: 8px;
    background: #f5f5f7;
    padding: 10px;
}

.order-summary span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.item-list {
    display: grid;
    gap: 8px;
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
}

.item-list li,
.shop-row,
.event-row {
    display: grid;
    gap: 4px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.item-list li:last-child,
.shop-row:last-child,
.event-row:last-child {
    border-bottom: 0;
}

.item-meta,
.supplier-meta {
    color: var(--muted);
    font-size: 13px;
}

.section-head {
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-head.compact {
    margin-bottom: 0;
}

.filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.view-mode-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.view-mode-switch .secondary-button.active {
    background: #1d1d1f;
    border-color: #1d1d1f;
    color: white;
}

.compact-button {
    min-height: 36px;
    padding: 0 12px;
    white-space: nowrap;
}

.compact-select {
    min-height: 36px;
    min-width: 190px;
    max-width: 260px;
}

input,
select {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    padding: 0 12px;
    color: var(--text);
}

.list-panel,
.table-wrap,
.events-list {
    border-radius: 8px;
    padding: 10px 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 4;
    background: rgba(251, 251, 253, 0.98);
    backdrop-filter: blur(14px);
}

.folder-group-row td {
    padding: 0;
    background: #f8f8fa;
}

.folder-group-row.is-inventory-controlled td {
    background: var(--inventory-control-folder-color, #d8ecff);
}

.folder-group-content {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
}

.folder-toggle-button {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 12px 0 calc(12px + (var(--folder-depth, 0) * 18px));
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: left;
}

.folder-control-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    padding: 0 12px 0 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease;
}

.folder-group-row:hover .folder-control-check,
.folder-control-check.is-enabled,
.folder-control-check:focus-within {
    opacity: 1;
    pointer-events: auto;
}

.folder-control-check input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.folder-toggle-caret {
    width: 14px;
    color: var(--muted);
    flex: 0 0 14px;
}

.folder-toggle-label {
    min-width: 0;
}

.folder-toggle-spinner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    margin-left: 2px;
}

.folder-toggle-spinner .button-spinner {
    width: 14px;
    height: 14px;
}

.tree-loading-row td {
    color: var(--muted);
    background: #fbfbfd;
}

.tree-loading-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
}

.tree-loading-indicator .button-spinner {
    width: 14px;
    height: 14px;
}

.catalog-item-cell {
    padding-left: calc(12px + (var(--item-depth, 0) * 18px));
}

tbody tr.catalog-item-row.is-alt-row {
    background: #f3f4f6;
}

.table-sort-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: inherit;
}

.table-sort-button.active {
    color: var(--text);
}

.actions-column {
    width: 192px;
}

.table-actions-cell {
    width: 192px;
    text-align: right;
}

.table-action-button {
    width: 34px;
    min-height: 34px;
    height: 34px;
    padding: 0;
}

.table-action-button.is-pending-hide {
    background: #f3e7a2;
    border-color: #d9bf53;
    color: #7a5b00;
}

.action-buttons {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.muted-dash {
    color: var(--muted);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(29, 29, 31, 0.28);
    backdrop-filter: blur(6px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(960px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 18px;
    border-radius: 8px;
    background: var(--panel);
    border: 1px solid rgba(215, 215, 220, 0.75);
    box-shadow: var(--shadow);
}

.modal-head,
.modal-filters,
.sales-log-summary {
    display: flex;
    gap: 12px;
}

.modal-head {
    align-items: start;
    justify-content: space-between;
    margin-bottom: 14px;
}

.modal-head h3 {
    margin: 0 0 4px;
    font-size: 20px;
}

.modal-filters,
.sales-log-summary {
    align-items: end;
    flex-wrap: wrap;
}

.modal-filters {
    margin-bottom: 12px;
}

.modal-filters label {
    min-width: 160px;
}

.sales-log-summary {
    margin-bottom: 12px;
}

.sales-log-table-wrap {
    padding: 0;
    overflow: visible;
}

.source-modal-card {
    width: min(1080px, calc(100vw - 32px));
}

.order-info-card {
    width: min(880px, calc(100vw - 32px));
}

.order-info-flow {
    display: grid;
    gap: 10px;
}

.order-info-section {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(247, 247, 249, 0.82);
}

.order-info-section h4 {
    margin: 0 0 8px;
    font-size: 15px;
}

.order-info-section p,
.order-info-section ul {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.order-info-section p + p,
.order-info-section p + ul,
.order-info-section ul + p {
    margin-top: 8px;
}

.order-info-section ul {
    padding-left: 18px;
}

.order-info-section li + li {
    margin-top: 4px;
}

.source-meta {
    margin-bottom: 12px;
}

.source-payload {
    margin: 0;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #f7f7f9;
    color: var(--text);
    font: 12px/1.5 Consolas, "SFMono-Regular", Menlo, monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: min(68vh, 760px);
    overflow: auto;
}

.source-payload-error {
    color: var(--red);
}

.inline-form,
.settings-layout {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.inline-form {
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    align-items: center;
}

.settings-layout {
    grid-template-columns: minmax(360px, 0.9fr) minmax(480px, 1.1fr);
    align-items: start;
    gap: 14px;
}

.settings-form {
    border-radius: 8px;
    padding: 14px;
    display: grid;
    gap: 10px;
    align-content: start;
}

.settings-form input,
.settings-form select {
    min-height: 36px;
    padding: 0 10px;
}

.settings-form .primary-button,
.settings-form .secondary-button {
    min-height: 38px;
}

.settings-form .section-head {
    margin: 2px 0 0;
}

.settings-form .section-head h3 {
    margin: 0;
    font-size: 16px;
}

.kontur-load-form,
.kontur-key-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto minmax(180px, 0.75fr);
    gap: 8px;
    align-items: end;
}

.kontur-key-form {
    grid-template-columns: minmax(130px, 0.55fr) minmax(220px, 1fr) auto;
}

#konturSyncMeta {
    align-self: center;
    line-height: 1.35;
}

#konturError {
    grid-column: 1 / -1;
}

.compact-table-wrap table {
    min-width: 420px;
}

.compact-table-wrap {
    padding: 6px 10px;
}

.compact-table-wrap th,
.compact-table-wrap td {
    padding: 9px 10px;
}

.order-columns-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: stretch;
}

.order-columns-item {
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8f8fa;
}

.order-columns-item span {
    line-height: 1.35;
}

.kontur-form {
    align-content: start;
}

.kontur-form label {
    max-width: none;
}

.color-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

#settingsForm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-row: 1 / span 3;
}

#settingsForm label {
    justify-items: start;
    align-content: start;
}

#settingsForm input,
#settingsForm select {
    width: min(100%, 250px);
    justify-self: start;
}

#settingsForm > label,
#settingsForm > .color-row,
#settingsForm > .checkline,
#settingsForm > button {
    min-width: 0;
}

#settingsForm > .color-row,
#settingsForm > label:has([name="dashboard_price_mode"]),
#settingsForm > label:has([name="telegram_bot_token"]),
#settingsForm > .checkline,
#settingsForm > button {
    grid-column: 1 / -1;
}

#settingsForm > button {
    justify-self: start;
    min-width: 160px;
}

#telegramForm {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    align-items: end;
}

#telegramForm button {
    align-self: end;
}

.kontur-form,
#telegramForm,
#view-settings .settings-layout > section.settings-form:not(.kontur-form) {
    grid-column: 2;
}

.kontur-form {
    grid-row: 1;
}

#telegramForm {
    grid-row: 2;
}

#view-settings .settings-layout > section.settings-form:not(.kontur-form) {
    grid-row: 3;
}

label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 13px;
}

.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.compact-checkline {
    min-height: 36px;
    padding: 0 4px;
    white-space: nowrap;
}

.hidden {
    display: none;
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    max-width: min(420px, calc(100vw - 48px));
    border-radius: 8px;
    padding: 12px 14px;
    background: #1d1d1f;
    color: white;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: 160ms ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.login-body {
    display: grid;
    place-items: center;
}

.login-shell {
    width: min(440px, calc(100vw - 36px));
}

.login-panel {
    padding: 32px;
    border-radius: 8px;
    background: white;
    box-shadow: var(--shadow);
}

.login-panel h1 {
    margin-top: 18px;
}

.login-panel p {
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

.auth-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 22px;
}

.auth-link {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #f5f5f7;
    color: var(--muted);
    text-decoration: none;
}

.auth-link.active {
    background: #1d1d1f;
    border-color: #1d1d1f;
    color: white;
}

.form-error {
    color: var(--red);
    font-size: 14px;
}

.auth-footnote {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.inline-error {
    color: var(--red);
    font-size: 13px;
}

.danger-button {
    color: var(--red);
    border-color: rgba(215, 0, 21, 0.24);
    background: #fff6f7;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        padding: 14px;
    }

    .nav {
        grid-auto-flow: column;
        grid-auto-columns: minmax(120px, 1fr);
        overflow-x: auto;
    }

    .nav-item {
        min-width: 120px;
    }

    .logout-link {
        margin-top: 0;
    }

    .main {
        padding: 20px 14px;
    }

    .topbar {
        display: grid;
    }

    .inline-form {
        grid-template-columns: 1fr;
    }

    .kontur-load-form,
    .kontur-key-form {
        grid-template-columns: 1fr;
    }

    .settings-layout,
    #settingsForm,
    #telegramForm {
        grid-template-columns: 1fr;
    }

    #settingsForm,
    .kontur-form,
    #telegramForm,
    #view-settings .settings-layout > section.settings-form:not(.kontur-form) {
        grid-column: 1;
        grid-row: auto;
    }

    #settingsForm > .color-row,
    #settingsForm > label:has([name="dashboard_price_mode"]),
    #settingsForm > label:has([name="telegram_bot_token"]),
    #settingsForm > .checkline,
    #settingsForm > button {
        grid-column: 1;
    }

    .color-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    h1 {
        font-size: 28px;
    }

    .dashboard-summary,
    .orders-grid,
    .supplier-grid {
        grid-template-columns: 1fr;
    }

    .toolbar,
    .filters {
        width: 100%;
    }

    .dashboard-summary > * {
        width: 100%;
    }

    .order-panel-head {
        display: grid;
    }

    .toolbar > *,
    .filters > * {
        flex: 1 1 auto;
    }
}
