@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;700&display=swap");

:root {
    color-scheme: light;
    --bg: #eef4ff;
    --panel: rgba(248, 251, 255, 0.88);
    --panel-strong: rgba(255, 255, 255, 0.96);
    --panel-soft: #f3f8ff;
    --text: #132033;
    --muted: #607086;
    --accent: #2563eb;
    --accent-strong: #1d4ed8;
    --accent-soft: #dbeafe;
    --accent-soft-strong: #bfdbfe;
    --success-soft: #dcfce7;
    --success-text: #166534;
    --warning-soft: #fef3c7;
    --warning-text: #92400e;
    --danger-soft: #fee2e2;
    --danger-text: #b42318;
    --border: #d4def0;
    --border-strong: #bed0ec;
    --shadow: 0 30px 80px rgba(37, 99, 235, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    /* Safety: никакой блок не должен скроллить страницу по горизонтали.
       overflow-x: hidden работает во всех браузерах (clip не поддерживается в Safari < 16). */
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
    font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 30%),
        radial-gradient(circle at top right, rgba(96, 165, 250, 0.18), transparent 24%),
        linear-gradient(180deg, #f4f8ff 0%, #edf4ff 48%, #e9f0ff 100%);
}

.shell {
    width: min(1360px, calc(100% - 24px));
    margin: 48px auto;
    padding: 22px;
    border: 1px solid rgba(190, 208, 236, 0.75);
    border-radius: 30px;
    background: var(--panel);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

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

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 720px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.page-title {
    margin: 0;
    font-family: "Space Grotesk", "Avenir Next", sans-serif;
    font-size: clamp(34px, 4vw, 52px);
    line-height: 0.98;
    letter-spacing: -0.03em;
}

.page-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.6;
    max-width: 660px;
}

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

.account-panel {
    display: grid;
    gap: 10px;
    min-width: 220px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(237,244,255,0.94));
    box-shadow: 0 18px 42px rgba(37, 99, 235, 0.08);
}

.account-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.user-chip {
    display: grid;
    gap: 4px;
    color: var(--text);
}

.user-chip strong {
    font-size: 15px;
}

.workspace-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 26px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 18px 42px rgba(37, 99, 235, 0.06);
}

.nav-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.nav-tab {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
}

.nav-tab:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.nav-tab-active {
    border-color: rgba(37, 99, 235, 0.12);
    background: linear-gradient(180deg, rgba(37,99,235,0.12), rgba(191,219,254,0.48));
    color: var(--accent-strong);
}

.analytics-tabs {
    display: flex;
    gap: 6px;
    padding: 4px;
    background: var(--panel);
    border-radius: 16px;
    border: 1px solid var(--border);
    width: fit-content;
}

.analytics-tab {
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
    text-decoration: none;
}

.analytics-tab:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.analytics-tab-active {
    background: var(--accent);
    color: #fff;
}

.analytics-tab-active:hover {
    background: var(--accent-strong);
    color: #fff;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.button,
button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
    opacity: 0.96;
    transform: translateY(-1px);
}

.button-secondary {
    border-color: var(--border);
    background: #ffffff;
    color: var(--text);
}

.button-ghost {
    border-color: var(--border);
    background: transparent;
    color: var(--muted);
}

.button-primary-cta {
    padding-inline: 20px;
    border-color: rgba(37, 99, 235, 0.18);
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 16px 28px rgba(37, 99, 235, 0.22);
}

.button-danger {
    background: #b43b30;
}

.layout-stack {
    display: grid;
    gap: 20px;
}

.content-center {
    min-height: calc(100vh - 220px);
    display: grid;
    place-items: center;
}

.panel {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--panel-strong);
    box-shadow: 0 18px 48px rgba(37, 99, 235, 0.05);
}

.panel-title {
    margin: 0 0 8px;
    font-family: "Space Grotesk", "Avenir Next", sans-serif;
    font-size: 24px;
    letter-spacing: -0.02em;
}

.panel-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.6;
}

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

