* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f3f4f6;
    color: #111827;
    font-size: 14px;
}

.hidden { display: none !important; }

/* ============ Login page ============ */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(135deg, #1f2937 0%, #2563eb 100%);
}
.login-box {
    background: #fff; padding: 32px 40px; border-radius: 10px;
    width: 360px; max-width: 90vw; box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.login-box h1 { margin: 0; font-size: 22px; }
.login-box .subtitle { color: #6b7280; margin: 4px 0 20px; font-size: 14px; }
.login-box form { display: flex; flex-direction: column; gap: 12px; }
.login-btn { padding: 10px; font-size: 14px; margin-top: 6px; }
.login-error {
    background: #fee2e2; color: #991b1b; padding: 8px 12px;
    border-radius: 6px; font-size: 13px; margin-bottom: 12px;
}

/* ============ Портал: сайдбар + контент ============ */
.portal {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background: #1f2937;
    color: #e5e7eb;
    padding: 16px 12px;
    border-right: 1px solid #111827;
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    padding: 6px 10px 14px;
    border-bottom: 1px solid #374151;
    margin-bottom: 14px;
}
.sidebar-section { margin-bottom: 20px; }
.sidebar-title {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: #9ca3af;
    padding: 0 10px 6px;
}
.sidebar-link {
    display: block;
    padding: 8px 10px;
    border-radius: 6px;
    color: #d1d5db;
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 2px;
}
.sidebar-link:hover { background: #374151; color: #fff; }
.sidebar-link.active { background: #2563eb; color: #fff; }

.cloud-list { list-style: none; margin: 0; padding: 0; }
.cloud-list li {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    color: #d1d5db;
    display: flex;
    align-items: center;
    gap: 6px;
}
.cloud-list li .cloud-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #10b981; flex-shrink: 0;
}
.cloud-list li .cloud-dot.error { background: #ef4444; }
.cloud-list li .cloud-dot.unknown { background: #6b7280; }
.cloud-list li.muted { color: #6b7280; font-style: italic; }

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid #374151;
}
.sidebar-user {
    font-size: 12px; color: #9ca3af; padding: 0 10px 8px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-logout { color: #fca5a5 !important; }
.sidebar-logout:hover { background: #7f1d1d; color: #fff !important; }
.sidebar { display: flex; flex-direction: column; }

/* Content */
.content {
    padding: 20px 28px;
    min-width: 0;
}
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.page-header h1 { margin: 0; font-size: 22px; flex: 1; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ============ Cards / table ============ */
.card {
    background: #fff;
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.card.no-padding { padding: 0; }
.card.no-padding > .pagination { padding: 10px 16px; }
.card-title { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.card-header {
    display: flex; align-items: center; gap: 10px;
    padding-bottom: 8px; margin-bottom: 10px;
    border-bottom: 1px solid #f3f4f6;
}
.card-header .card-title { margin: 0; flex: 1; }

/* Forms */
label { display: flex; flex-direction: column; font-size: 13px; color: #374151; margin-bottom: 8px; }
input, select {
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}
input:focus, select:focus { outline: 2px solid #2563eb; outline-offset: -1px; }
.actions { display: flex; align-items: center; gap: 8px; }

/* Buttons */
.btn {
    padding: 7px 13px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    color: #111827;
    display: inline-block;
    line-height: 1.2;
}
.btn:hover { background: #f9fafb; }
.btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: #dc2626; }
.btn.danger:hover { background: #fee2e2; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Status */
.status { font-size: 13px; }
.status.ok { color: #059669; }
.status.error { color: #dc2626; }
.status.info { color: #6b7280; }

.muted { color: #9ca3af; }
.muted-inline { color: #9ca3af; }
.center { text-align: center; padding: 16px; }

/* ============ Customers table ============ */
.table-wrap { overflow-x: auto; }
table.customers {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.customers th, table.customers td {
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}
table.customers th {
    color: #6b7280; font-weight: 500; font-size: 11px; text-transform: uppercase;
    background: #f9fafb; position: sticky; top: 0;
}
table.customers tr:last-child td { border-bottom: none; }
table.customers .cloud-col { text-align: center; font-size: 14px; min-width: 90px; }
table.customers .cloud-col .pc-count {
    display: inline-block;
    min-width: 28px;
    padding: 1px 8px;
    background: #2563eb;
    color: #fff;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
}
table.customers .cloud-col .pc-count.zero { background: #e5e7eb; color: #6b7280; }
table.customers .cloud-col .pc-loading { color: #9ca3af; font-size: 13px; }
table.customers .cloud-col .pc-error { color: #dc2626; font-size: 12px; }
table.customers .cloud-col .absent { color: #d1d5db; font-size: 18px; }
table.customers .cloud-col .bonus { font-size: 11px; color: #6b7280; display: block; margin-top: 2px; }
.cust-reg-row { font-size: 13px; margin-top: 2px; padding-left: 8px; }
table.customers .cloud-col .pc-reg {
  display: block; margin-top: 2px; font-size: 10px; line-height: 1.3;
  color: #94a3b8; max-width: 140px; margin-left: auto; margin-right: auto;
  white-space: normal; overflow: hidden; text-overflow: ellipsis;
}
table.customers .actions-th, table.customers .actions-td { text-align: right; }
table.customers .actions-td .btn { margin-left: 4px; }

a.customer-link {
    color: #2563eb;
    text-decoration: none;
    cursor: pointer;
}
a.customer-link:hover { text-decoration: underline; }

.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #f3f4f6;
}
.pagination .page-size { margin-left: 4px; flex-direction: row; align-items: center; gap: 6px; color: #6b7280; }
.pagination select {
    padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; font-size: 13px; margin: 0;
}

/* ============ Settings / clouds list ============ */
#clouds_list_container .cloud-item {
    background: #fff;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}

/* Master-detail для блока облаков. Слева — список облаков, справа — карточка. */
#clouds_list_container .cloud-md-wrap {
    display: grid; grid-template-columns: 240px 1fr; gap: 0;
    background: #fff; border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    overflow: hidden;
}
#clouds_list_container .cloud-md-list {
    background: #f9fafb; border-right: 1px solid #e5e7eb;
    padding: 8px 6px;
    display: flex; flex-direction: column;
    min-height: 220px;
}
#clouds_list_container .cloud-md-item {
    padding: 9px 10px; border-radius: 6px; cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: #374151;
    user-select: none;
}
#clouds_list_container .cloud-md-item:hover { background: #f3f4f6; }
#clouds_list_container .cloud-md-item.active {
    background: #dbeafe; color: #1e40af; font-weight: 600;
}
#clouds_list_container .cloud-md-item .m-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#clouds_list_container .cloud-md-item .cloud-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    background: #6b7280;
}
#clouds_list_container .cloud-md-item .cloud-dot.ok { background: #10b981; }
#clouds_list_container .cloud-md-item .cloud-dot.running { background: #fbbf24; }
#clouds_list_container .cloud-md-item .cloud-dot.error { background: #ef4444; }
#clouds_list_container .cloud-md-summary {
    margin-top: auto; padding: 10px;
    border-top: 1px solid #e5e7eb;
    font-size: 12px; color: #6b7280; line-height: 1.6;
}
#clouds_list_container .cloud-md-summary b { color: #111827; }
#clouds_list_container .cloud-md-detail {
    padding: 14px 16px;
    min-width: 0;
}
/* Карточка внутри detail-панели — без рамки/тени/отступов, они уже у wrap. */
#clouds_list_container .cloud-md-detail .cloud-item {
    background: transparent; box-shadow: none; border-radius: 0;
    padding: 0; margin: 0;
}
@media (max-width: 980px) {
    #clouds_list_container .cloud-md-wrap { grid-template-columns: 1fr; }
    #clouds_list_container .cloud-md-list {
        border-right: none; border-bottom: 1px solid #e5e7eb;
        min-height: 0; flex-direction: row; flex-wrap: wrap;
    }
    #clouds_list_container .cloud-md-summary {
        flex-basis: 100%; margin-top: 6px; padding-top: 6px;
    }
}
.cloud-item .ci-info { display: flex; flex-direction: column; gap: 3px; }
.cloud-item .ci-label { font-weight: 600; }
.cloud-item .ci-host { font-size: 12px; color: #6b7280; }
.cloud-item .ci-group { font-size: 12px; color: #374151; }
.cloud-item .ci-actions { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.cloud-item .ci-actions-group { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; max-width: 100%; }
.cloud-item .ci-actions-label {
    flex-basis: 100%;
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: right;
    margin-bottom: 2px;
    cursor: help;
}
.cloud-item .ci-test-result { font-size: 12px; }

.cloud-item .ci-sync {
    font-size: 12px;
    margin-top: 4px;
    color: #4b5563;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.cloud-item .sync-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500;
}
.cloud-item .sync-badge.ok { background: #d1fae5; color: #065f46; }
.cloud-item .sync-badge.running { background: #fef3c7; color: #92400e; }
.cloud-item .sync-badge.error { background: #fee2e2; color: #991b1b; }
.cloud-item .sync-badge.never { background: #e5e7eb; color: #6b7280; }
.cloud-item .ci-stats { font-size: 12px; color: #6b7280; display: flex; gap: 12px; flex-wrap: wrap; }
.cloud-item .ci-stats .ci-pending { color: #d97706; }
.cloud-item .ci-resume {
    font-size: 12px; color: #b45309;
    background: #fef3c7; padding: 4px 8px; border-radius: 4px;
    display: inline-block; align-self: flex-start;
}

/* ============ Users list ============ */
#users_list_container .user-item {
    background: #fff;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    align-items: center;
}
.user-item .u-email { font-weight: 500; }
.user-item .u-meta { font-size: 12px; color: #6b7280; }
.user-item .u-role-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.user-item .u-role-badge.admin { background: #fce7f3; color: #9d174d; }
.user-item .u-role-badge.viewer { background: #e0e7ff; color: #3730a3; }
.user-item .u-actions { display: flex; gap: 6px; }
.user-item .u-self-marker { font-size: 11px; color: #059669; margin-left: 4px; }

/* ============ Cloud sync_mode checkbox ============ */
.mc-checkbox {
    flex-direction: row; align-items: center; gap: 8px;
    padding: 8px 12px; background: #f9fafb; border-radius: 6px;
    margin: 4px 0;
}
.mc-checkbox input[type=checkbox] { margin: 0; width: auto; }
.mc-warn {
    font-size: 12px; padding: 10px 12px;
    background: #fef3c7; color: #92400e; border-radius: 6px;
    line-height: 1.5;
}

/* ============ Global view ============ */
.global-filters { padding: 14px 16px; }
.global-filters .gf-row {
    display: flex; gap: 12px; align-items: end; flex-wrap: wrap;
}
.global-filters .gf-field {
    display: flex; flex-direction: column; gap: 4px;
    margin: 0; min-width: 160px;
}
.global-filters .gf-field span {
    font-size: 11px; text-transform: uppercase; color: #6b7280; letter-spacing: 0.3px;
}
.global-filters .gf-search { flex: 1; min-width: 240px; }

table.customers th.sort-th { cursor: pointer; user-select: none; }
table.customers th.sort-th:hover { background: #e5e7eb; }
table.customers th.sort-th.active::after {
    content: " ▲"; opacity: 0.8;
}
table.customers th.sort-th.active.desc::after { content: " ▼"; }
table.customers th.tar, table.customers td.tar { text-align: right; }
table.customers td.cell-cloud, table.customers td.cell-group {
    font-size: 12px; color: #4b5563;
}

/* ============ Customer page (3-column layout) ============ */
.customer-layout {
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    gap: 16px;
    align-items: start;
}
@media (max-width: 1100px) {
    .customer-layout { grid-template-columns: 1fr; }
}

/* ============ Карточка-360: расширение ============ */
.cust-360-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 16px; margin-top: 16px;
}
@media (max-width: 900px) { .cust-360-grid { grid-template-columns: 1fr; } }

.cust-360-kpi {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 8px 12px; margin-top: 10px; font-size: 13px;
}
.cust-360-kpi .lbl { color: #6b7280; font-size: 11px; }
.cust-360-kpi .val { font-weight: 600; font-size: 15px; }

.rfm-badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 600; color: #fff; background: #6366f1;
}
.rfm-badge.champions   { background: #16a34a; }
.rfm-badge.loyal       { background: #2563eb; }
.rfm-badge.new         { background: #0ea5e9; }
.rfm-badge.promising   { background: #06b6d4; }
.rfm-badge.at_risk     { background: #f59e0b; }
.rfm-badge.hibernating { background: #f97316; }
.rfm-badge.lost        { background: #dc2626; }
.rfm-badge.other       { background: #6b7280; }
.rfm-scores { font-family: monospace; color: #4b5563; margin-left: 8px; font-size: 12px; }

.cust-heatmap-grid {
    display: grid; grid-template-columns: 28px repeat(24, 1fr); gap: 2px;
    font-size: 10px; color: #6b7280;
}
.cust-heatmap-grid .hm-h { text-align: center; }
.cust-heatmap-grid .hm-d { text-align: right; padding-right: 4px; line-height: 14px; }
.cust-heatmap-grid .hm-cell { height: 14px; border-radius: 2px; background: #f1f5f9; }

.cust-top-items { width: 100%; font-size: 12px; border-collapse: collapse; }
.cust-top-items td, .cust-top-items th { padding: 4px 6px; border-bottom: 1px solid #f1f5f9; }
.cust-top-items th { text-align: left; color: #6b7280; font-weight: 500; }
.cust-top-items td.n, .cust-top-items th.n { text-align: right; font-variant-numeric: tabular-nums; }

.cust-bonus-balance { font-size: 22px; font-weight: 600; margin-bottom: 10px; }
.cust-bonus-tbl { width: 100%; font-size: 12px; border-collapse: collapse; max-height: 320px; }
.cust-bonus-tbl td, .cust-bonus-tbl th { padding: 3px 6px; border-bottom: 1px solid #f1f5f9; }
.cust-bonus-tbl th { text-align: left; color: #6b7280; font-weight: 500; }
.cust-bonus-tbl td.n, .cust-bonus-tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
.cust-bonus-tbl .btx-credit { color: #16a34a; }
.cust-bonus-tbl .btx-debit  { color: #dc2626; }
.cust-bonus-scroll { max-height: 320px; overflow-y: auto; }

.customer-meta {
    display: flex; flex-direction: column; gap: 6px; font-size: 13px;
}

/* Venues by cloud */
#venues_by_cloud .venue-cloud { margin-bottom: 12px; }
#venues_by_cloud .venue-cloud-head {
    font-weight: 600; font-size: 13px; padding: 6px 8px;
    background: #eef2ff; color: #3730a3; border-radius: 5px;
    margin-bottom: 4px; display: flex; justify-content: space-between;
    cursor: pointer; user-select: none;
}
#venues_by_cloud .venue-cloud-head:hover { background: #dbeafe; }
#venues_by_cloud .venue-cloud-head.active {
    background: #2563eb; color: #fff;
}
#venues_by_cloud .venue-row {
    display: flex; justify-content: space-between;
    padding: 4px 8px; font-size: 13px; border-bottom: 1px solid #f3f4f6;
    cursor: pointer; user-select: none; border-radius: 3px;
}
#venues_by_cloud .venue-row:last-child { border-bottom: none; }
#venues_by_cloud .venue-row:hover { background: #f3f4f6; }
#venues_by_cloud .venue-row.active {
    background: #2563eb; color: #fff;
}
#venues_by_cloud .venue-row.active .vc-count { color: #dbeafe; }
#venues_by_cloud .venue-row .vc-count { color: #6b7280; }

/* ===== Активный фильтр ===== */
.filter-reset {
    margin: 0 0 12px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.filter-reset .fr-title {
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    color: #2563eb;
    font-weight: 700;
    display: flex; align-items: center; gap: 6px;
}
.filter-reset .fr-title::before {
    content: ""; display: inline-block; width: 6px; height: 6px;
    background: #2563eb; border-radius: 50%;
}
.filter-reset .fr-chips {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
}
.filter-reset .fr-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; background: #fff; border: 1px solid #bfdbfe;
    border-radius: 999px; font-size: 12px; color: #1e3a8a; font-weight: 500;
}
.filter-reset .fr-chip.cloud-chip { background: #2563eb; color: #fff; border-color: #2563eb; }
.filter-reset .fr-chip-icon { font-size: 11px; opacity: 0.7; }
.filter-reset .fr-sep { color: #93c5fd; font-size: 14px; line-height: 1; }
.filter-reset .fr-clear {
    align-self: flex-start;
    margin-top: 2px;
    padding: 4px 10px 4px 8px;
    background: #fff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    color: #1d4ed8;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex; align-items: center; gap: 4px;
    text-decoration: none;
    transition: background 0.1s;
}
.filter-reset .fr-clear:hover { background: #2563eb; color: #fff; border-color: #2563eb; }
.filter-reset .fr-clear .fr-x {
    font-size: 14px; line-height: 1; font-weight: 700;
}

/* Orders */
.order-card {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #fff;
}
.order-card-head {
    display: flex; gap: 12px; align-items: center; font-size: 13px;
    flex-wrap: wrap;
}
.order-card-head .o-date { color: #6b7280; min-width: 130px; }
.order-card-head .o-sum { font-weight: 600; min-width: 80px; }
.order-card-head .o-place { flex: 1; }
.order-card-head .cloud-badge {
    display: inline-block; padding: 2px 7px; font-size: 11px;
    background: #eef2ff; color: #3730a3; border-radius: 10px;
}
.order-products {
    margin-top: 8px; padding-top: 8px; border-top: 1px solid #f3f4f6;
    font-size: 13px; color: #4b5563;
}
.order-products .op-row { display: flex; gap: 8px; padding: 2px 0; }
.order-products .op-name { flex: 1; }
.order-products .op-amt { min-width: 50px; text-align: right; color: #6b7280; }
.order-products .op-sum { min-width: 70px; text-align: right; }
.order-products .op-loading { color: #9ca3af; font-style: italic; }
.order-products .op-error { color: #dc2626; }
.order-products .op-row.op-mod {
    padding-left: 18px; font-size: 12px; color: #6b7280;
}
.order-products .op-row.op-mod .op-name::before {
    content: "↳ "; color: #9ca3af;
}
/* Пустая строка между блюдами: любой не-модификатор, следующий за другой строкой */
.order-products .op-row + .op-row:not(.op-mod) {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #f3f4f6;
}

/* Year/Month chips */
#by_year_month .year-row {
    margin-bottom: 8px; padding: 6px 8px; background: #f9fafb; border-radius: 4px; font-size: 13px;
}
#by_year_month .year-label { font-weight: 600; }
#by_year_month .month-chip {
    display: inline-block; margin: 2px 4px 2px 0;
    padding: 2px 8px; background: #e0e7ff; color: #3730a3;
    border-radius: 10px; font-size: 12px;
}

/* Calendar */
.cal-month { margin-bottom: 14px; }
.cal-month .cal-title { font-size: 12px; font-weight: 600; margin-bottom: 4px; color: #374151; }
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    max-width: 250px;
}
.cal-grid .cal-dow {
    font-size: 9px; color: #9ca3af; text-align: center; padding: 2px 0;
}
.cal-grid .cal-day {
    aspect-ratio: 1;
    text-align: center; font-size: 11px;
    background: #f3f4f6; color: #9ca3af; border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
}
.cal-grid .cal-day.has {
    background: #2563eb; color: #fff; font-weight: 600;
    cursor: pointer; user-select: none;
}
.cal-grid .cal-day.has:hover { background: #1d4ed8; }
.cal-grid .cal-day.has.active {
    background: #f59e0b;
    box-shadow: 0 0 0 2px #fbbf24;
}
.cal-grid .cal-day.empty { background: transparent; }

.ic-config-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
}
.ic-config-grid label {
    display: flex; flex-direction: column; gap: 4px;
    font-size: 12px; color: #374151;
}
.ic-config-grid input[type=text], .ic-config-grid input[type=password] {
    padding: 6px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 13px;
}
#ic_section .ci-stats { font-size: 14px; }
#ic_last_run_block { font-size: 13px; padding: 8px 12px; background: #f9fafb; border-radius: 6px; }
#ic_last_run_block.ok { background: #ecfdf5; color: #065f46; }
#ic_last_run_block.error { background: #fef2f2; color: #991b1b; }
#ic_last_run_block.running { background: #fef3c7; color: #92400e; }

#gf_exclude_own.active {
    background: #f59e0b; color: #fff; border-color: #f59e0b;
}
#gf_only_no_purchase.active,
#gf_exclude_no_purchase.active {
    background: #2563eb; color: #fff; border-color: #2563eb;
}
.gf-dateby { display: flex; gap: 6px; margin-bottom: 10px; }
.gf-dateby .btn-sm.active {
    background: #2563eb; color: #fff; border-color: #2563eb;
}

/* Global page calendar filter */
.all-customers-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 16px;
    align-items: start;
}
@media (max-width: 1100px) {
    .all-customers-layout { grid-template-columns: 1fr; }
}
.all-customers-side .card { padding: 14px; }
.all-customers-side .card-title { margin: 0 0 10px; font-size: 14px; color: #374151; }
#gf_calendar { min-width: 280px; }
.gf-cal-header {
    display: flex; align-items: center; gap: 4px;
    margin-bottom: 6px;
}
.gf-cal-nav {
    background: #f3f4f6; border: none; cursor: pointer;
    width: 24px; height: 24px; border-radius: 4px; font-size: 14px; line-height: 1;
    color: #374151; padding: 0;
}
.gf-cal-nav:hover { background: #e5e7eb; }
.gf-cal-label {
    background: none; border: none; cursor: pointer;
    padding: 2px 8px; border-radius: 4px;
    font-size: 14px; font-weight: 600; color: #111827;
}
.gf-cal-label:hover { background: #eef2ff; color: #4338ca; }
.gf-cal-label.active { background: #f59e0b; color: #fff; }
.gf-cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
    width: 280px;
}
.gf-cal-grid .cal-dow {
    font-size: 10px; color: #9ca3af; text-align: center; padding: 2px 0;
}
.gf-cal-grid .cal-day {
    aspect-ratio: 1; text-align: center; font-size: 12px;
    background: #f3f4f6; color: #9ca3af; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
}
.gf-cal-grid .cal-day.empty { background: transparent; }
.gf-cal-grid .cal-day.has {
    background: #2563eb; color: #fff; font-weight: 600;
    cursor: pointer; user-select: none;
}
.gf-cal-grid .cal-day.has:hover { background: #1d4ed8; }
.gf-cal-grid .cal-day.has.active {
    background: #f59e0b; box-shadow: 0 0 0 2px #fbbf24;
}
.gf-period-info {
    display: flex; flex-direction: column; gap: 8px;
    font-size: 13px; color: #374151; margin-top: 12px;
    padding-top: 10px; border-top: 1px solid #f3f4f6;
}
.gf-period-info .gf-period-label { font-weight: 600; }
.gf-period-info .gf-period-clear { align-self: flex-start; }

#customer_stats_blocks { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.stats-block .stats-grid {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 13px; color: #374151;
}
.stats-block .stats-row {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 4px 0; border-bottom: 1px solid #f3f4f6;
}
.stats-block .stats-row:last-child { border-bottom: none; }
.stats-block .stats-label { color: #6b7280; }
.stats-block .stats-val { font-weight: 600; color: #111827; font-variant-numeric: tabular-nums; }
button.stats-row {
    background: none; border: none; border-bottom: 1px solid #f3f4f6;
    text-align: left; font: inherit; cursor: pointer; width: 100%;
    padding: 4px 6px; margin: 0; border-radius: 4px;
    transition: background-color 0.12s;
}
button.stats-row:hover { background: #f3f4f6; }
button.stats-row.active { background: #dbeafe; }
button.stats-row.active .stats-label,
button.stats-row.active .stats-val { color: #1d4ed8; }

/* ===== Origin backfill progress widget ===== */
.origin-progress {
    background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px;
    padding: 12px 16px; margin-bottom: 16px;
}
.origin-progress.hidden { display: none; }
.origin-progress .op-head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    font-size: 14px; color: #1e3a8a;
}
.origin-progress .op-total { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.origin-progress .op-bar {
    margin-top: 8px; height: 8px; background: #dbeafe; border-radius: 4px; overflow: hidden;
}
.origin-progress .op-bar-fill {
    height: 100%; background: #3b82f6; border-radius: 4px; transition: width 0.4s ease;
}
.origin-progress .op-clouds {
    margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: #374151;
}
.origin-progress .op-clouds .op-cloud { font-variant-numeric: tabular-nums; }
.origin-progress .op-hint { margin-top: 6px; font-size: 12px; }
.origin-progress .op-spinner {
    width: 14px; height: 14px; border: 2px solid #93c5fd; border-top-color: #1d4ed8;
    border-radius: 50%; display: inline-block; animation: op-spin 0.8s linear infinite;
}
@keyframes op-spin { to { transform: rotate(360deg); } }

/* ===== 12a.3 — ETL last-run progress card ===== */
.etl-progress {
    background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px;
    padding: 10px 12px; margin: 0 0 12px;
}
.etl-progress--running { background: #eff6ff; border-color: #bfdbfe; }
.etl-progress--ok { background: #f0fdf4; border-color: #bbf7d0; }
.etl-progress--error { background: #fef2f2; border-color: #fecaca; }
.etl-progress .ep-head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    font-size: 13px; color: #1f2937;
}
.etl-progress .ep-title { font-weight: 600; }
.etl-progress .ep-cloud { font-size: 12px; }
.etl-progress .ep-meta { margin-left: auto; font-size: 12px; color: #6b7280; font-variant-numeric: tabular-nums; }
.etl-progress .ep-bar {
    margin-top: 8px; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden;
}
.etl-progress .ep-bar-fill {
    height: 100%; background: #3b82f6; border-radius: 4px; transition: width 0.4s ease;
}
.etl-progress--ok .ep-bar-fill { background: #16a34a; }
.etl-progress--error .ep-bar-fill { background: #dc2626; }
.etl-progress .ep-line {
    margin-top: 6px; font-size: 12px; color: #374151; font-variant-numeric: tabular-nums;
}

/* ============ Modal ============ */
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
    background: #fff; padding: 24px; border-radius: 8px;
    width: 440px; max-width: 90vw; max-height: 90vh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px;
}
.modal-content h3 { margin: 0 0 6px; }

.m-clouds { padding: 8px 0; border-top: 1px solid #f3f4f6; margin-top: 6px; }
.m-clouds-title { font-size: 13px; color: #374151; margin-bottom: 6px; font-weight: 500; }
.m-clouds-row {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0; font-size: 13px;
}
.m-clouds-row input[type=checkbox] { margin: 0; }
.m-clouds-row .m-present { font-size: 11px; color: #059669; }
.m-clouds-row .m-absent { font-size: 11px; color: #9ca3af; }

/* 10f.4 — permissions modal */
.mu-perms { border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px 10px; margin: 4px 0; }
.mu-perms legend { padding: 0 6px; font-size: 12px; color: #6b7280; font-weight: 600; }
.mu-perm { display: block; padding: 3px 0; font-size: 14px; }
.mu-perm input[type=checkbox] { margin-right: 6px; vertical-align: middle; }

/* ============ 1C CRM pages (общий layout, использует .portal/.sidebar) ============ */
.ic-content { background: #f7f7f8; padding: 0; }
.ic-tabs {
    background: #fff; border-bottom: 1px solid #e5e7eb;
    padding: 0 20px; display: flex; gap: 4px;
    flex-wrap: wrap;
}
.ic-tabs .ic-tab {
    padding: 10px 16px; color: #374151; text-decoration: none;
    font-size: 13px; border-bottom: 2px solid transparent;
    white-space: nowrap; flex: 0 0 auto;
}
.ic-tabs .ic-tab:hover { background: #f3f4f6; }
.ic-tabs .ic-tab.active { border-bottom-color: #2563eb; color: #1d4ed8; font-weight: 600; }
.ic-wrap { padding: 20px; max-width: 1700px; }
.ic-card {
    background: #fff; padding: 14px; border-radius: 6px; margin-bottom: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.ic-card h2 { margin: 0 0 10px; font-size: 15px; }
.ic-kpi-row { display: flex; gap: 12px; flex-wrap: wrap; }
.ic-kpi {
    background: #fff; padding: 12px 16px; border-radius: 6px; min-width: 150px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.ic-kpi .lbl { font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; }
.ic-kpi .val { font-size: 20px; font-weight: 600; margin-top: 4px; }
.ic-tbl { border-collapse: collapse; background: #fff; font-size: 13px; width: 100%; }
.ic-tbl th, .ic-tbl td {
    padding: 6px 10px; text-align: left; border-bottom: 1px solid #f0f0f3; vertical-align: top;
}
.ic-tbl th { background: #eef0f3; font-size: 12px; color: #374151; }
.ic-tbl tr:hover td { background: #fafbfd; }
.ic-tbl .n { text-align: right; font-variant-numeric: tabular-nums; }
.ic-tbl .muted { color: #9ca3af; }
.ic-tbl .money { text-align: right; font-variant-numeric: tabular-nums; }
.ic-filter {
    display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap;
}
.ic-filter input, .ic-filter select {
    padding: 6px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 13px;
}
.ic-filter input[type=search] { min-width: 280px; }
.ic-pagi {
    display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 13px; color: #374151;
}
.ic-pagi a {
    padding: 4px 10px; background: #fff; border: 1px solid #d1d5db; border-radius: 4px;
    text-decoration: none; color: #374151;
}
.ic-pagi a:hover { background: #eef2ff; }
.ic-pagi a.disabled { color: #9ca3af; pointer-events: none; }
.ic-badge {
    display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px;
    background: #e0e7ff; color: #3730a3;
}
.ic-badge.vip { background: #fef3c7; color: #92400e; }
.ic-content details {
    margin-bottom: 6px; background: #fff; padding: 8px 12px; border-radius: 5px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.ic-content details summary {
    cursor: pointer; display: flex; gap: 14px; align-items: center; font-size: 13px;
}

/* ============ Dashboards ============ */
.dash-controls {
    display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
}
.dash-presets { display: flex; gap: 8px; }
.dash-archive {
    display: flex; align-items: center; gap: 8px;
    border-left: 1px solid #e5e7eb; padding-left: 16px;
}
.dash-archive select,
.dash-archive input[type="date"],
.dash-wperiod input[type="date"] {
    padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 5px;
    background: #fff; font-size: 13px;
}
.dash-toggle {
    display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px;
    margin-left: auto;
}
.dash-cust-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px; margin-bottom: 16px;
}
.dash-cust-grid .stats-block { margin: 0; }
.dash-cloud { margin-bottom: 14px; }
.dash-total { border-left: 3px solid #2563eb; }
.dash-metrics {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 8px 0 14px;
}
.dash-metric {
    background: #f9fafb; border: 1px solid #f0f0f0; border-radius: 6px;
    padding: 10px 14px;
}
.dash-metric-label { color: #6b7280; font-size: 12px; margin-bottom: 4px; }
.dash-metric-sub { color: #9ca3af; font-weight: normal; }
.dash-metric-val {
    font-size: 20px; font-weight: 700; color: #111827; font-variant-numeric: tabular-nums;
}
.dash-places {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.dash-places th, .dash-places td {
    padding: 6px 10px; border-bottom: 1px solid #f1f5f9; text-align: left;
}
.dash-places th { color: #6b7280; font-weight: 600; font-size: 12px; }
.dash-places td.num, .dash-places th.num {
    text-align: right; font-variant-numeric: tabular-nums;
}
.dash-places tbody tr:hover { background: #fafafa; }

/* ---- Новые метрики дашборда: регистрации / ABC / топ позиций ---- */
.dash-metric-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 6px;
}
.dash-seg { display: inline-flex; gap: 4px; }
.dash-wperiod {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    margin: 2px 0 12px; padding: 8px 10px; background: #f9fafb;
    border: 1px solid #f0f0f0; border-radius: 6px;
}
.dash-wperiod .dash-presets { gap: 6px; }
.dash-wperiod-label { font-size: 12px; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.dash-seg-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.dash-seg-btn.active:hover { background: #1d4ed8; }
.dash-cloud-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.dash-cloud-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.dash-cloud-tab.active:hover { background: #1d4ed8; }

/* Гистограмма регистраций */
.reg-chart {
    display: flex; align-items: flex-end; gap: 3px;
    height: 160px; margin-top: 10px; overflow-x: auto; padding-bottom: 22px;
}
.reg-bar-wrap {
    flex: 1 1 0; min-width: 8px; height: 100%;
    display: flex; flex-direction: column; justify-content: flex-end;
    position: relative;
}
.reg-bar-val {
    font-size: 9px; color: #6b7280; text-align: center; line-height: 1.1;
    margin-bottom: 2px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.reg-bar {
    background: #2563eb; border-radius: 3px 3px 0 0; min-height: 2px;
    transition: background .15s;
}
.reg-bar-wrap:hover .reg-bar { background: #1d4ed8; }
.reg-bar-x {
    position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%) rotate(0);
    font-size: 9px; color: #9ca3af; white-space: nowrap;
}

/* ABC */
.abc-bar {
    display: flex; height: 16px; border-radius: 4px; overflow: hidden;
    background: #f1f5f9; margin-top: 6px;
}
.abc-seg { height: 100%; }
.abc-seg.abc-A, .abc-badge.abc-A { background: #059669; }
.abc-seg.abc-B, .abc-badge.abc-B { background: #f59e0b; }
.abc-seg.abc-C, .abc-badge.abc-C { background: #9ca3af; }
.abc-badge {
    display: inline-block; width: 18px; height: 18px; line-height: 18px;
    text-align: center; border-radius: 4px; color: #fff; font-weight: 700;
    font-size: 11px; vertical-align: middle;
}

/* Топ позиций — горизонтальные бары в ячейке названия */
.dash-places.topitems td:nth-child(2) { position: relative; min-width: 220px; }
.topitem-bar {
    position: absolute; left: 0; top: 0; bottom: 0;
    background: #dbeafe; border-radius: 4px; z-index: 0;
}
.topitem-name { position: relative; z-index: 1; }

/* ============ Удаление клиентов без покупок ============ */
.cl-cloud { margin-bottom: 18px; }
.cl-cloud:last-child { margin-bottom: 0; }
.cl-cloud-head { font-size: 14px; margin-bottom: 6px; }
.cl-none { font-size: 13px; padding: 8px 0 4px; }

/* Табы облаков */
.cl-tabs {
    display: flex; gap: 4px; flex-wrap: wrap;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 12px; padding: 0 2px;
}
.cl-tab {
    padding: 8px 14px; cursor: pointer;
    font-size: 13px; color: #374151; font-weight: 500;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    display: inline-flex; align-items: center; gap: 8px;
    user-select: none;
}
.cl-tab:hover { color: #111827; }
.cl-tab.active {
    color: #2563eb; border-bottom-color: #2563eb; font-weight: 600;
}
.cl-badge {
    background: #fee2e2; color: #991b1b;
    font-size: 11px; padding: 1px 7px; border-radius: 999px;
    font-weight: 600; font-variant-numeric: tabular-nums;
}
.cl-tab.active .cl-badge { background: #dbeafe; color: #1e40af; }
.cl-badge.zero { background: #e5e7eb; color: #6b7280; }

/* Пагинатор для таблицы запусков ETL */
.etl-pager {
    display: flex; align-items: center; gap: 10px;
    margin-top: 10px; padding-top: 10px;
    border-top: 1px solid #f3f4f6;
}
.etl-pager .etl-pg-info { font-size: 12px; flex: 1; text-align: center; }
.etl-pager .btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* Двухколоночный верх страницы настроек: cleanup + 1С CRM рядом */
.settings-row-2col {
    display: flex; flex-wrap: wrap; gap: 14px;
    margin-top: 28px;
}
.settings-row-2col > .section-block {
    flex: 1 1 0; min-width: 420px; margin-top: 0;
}
@media (max-width: 1100px) {
    .settings-row-2col > .section-block { flex-basis: 100%; }
}
.cl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cl-table th {
    text-align: left; font-weight: 600; color: #6b7280;
    font-size: 12px; padding: 4px 10px; border-bottom: 1px solid #eee;
}
.cl-table th.num, .cl-table td.num { text-align: right; }
.cl-table td { padding: 6px 10px; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
.cl-table td.cl-act { text-align: right; white-space: nowrap; }
.cl-run-line { margin-top: 3px; }
.cl-run { font-size: 12px; }
.cl-run.running { color: #2563eb; }
.cl-run.ok { color: #059669; }
.cl-run.stopped { color: #92400e; }
.cl-run.err { color: #dc2626; }

.mcl-warn {
    font-size: 12px; padding: 10px 12px; margin: 4px 0;
    background: #fee2e2; color: #991b1b; border-radius: 6px; line-height: 1.5;
}
.mcl-check {
    flex-direction: row; align-items: center; gap: 8px;
    padding: 8px 12px; background: #f9fafb; border-radius: 6px; margin: 8px 0 4px;
}
.mcl-check input[type=checkbox] { margin: 0; width: auto; }
.mcl-input { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.mcl-input input { font-size: 14px; }

/* ============ index.html SPA polish (A2.6) ============ */
.ml-auto { margin-left: auto; }
.card-mb16 { margin-bottom: 16px; }
.mb12 { margin-bottom: 12px; }
.mb8 { margin-bottom: 8px; }
.section-block { margin-top: 28px; }
.section-title { margin: 0; font-size: 18px; flex: 1; }
.subsection-title { margin: 0 0 10px; font-size: 16px; }
.subsection-h3 { margin: 0 0 10px; font-size: 14px; }
.subsection-h3.tight { margin: 0 0 8px; }
.title-link { font-size: 13px; font-weight: normal; margin-left: 8px; }
.toggle-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle-row + .toggle-row { margin-top: 10px; }
.hint { font-size: 12px; }
.hint.mt8 { margin-top: 8px; }
.hint.mt6 { margin-top: 6px; }
.hint.mt4 { margin-top: 4px; }
.hint.indent-24 { margin-left: 24px; }
.hint-13 { font-size: 13px; }
.divider { margin: 14px 0; border: none; border-top: 1px solid #eee; }
.action-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.ic-config-wrap { border-top: 1px solid #f0f0f3; padding-top: 12px; margin-top: 10px; }
.ic-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.ic-config-grid label.row-full { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 8px; }
.ic-fields-box {
    margin-top: 10px; padding: 10px; border: 1px solid #c7d2fe;
    background: #eef2ff; border-radius: 6px;
}
.ic-fields-title { font-size: 12px; color: #3730a3; font-weight: 600; margin-bottom: 8px; }
.ic-fields-hint { font-size: 11px; color: #6b7280; margin-top: 4px; }
.ic-field-row { display: block; margin: 4px 0; font-size: 13px; }
.ic-field-row input { width: 100%; }
.dash-period-label { margin-top: 10px; font-size: 13px; }
.muted-12 { font-size: 12px; }
.cust-ic-section { margin-top: 14px; }
.modal-help { margin: 0 0 8px; }
.modal-help.tight { margin: 0 0 10px; }
.app-settings-status { margin-top: 8px; }

/* ============ Общие настройки — карточки-плитки (10-Б) ============ */
.app-settings { padding: 0; }
.app-settings-head {
    padding: 16px 18px 12px;
    border-bottom: 1px solid #f3f4f6;
}
.app-settings-title { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.app-settings-sub { font-size: 12px; line-height: 1.5; }

.app-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px 18px;
}
.app-settings-grid--single { grid-template-columns: 1fr; }
.app-settings-grid--3col { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 1100px) {
    .app-settings-grid--3col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .app-settings-grid { grid-template-columns: 1fr; }
}

.ast-tile {
    flex-direction: column;
    gap: 10px;
    transition: opacity 0.15s;
}
.ast-tile.ast-tile--off { opacity: 0.65; }
.ast-tile > .ast-icon { margin-top: 2px; }
.ast-icon--green { background: #d1fae5; color: #065f46; }
.ast-icon--violet { background: #ede9fe; color: #5b21b6; }

/* Внутри плитки контролы выкладываем вертикально, а икона/тело — горизонтально через flex плитки */
.ast-tile { display: flex; flex-direction: row; }
.ast-tile .ast-body { display: flex; flex-direction: column; gap: 8px; }

.ast-row {
    display: flex; align-items: center; gap: 10px;
}
.ast-row-label { font-size: 12px; color: #374151; font-weight: 500; flex-shrink: 0; }
.ast-select {
    flex: 1;
    padding: 6px 10px;
    font-size: 13px; line-height: 1.2;
    border: 1px solid #d1d5db; border-radius: 6px; background: #fff;
    margin: 0;
}
.ast-select:focus { outline: 2px solid #2563eb; outline-offset: -1px; }
.ast-select:disabled { background: #f3f4f6; color: #6b7280; cursor: not-allowed; }

.ast-switch-row--bottom {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
    display: flex; align-items: center; gap: 10px;
}
.ast-switch-row--bottom .ast-meta { flex: 1; min-width: 0; }
.ast-meta-line {
    font-size: 11px; color: #6b7280; line-height: 1.4;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ast-meta-line--countdown { color: #2563eb; font-weight: 500; }
.ast-tile.ast-tile--off .ast-meta-line--countdown { color: #9ca3af; font-weight: 400; }
.ast-switch-wrap { display: inline-flex; align-items: center; cursor: pointer; }
.ast-tile {
    padding: 14px;
    background: #f9fafb;
    border: 1px solid #f3f4f6;
    border-radius: 8px;
    display: flex; gap: 12px; align-items: flex-start;
}
.ast-icon {
    width: 38px; height: 38px; flex-shrink: 0;
    border-radius: 8px;
    background: #dbeafe; color: #1e40af;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.ast-body { flex: 1; min-width: 0; }
.ast-title-row {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 4px;
}
.ast-title {
    font-size: 14px; font-weight: 600; color: #111827;
}
.ast-pill {
    margin-left: auto;
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.2px;
    background: #e5e7eb; color: #6b7280;  /* default = off */
}
.ast-pill.on { background: #d1fae5; color: #065f46; }
.ast-pill.warn { background: #fef3c7; color: #92400e; }
.ast-hint {
    font-size: 12px; color: #6b7280; line-height: 1.5;
    margin-bottom: 10px;
}

/* Свитч на базе нативного checkbox */
.ast-switch-row {
    display: flex; align-items: center; gap: 8px;
    margin: 0; cursor: pointer; user-select: none;
}
.ast-switch-input {
    position: absolute; opacity: 0; pointer-events: none;
    width: 0; height: 0; margin: 0;
}
.ast-switch {
    position: relative;
    width: 38px; height: 22px;
    background: #d1d5db;
    border-radius: 999px;
    transition: background 0.15s;
    flex-shrink: 0;
}
.ast-switch::after {
    content: '';
    position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: left 0.15s;
}
.ast-switch-input:checked + .ast-switch { background: #2563eb; }
.ast-switch-input:checked + .ast-switch::after { left: 18px; }
.ast-switch-input:disabled + .ast-switch { opacity: 0.5; cursor: not-allowed; }
.ast-switch-input:focus-visible + .ast-switch { outline: 2px solid #2563eb; outline-offset: 2px; }
.ast-switch-label { font-size: 11px; color: #6b7280; }

/* Нижний action-row (Пересчитать сводку) */
.app-settings-action {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px;
    background: #f9fafb;
    border-top: 1px solid #f3f4f6;
    border-radius: 0 0 8px 8px;
}
.app-settings-action .aa-main { flex: 1; min-width: 0; }
.app-settings-action .aa-title {
    font-size: 13px; font-weight: 600; color: #111827; margin-bottom: 2px;
}
.app-settings-action .aa-meta {
    font-size: 12px; color: #374151;
}
.app-settings-action .aa-hint {
    font-size: 11px; margin-top: 4px; line-height: 1.5;
}

/* A3.1 — пагинатор маркетинговых таблиц */
.pg-bar { color: #374151; }
.pg-bar .muted { color: #6b7280; }
.pg-btn {
    display: inline-block; min-width: 28px; padding: 4px 8px;
    border: 1px solid #e5e7eb; border-radius: 6px;
    text-decoration: none; color: #374151; background: #fff;
    font-size: 13px; text-align: center;
}
.pg-btn:hover { background: #f3f4f6; }
.pg-btn.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.pg-btn.disabled { color: #d1d5db; background: #f9fafb; cursor: not-allowed; pointer-events: none; }
.pg-ellipsis { color: #9ca3af; padding: 0 4px; font-size: 13px; }

/* ===== Автоотчёты ===== */
.rep-row { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.rep-row-main { flex: 1 1 auto; min-width: 0; }
.rep-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.rep-title { font-size: 15px; margin-bottom: 4px; }
.rep-runs { margin-top: 10px; padding-top: 10px; border-top: 1px solid #eee; }
.rep-runs-list { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.rep-run-row { padding: 4px 0; border-bottom: 1px dashed #f0f0f0; }
.mr-clouds { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.mr-chip { background: #f3f4f6; padding: 4px 10px; border-radius: 14px; font-size: 13px; cursor: pointer; user-select: none; }
.mr-chip input { margin-right: 4px; }
.mr-radio { margin-right: 12px; font-size: 14px; }