.stat-card {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(233,242,255,0.94));
    box-shadow: 0 14px 32px rgba(37, 99, 235, 0.07);
}

.stat-label {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 14px;
}

.stat-value {
    font-size: clamp(24px, 3vw, 34px);
    font-weight: 700;
    line-height: 1;
}

.grid-two {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 20px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    width: 100%;
}

.table-wrap::after {
    content: "Прокрутите для просмотра \2192";
    display: none;
    padding: 6px 0;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
}

@media (max-width: 760px) {
    .table-wrap::after {
        display: block;
    }
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(212, 222, 240, 0.9);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

tbody tr:hover td {
    background: rgba(237, 244, 255, 0.72);
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

/* Палитра статусов: один источник для pill / status-button / status-dropdown-item. */
.pill-muted,
.pill-warning,
.status-button-warning,
.status-dropdown-item-warning {
    background: var(--warning-soft);
    color: var(--warning-text);
}

.pill-success,
.status-button-success,
.status-dropdown-item-success {
    background: var(--success-soft);
    color: var(--success-text);
}

.pill-danger,
.status-button-danger,
.status-dropdown-item-danger {
    background: var(--danger-soft);
    color: var(--danger-text);
}

.pill-info,
.status-button-default,
.status-dropdown-item-default,
.status-dropdown-item-info {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.pill-accent,
.status-dropdown-item-accent {
    background: #ede9fe;
    color: #5b21b6;
}

.status-panel {
    display: grid;
    gap: 10px;
    width: 100%;
}

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

.status-actions-row form {
    margin: 0;
}

.status-button {
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 800;
    box-shadow: none;
}

/* Границы для status-button — соответствуют цвету фона. Сам фон задан выше в палитре. */
.status-button-danger { border-color: rgba(180, 35, 24, 0.14); }
.status-button-warning { border-color: rgba(146, 64, 14, 0.14); }
.status-button-success { border-color: rgba(22, 101, 52, 0.14); }
.status-button-default { border-color: rgba(37, 99, 235, 0.14); }

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chip-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.chip-link-active {
    border-color: transparent;
    background: var(--accent);
    color: #fff;
}

.chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    font-size: 12px;
}

.chip-link-active .chip-count {
    background: rgba(255, 255, 255, 0.18);
}

.muted {
    color: var(--muted);
}

.flash-list {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.flash {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 600;
}

.flash.error {
    border-color: #e7b8b1;
    background: var(--danger-soft);
    color: var(--danger-text);
}

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

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

.field {
    display: grid;
    gap: 8px;
}

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

.channel-switch {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.channel-switch-button {
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    color: var(--muted);
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.channel-switch-button-active {
    border-color: rgba(37, 99, 235, 0.16);
    background: var(--accent-soft);
    color: var(--accent-strong);
}

label {
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

.input-compact {
    min-height: 40px;
    padding: 9px 11px;
    border-radius: 12px;
}

.textarea-compact {
    min-height: 64px;
}

.phone-input-group {
    display: flex;
    align-items: stretch;
}

.phone-prefix {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 14px 0 0 14px;
    font-weight: 700;
    font-size: 15px;
    color: var(--muted);
    user-select: none;
}

.phone-input-group .phone-input {
    border-radius: 0 14px 14px 0;
    flex: 1;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(37, 99, 235, 0.14);
    border-color: var(--accent);
}

.errorlist {
    margin: 4px 0 0;
    padding: 6px 10px;
    list-style: none;
    color: var(--danger-text);
    background: var(--danger-soft);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}

.errorlist:empty {
    display: none;
}

.errorlist + input,
.errorlist + select,
.errorlist + textarea,
.field:has(.errorlist li) input,
.field:has(.errorlist li) select,
.field:has(.errorlist li) textarea,
.field:has(.errorlist li) .phone-input-group .phone-input,
.field:has(.errorlist li) .phone-input-group .phone-prefix {
    border-color: var(--danger-text);
}

.items-stack {
    display: grid;
    gap: 10px;
}

.item-row {
    display: grid;
    grid-template-columns: minmax(0, 2.1fr) 104px 116px minmax(0, 1fr) 146px;
    gap: 10px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(244,248,255,0.96));
}

.item-row .field {
    gap: 6px;
}

.item-row label {
    font-size: 12px;
    font-weight: 800;
}

.item-row input,
.item-row select,
.item-row textarea {
    min-height: 40px;
    padding: 9px 11px;
    border-radius: 12px;
}

.product-select {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.line-total-box {
    display: grid;
    gap: 4px;
    align-self: stretch;
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: var(--panel-soft);
}

.line-total-box-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.inline-link-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent-strong);
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.inline-link-button-active {
    color: var(--danger-text);
}

.line-total-value,
.summary-total {
    font-size: 22px;
    font-weight: 700;
}

.item-row .line-total-value,
.item-row .js-unit-price-display {
    font-size: 17px;
    line-height: 1.15;
}

.summary-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(219,234,254,0.92), rgba(255,255,255,0.98));
}

.helper-text {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.action-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.action-row-compact {
    flex-wrap: nowrap;
    gap: 4px;
}

.qty-buttons {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.qty-btn {
    min-height: 28px;
    padding: 2px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-strong);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.qty-btn:hover {
    background: var(--accent-soft);
}

.micro-button {
    min-height: 30px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    min-width: 30px;
    min-height: 30px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.icon-button-danger {
    border-color: rgba(180, 35, 24, 0.14);
    background: var(--danger-soft);
    color: var(--danger-text);
}

.icon-link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    min-width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
    color: var(--text);
    box-shadow: none;
}

.icon-link-button:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.icon-link-button svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.custom-price-box {
    margin-top: -2px;
    padding: 12px;
    border: 1px dashed rgba(37, 99, 235, 0.18);
    border-radius: 14px;
    background: rgba(239, 246, 255, 0.7);
}

.custom-price-grid {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 10px;
}

.empty-note {
    padding: 16px;
    border: 1px dashed var(--border);
    border-radius: 16px;
    color: var(--muted);
    background: rgba(243, 248, 255, 0.8);
}

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

.quick-grid-fit {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.quick-grid-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.quick-card {
    display: grid;
    gap: 12px;
    min-width: 0;
    align-content: start;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
}

button.quick-card {
    width: 100%;
    min-height: auto;
    padding: 16px;
    align-items: flex-start;
    justify-content: flex-start;
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    text-align: left;
    box-shadow: none;
}

.quick-card-compact {
    gap: 8px;
    padding: 12px;
    border-radius: 14px;
}

.quick-card-person {
    grid-template-rows: auto 1fr auto;
}

.quick-card-product {
    grid-template-rows: 1fr auto;
    align-content: start;
}

button.quick-card-compact {
    padding: 12px;
}

button.quick-card:hover {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(237,244,255,0.96));
}

.quick-card-title {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.quick-card-compact .quick-card-title {
    margin-bottom: 2px;
    font-size: 14px;
    line-height: 1.3;
    display: -webkit-box;
    max-height: calc(1.3em * 2);
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.quick-card-meta {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.quick-card-compact .quick-card-meta {
    margin-bottom: 4px;
    font-size: 12px;
    line-height: 1.4;
}

.quick-card-action {
    width: 100%;
    margin-top: auto;
}

.quick-card-action-compact {
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 12px;
}

.quick-card-tag {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin-top: auto;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 11px;
    font-weight: 800;
}

.quick-card-action-tag {
    cursor: pointer;
}

.quick-search-panel .panel-subtitle {
    font-size: 13px;
    line-height: 1.45;
}

.toolbar-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-header .panel-title {
    margin-bottom: 6px;
}

.section-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.stack-tight {
    display: grid;
    gap: 10px;
}

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

.order-card {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(241,247,255,0.96));
    box-shadow: 0 14px 34px rgba(37, 99, 235, 0.06);
}

.order-card-header,
.order-card-footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.order-card-footer {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(212, 222, 240, 0.9);
    align-items: flex-end;
}

.order-card-compact {
    display: grid;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 18px;
}

.order-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.order-card-main {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.order-number {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-family: "Space Grotesk", "Avenir Next", sans-serif;
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.order-number-compact {
    margin-bottom: 0;
    font-size: 20px;
    line-height: 1.15;
    flex-wrap: wrap;
}

.order-customer-inline {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
}

.order-meta-inline {
    display: flex;
    gap: 8px 12px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.order-meta-inline span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 4px 10px;
    border: 1px solid rgba(212, 222, 240, 0.78);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.76);
    white-space: nowrap;
}

.order-toolbar-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.order-note-inline {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.order-note-inline strong {
    color: var(--danger-text);
}

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

.meta-card {
    display: grid;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid rgba(212, 222, 240, 0.85);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.85);
}

.meta-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.meta-value {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
}

.meta-note {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.amount-display {
    display: grid;
    gap: 8px;
    min-width: 150px;
    padding: 16px 18px;
    border: 1px solid rgba(37, 99, 235, 0.14);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(219,234,254,0.96), rgba(255,255,255,0.96));
    text-align: right;
}

.amount-display-compact {
    min-width: 128px;
    padding: 10px 12px;
    border-radius: 14px;
    gap: 4px;
}

.amount-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.amount-value {
    font-family: "Space Grotesk", "Avenir Next", sans-serif;
    font-size: clamp(26px, 3vw, 34px);
    font-weight: 700;
    letter-spacing: -0.03em;
}

.amount-value-compact {
    font-size: 22px;
}

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

.order-actions-compact {
    gap: 8px;
    justify-content: flex-start;
}

/* Базовый компактный размер для всех плотных кнопок. */
.button-compact,
.button-status-next {
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

/* Акцентный вариант компактной кнопки: "Следующий статус →". */
.button-status-next {
    padding: 8px 14px;
    background: var(--accent);
    color: #fff;
    border: none;
}

.button-status-next:hover {
    background: var(--accent-strong);
}

.cancel-box {
    padding: 14px;
    border: 1px solid rgba(228, 89, 72, 0.16);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(254,242,242,0.96));
}

.cancel-box summary {
    cursor: pointer;
}

.cancel-box summary::-webkit-details-marker {
    display: none;
}

.cancel-box[open] summary {
    margin-bottom: 12px;
}

.summary-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.order-status-zone {
    display: flex;
    justify-content: flex-end;
    min-width: 0;
}

.status-actions-row-compact {
    justify-content: flex-end;
    gap: 6px;
}

.status-actions-row-compact .status-button {
    min-height: 34px;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 12px;
}

.order-status-note {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-align: left;
}

.status-dropdown {
    position: relative;
}

.status-dropdown summary {
    list-style: none;
}

.status-dropdown summary::-webkit-details-marker {
    display: none;
}

.status-dropdown[open] summary {
    border-color: rgba(37, 99, 235, 0.18);
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.status-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    display: grid;
    gap: 6px;
    min-width: 170px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 20px 40px rgba(19, 32, 51, 0.12);
}

.status-dropdown-menu form {
    margin: 0;
}

.status-dropdown-item {
    width: 100%;
    min-height: 36px;
    justify-content: flex-start;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    box-shadow: none;
}

/* Цвета status-dropdown-item-* заданы общей палитрой статусов выше. */

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

.info-card {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(241,247,255,0.96));
}

.info-list {
    display: grid;
    gap: 12px;
}

.info-item {
    display: grid;
    gap: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(212, 222, 240, 0.9);
}

.info-item:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.positions-table th:first-child,
.positions-table td:first-child {
    padding-left: 0;
}

.positions-table th:last-child,
.positions-table td:last-child {
    padding-right: 0;
}

.panel-soft {
    padding: 18px;
    border: 1px solid rgba(212, 222, 240, 0.85);
    border-radius: 18px;
    background: rgba(243, 248, 255, 0.84);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(212, 222, 240, 0.9);
}

.pagination-info {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.pagination-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.page-link-active {
    border-color: rgba(37, 99, 235, 0.16);
    background: linear-gradient(180deg, rgba(37,99,235,0.12), rgba(191,219,254,0.48));
    color: var(--accent-strong);
}

.page-link-muted {
    color: var(--muted);
}

.page-gap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    color: var(--muted);
    font-size: 15px;
    font-weight: 800;
}

.table-item-title {
    display: grid;
    gap: 4px;
}

.table-item-title strong {
    font-size: 15px;
}

.mobile-divider {
    display: none;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
    gap: 20px;
    align-items: start;
}

.sidebar-stack {
    display: grid;
    gap: 16px;
    position: sticky;
    top: 24px;
}

.summary-card {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(237,244,255,0.94));
    box-shadow: 0 16px 36px rgba(37, 99, 235, 0.08);
}

.summary-card-primary {
    background: linear-gradient(180deg, rgba(219,234,254,0.92), rgba(255,255,255,0.98));
    border-color: rgba(37, 99, 235, 0.16);
}

.summary-card-title {
    margin: 0 0 6px;
    font-family: "Space Grotesk", "Avenir Next", sans-serif;
    font-size: 22px;
    letter-spacing: -0.02em;
}

.summary-card-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.summary-metrics {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.summary-metric {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(212, 222, 240, 0.9);
}

.summary-metric:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.summary-metric-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.summary-metric-value {
    text-align: right;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
}

.summary-big-total {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(212, 222, 240, 0.9);
}

.summary-receipt {
    margin-top: 18px;
    padding: 14px;
    border: 1px solid rgba(212, 222, 240, 0.92);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
}

.summary-receipt-title {
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.summary-receipt-items {
    display: grid;
    gap: 8px;
}

.summary-receipt-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 1px dashed rgba(212, 222, 240, 0.92);
}

.summary-receipt-row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.summary-receipt-main {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.summary-receipt-name {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.summary-receipt-qty {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.summary-receipt-price {
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
}

.summary-receipt-empty {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.summary-big-total .amount-value {
    font-size: clamp(28px, 3vw, 36px);
}

.section-stack {
    display: grid;
    gap: 20px;
}

.panel-grid-compact {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

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

.customer-main-grid {
    display: grid;
    grid-template-columns: minmax(230px, 1.1fr) minmax(180px, 0.9fr);
    gap: 16px;
}

.inline-helper {
    margin-top: -6px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.item-row {
    grid-template-columns: minmax(0, 2.2fr) minmax(120px, 0.75fr) minmax(150px, 0.95fr) minmax(0, 1.2fr) minmax(160px, 1fr);
    gap: 14px;
}

.line-total-box {
    min-height: 100%;
    justify-content: space-between;
}

.sticky-actions .button {
    width: 100%;
}

.summary-metric-value {
    overflow-wrap: anywhere;
}

.form-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.sticky-actions {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.field-hidden {
    display: none;
}

.hint-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.hint-item {
    padding: 14px 16px;
    border: 1px solid rgba(212, 222, 240, 0.9);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.86);
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

@media (max-width: 1040px) {
    .stats-grid,
    .field-grid-3,
    .grid-two,
    .quick-grid,
    .meta-grid,
    .info-grid,
    .workspace-grid,
    .panel-grid-compact,
    .compact-grid-3,
    .customer-main-grid {
        grid-template-columns: 1fr 1fr;
    }

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

@media (max-width: 760px) {
    .shell {
        margin: 20px auto;
        padding: 18px;
    }

    .topbar,
    .summary-panel,
    .workspace-nav {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-actions,
    .nav-actions {
        justify-content: stretch;
    }

    .field-grid,
    .field-grid-3,
    .grid-two,
    .stats-grid,
    .quick-grid,
    .item-row,
    .custom-price-grid,
    .meta-grid,
    .info-grid,
    .workspace-grid,
    .panel-grid-compact,
    .compact-grid-3,
    .customer-main-grid {
        grid-template-columns: 1fr;
    }

    .order-card-header,
    .order-card-top,
    .order-card-footer,
    .section-header,
    .pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .amount-display,
    .order-actions,
    .order-status-zone,
    .pagination-links {
        width: 100%;
        text-align: left;
        justify-content: flex-start;
    }

    .order-meta-inline span {
        white-space: normal;
    }

    .order-status-note {
        text-align: left;
    }

    .sidebar-stack {
        position: static;
    }

    .status-dropdown-menu {
        position: static;
        box-shadow: none;
        border: 1px solid var(--border);
        margin-top: 8px;
    }

    .mobile-divider {
        display: block;
    }
}

/* Узкая мобилка: iPhone SE / Android mini (360-480px). */
@media (max-width: 480px) {
    /* Гарантированный столбик для всех сеток: через flex, не зависим от grid-template-columns. */
    .stats-grid,
    .field-grid,
    .field-grid-3,
    .grid-two,
    .quick-grid,
    .item-row,
    .custom-price-grid,
    .meta-grid,
    .info-grid,
    .workspace-grid,
    .panel-grid-compact,
    .compact-grid-3,
    .customer-main-grid {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
    }

    .stats-grid > *,
    .field-grid > *,
    .field-grid-3 > *,
    .grid-two > *,
    .quick-grid > *,
    .item-row > *,
    .custom-price-grid > *,
    .meta-grid > *,
    .info-grid > *,
    .workspace-grid > *,
    .panel-grid-compact > *,
    .compact-grid-3 > *,
    .customer-main-grid > * {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* Железобетон: ничего в иерархии не должно быть шире viewport. */
    .shell,
    .topbar,
    .workspace-nav,
    .layout-stack,
    .panel,
    .panel-soft,
    .stats-grid,
    .field-grid,
    .field-grid-3,
    .grid-two,
    .quick-grid,
    .summary-panel,
    .order-list,
    .order-card,
    .order-card-top,
    .order-toolbar-inline,
    .order-meta-inline,
    .order-actions,
    .section-header {
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .shell {
        width: 100%;
        margin: 0;
        padding: 14px;
        border: none;
        border-radius: 0;
    }

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

    .panel-title {
        font-size: 20px;
    }

    .page-title {
        font-size: 28px;
        line-height: 1.05;
    }

    .page-subtitle {
        font-size: 14px;
    }

    .brand-mark {
        font-size: 11px;
        padding: 5px 10px;
    }

    .topbar,
    .workspace-nav {
        padding: 12px;
        border-radius: 16px;
        margin-bottom: 16px;
        gap: 12px;
    }

    .account-panel {
        min-width: 0;
        padding: 12px 14px;
        border-radius: 16px;
    }

    .stats-grid,
    .field-grid,
    .field-grid-3 {
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 26px;
    }

    .section-header {
        gap: 10px;
    }

    /* Таблицы на узких: сжимаем ячейки, но даём таблице расти в ширину —
       тогда `.table-wrap` получает горизонтальный скролл внутри себя. */
    th, td {
        padding: 10px 8px;
        font-size: 13px;
    }

    .table-wrap table {
        min-width: 540px;
    }

    /* Фильтры "Применить/Сбросить": обе кнопки одинаковой ширины и на отдельной строке. */
    .flex-row-bottom {
        flex-direction: column;
        align-items: stretch;
    }
    .flex-row-bottom .button,
    .flex-row-bottom .button-secondary {
        width: 100%;
    }

    /* Action-row в строках таблиц — вертикально, чтобы ничего не торчало. */
    .flex-row,
    .flex-row-tight,
    .flex-row-bottom {
        gap: 8px;
    }

    .pill {
        font-size: 11px;
        padding: 2px 8px;
    }

    /* Пагинация: не растягиваем, но разрешаем перенос. */
    .pagination-links {
        flex-wrap: wrap;
        gap: 6px;
    }
}

/* Единый focus-visible для клавиатурной навигации. */
.button:focus-visible,
.button-secondary:focus-visible,
.button-compact:focus-visible,
.button-status-next:focus-visible,
.icon-button:focus-visible,
.icon-link-button:focus-visible,
.channel-switch-button:focus-visible,
.status-dropdown-item:focus-visible,
.status-dropdown summary:focus-visible,
.quick-card:focus-visible,
.inline-link-button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Flash-уведомления (см. static/js/flash.js). */
.flash-stack {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

.flash-toast {
    min-width: 220px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(15, 35, 90, 0.16);
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    pointer-events: auto;
    animation: flash-toast-enter 180ms ease;
}

.flash-toast-error {
    background: var(--danger-soft);
    color: var(--danger-text);
    border-color: rgba(180, 35, 24, 0.2);
}

.flash-toast-success {
    background: rgba(22, 163, 74, 0.08);
    color: #166534;
    border-color: rgba(22, 163, 74, 0.2);
}

.flash-toast-leaving {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 180ms ease, transform 180ms ease;
}

@keyframes flash-toast-enter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ========== Layout utilities (вместо inline style) ========== */
.inline-form { margin: 0; }
.button-full { width: 100%; }
.button-ghost-danger { color: var(--danger-text); }
.hidden-checkbox { display: none; }

.flex-row { display: flex; gap: 12px; flex-wrap: wrap; }
.flex-row-tight { display: flex; gap: 8px; flex-wrap: wrap; }
.flex-row-bottom { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }

.spaced-top-sm { margin-top: 8px; }
.spaced-top-md { margin-top: 12px; }
.spaced-top-lg { margin-top: 18px; }
.spaced-bottom-sm { margin-bottom: 8px; }

.narrow-form { max-width: 820px; }
.narrow-form-wide { max-width: 860px; }
.login-container { width: min(560px, 100%); }

.status-side { min-width: min(100%, 360px); }
.status-dropdown-spaced { margin-top: 8px; }
.status-dropdown-toggle { font-size: 12px; }
.panel-soft-body { margin-top: 8px; }
.stat-value-sm { font-size: 20px; }

/* Глобально: disabled для любых интерактивных кнопок. */
.button:disabled,
.button-secondary:disabled,
.button-compact:disabled,
.button-status-next:disabled,
.icon-button:disabled,
.qty-btn:disabled,
.channel-switch-button:disabled,
.inline-link-button:disabled,
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Модальные окна (см. static/js/modal.js). */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 35, 90, 0.48);
    backdrop-filter: blur(4px);
    animation: modal-fade 160ms ease;
}

.modal {
    width: min(440px, 100%);
    padding: 22px;
    border-radius: 20px;
    background: var(--panel-strong);
    box-shadow: 0 40px 80px rgba(15, 35, 90, 0.28);
    animation: modal-scale 180ms ease;
}

.modal-title {
    margin: 0 0 8px;
    font-family: "Space Grotesk", "Avenir Next", sans-serif;
    font-size: 20px;
    letter-spacing: -0.02em;
}

.modal-body {
    margin: 0 0 14px;
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

.modal-input {
    width: 100%;
    min-height: 86px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    font: inherit;
    font-size: 15px;
    resize: vertical;
}

.modal-input:focus {
    outline: 2px solid rgba(37, 99, 235, 0.14);
    border-color: var(--accent);
}

.modal-input-error {
    border-color: var(--danger-text);
    background: var(--danger-soft);
}

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

.modal-actions .button {
    min-width: 120px;
}

@keyframes modal-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modal-scale {
    from { opacity: 0; transform: scale(0.96) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 480px) {
    .modal {
        padding: 18px;
        border-radius: 16px;
    }
    .modal-actions .button {
        width: 100%;
        min-width: 0;
    }
}

/* ===== Farm map ===== */

.farm-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.farm-role {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid var(--border);
    background: var(--panel-soft);
    color: var(--muted);
}

.farm-role-empty     { background: #e5e7eb; color: #374151; border-color: #d1d5db; }
.farm-role-breeding  { background: #bbf7d0; color: #14532d; border-color: #16a34a; }
.farm-role-colony    { background: #99f6e4; color: #134e4a; border-color: #0d9488; }
.farm-role-grow_out  { background: #bae6fd; color: #0c4a6e; border-color: #0284c7; }
.farm-role-selection { background: #fde68a; color: #78350f; border-color: #ca8a04; }
.farm-role-culture   { background: #ddd6fe; color: #4c1d95; border-color: #7c3aed; }
.farm-role-quarantine{ background: #fecaca; color: #7f1d1d; border-color: #dc2626; }
.farm-role-demo      { background: #f5d0fe; color: #701a75; border-color: #c026d3; }
.farm-role-test      { background: #fed7aa; color: #7c2d12; border-color: #ea580c; }
.farm-role-non_grade { background: #cbd5e1; color: #1e293b; border-color: #475569; }

.farm-rack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.farm-rack--amano {
    border-color: #ddd6fe;
    background: linear-gradient(180deg, #faf5ff 0%, var(--panel-strong) 100%);
}

.farm-rack__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.farm-levels {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.farm-level {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 14px;
    align-items: stretch;
}

.farm-level__label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--muted);
    background: var(--panel-soft);
    border: 1px dashed var(--border);
    border-radius: 14px;
    padding: 8px;
    font-size: 13px;
}

.farm-level__tanks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}

.farm-tank {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel-strong);
    text-decoration: none;
    color: inherit;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    min-height: 88px;
}

.farm-tank:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.10);
    border-color: var(--border-strong);
}

.farm-tank__head {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
}

.farm-tank__code {
    font-weight: 700;
    letter-spacing: 0.04em;
}

.farm-tank__title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.25;
}

.farm-tank__role {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.farm-tank__age,
.farm-tank__headcount,
.farm-tank__notes {
    font-size: 12px;
    color: var(--muted);
}

.farm-tank__headcount {
    font-weight: 600;
}

.farm-tank__alert {
    margin-top: 2px;
    font-size: 12px;
    font-weight: 600;
}

/* Роли → контрастная заливка плитки (используется, если у вида НЕ задан color_hex) */
.farm-tank--empty     { background: #f3f4f6; border-color: #d1d5db; }
.farm-tank--breeding  { background: #bbf7d0; border-color: #16a34a; }
.farm-tank--colony    { background: #99f6e4; border-color: #0d9488; }
.farm-tank--grow_out  { background: #bae6fd; border-color: #0284c7; }
.farm-tank--selection { background: #fde68a; border-color: #ca8a04; }
.farm-tank--culture   { background: #ddd6fe; border-color: #7c3aed; }
.farm-tank--quarantine{ background: #fecaca; border-color: #dc2626; }
.farm-tank--demo      { background: #f5d0fe; border-color: #c026d3; }
.farm-tank--test      { background: #fed7aa; border-color: #ea580c; }
.farm-tank--non_grade { background: #cbd5e1; border-color: #475569; }

/* Аквариум с привязанным видом — цвет вида перекрывает роль, роль остаётся в виде левой полосы */
.farm-tank--colored {
    border-left-width: 6px;
    border-left-style: solid;
}

/* Алерты перебивают фон */
.farm-tank--warn {
    background: #fef9c3;
    border-color: #fde047;
}
.farm-tank--warn .farm-tank__alert { color: #a16207; }

.farm-tank--critical {
    background: #fee2e2;
    border-color: #fca5a5;
}
.farm-tank--critical .farm-tank__alert { color: #b91c1c; }

/* Форма редактирования */
.farm-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

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

.farm-form .field-wide { grid-column: 1 / -1; }

.farm-form__section {
    border: 1px solid var(--border);
    background: var(--panel-soft);
    border-radius: 16px;
    padding: 16px;
}

.farm-form__section legend {
    font-weight: 600;
    padding: 0 6px;
    color: var(--accent);
}

.farm-form__amano {
    border-color: #ddd6fe;
    background: #faf5ff;
}

.farm-form__amano legend {
    color: #6d28d9;
}

.farm-form__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .farm-level {
        grid-template-columns: 64px 1fr;
    }
    .farm-level__tanks {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    }
    .farm-form__grid {
        grid-template-columns: 1fr;
    }
}
