/* Мія — оформление в едином стиле AG-модулей (эталон: acf3.0) + каркас панели */

* {
    box-sizing: border-box;
}
html, body {
    margin: 0;
}
body.ag-os {
    min-height: 100vh;
    padding: 0;
}
.ag-os {
    font-size: 14px;
    line-height: 1.5;
    background-color: #f8fafc;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #334155;
}
.ag-os a {
    color: #6d28d9;
    text-decoration: none;
}
.ag-os a:hover {
    text-decoration: underline;
}

/* ===== Каркас ===== */
.mia {
    display: flex;
    min-height: 100vh;
}
.mia-side {
    flex: 0 0 248px;
    padding: 20px 12px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
}
.mia-main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 20px 32px 40px;
}
.mia-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 8px 24px;
    font-size: 18px;
    font-weight: 700;
    color: #0f172a !important;
    text-decoration: none !important;
}
.mia-brand small {
    display: block;
    font-size: 14px;
    font-weight: 400;
    color: #64748b;
}
.mia-brand--center {
    justify-content: center;
    margin-bottom: 20px;
}
.mia-brand__logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 20px;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    border-radius: 12px;
}
.mia-nav__group {
    margin: 18px 14px 6px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}
.mia-nav__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 15px;
    font-weight: 500;
    color: #334155 !important;
    border-radius: 8px;
    transition: all 0.15s;
}
.mia-nav__item + .mia-nav__item {
    margin-top: 2px;
}
a.mia-nav__item:hover {
    text-decoration: none;
    background: #f1f5f9;
}
.mia-nav__item--active,
a.mia-nav__item--active:hover {
    color: #fff !important;
    background: #6d28d9;
}
.mia-nav__item--soon {
    color: #64748b !important;
    cursor: default;
}
.mia-nav__item em {
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    color: #94a3b8;
}
.mia-top {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 24px;
}
.mia-top form {
    margin: 0;
}
.mia-top__user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 4px;
    font-weight: 500;
    color: #0f172a !important;
    border-radius: 24px;
}
.mia-top__user:hover,
.mia-top__user--active {
    text-decoration: none !important;
    background: #f1f5f9;
}
.mia-top__user small {
    display: block;
    font-size: 14px;
    font-weight: 400;
    color: #64748b;
}
.mia-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-weight: 600;
    color: #6d28d9;
    background: #ede9fe;
    border-radius: 50%;
}
.mia-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 24px;
    align-items: start;
}
.mia-grid > .ag-card {
    margin-bottom: 0;
}
.mia-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 16px;
}

/* ===== Вход ===== */
.mia-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 16px;
}
.ag-os .mia-auth__card {
    width: 100%;
    max-width: 420px;
    margin: 0;
    padding: 32px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}
.mia-auth__title {
    margin: 0 0 16px;
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    color: #0f172a;
}
.mia-auth__note {
    margin: 16px 0 0;
    text-align: center;
}
.mia-wide {
    width: 100%;
}

/* ===== Шапка страницы ===== */
.ag-os .ag-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.ag-os .ag-header-title h1 {
    margin: 0 0 4px;
    font-size: 26px;
    font-weight: 600;
    color: #0f172a;
}
.ag-os .ag-header-actions {
    display: flex;
    gap: 8px;
    margin: 0;
}

/* ===== Кнопки ===== */
.ag-os .ag-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    height: 38px;
    padding: 6px 16px;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.ag-os .ag-btn:hover {
    text-decoration: none;
}
.ag-os .ag-btn-primary {
    color: #fff;
    background-color: #0f172a;
}
.ag-os .ag-btn-primary:hover {
    background-color: #1e293b;
}
.ag-os .ag-btn-grey {
    color: #0f172a;
    background: #fff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}
.ag-os .ag-btn-grey:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}
.ag-os .ag-btn-danger {
    color: #fff;
    background: #ef4444;
}
.ag-os .ag-btn-soft {
    color: #6d28d9;
    background: #f5f3ff;
    border: 1px dashed #c4b5fd;
}
.ag-os .ag-btn-soft:hover {
    background: #ede9fe;
}
.ag-os .ag-btn-sm {
    height: 32px;
    padding: 4px 12px;
}
.ag-os .ag-btn[disabled] {
    opacity: 0.5;
    cursor: default;
}

/* ===== Поля ===== */
.ag-os .ag-form-control {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font: inherit;
    font-size: 14px;
    color: #0f172a;
    background-color: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    outline: none;
}
.ag-os select.ag-form-control {
    padding-right: 8px;
}
.ag-os .ag-form-control:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .12);
}
.ag-os .ag-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.ag-os .ag-input-group > label {
    font-weight: 500;
    color: #334155;
}
.ag-os .ag-input-group.required > label:after {
    content: " *";
    color: #ef4444;
}
.ag-os .ag-help {
    font-size: 14px;
    color: #64748b;
}
.ag-os .ag-check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    color: #334155;
    cursor: pointer;
}
.ag-os input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin: 0;
    background: #fff center / 12px no-repeat;
    border: 1.5px solid #cbd5e1;
    border-radius: 5px;
    cursor: pointer;
    transition: all .15s;
}
.ag-os input[type="checkbox"]:hover {
    border-color: #a78bfa;
}
.ag-os input[type="checkbox"]:checked {
    background-color: #7c3aed;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E");
    border-color: #7c3aed;
}
.ag-os input[type="checkbox"]:disabled {
    opacity: .5;
    cursor: default;
}
.ag-os input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .2);
}
.mia-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}
.mia-copy {
    display: flex;
    gap: 8px;
}

/* ===== Карточки ===== */
.ag-os .ag-card {
    margin-bottom: 24px;
    padding: 24px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}
.ag-os .ag-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.ag-os .ag-card-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #0f172a;
}
.ag-os .ag-card-descr {
    margin: 4px 0 0;
    color: #64748b;
}
.mia-invite {
    border-color: #c4b5fd !important;
    background: #faf8ff !important;
}
.mia-error {
    text-align: center;
}
.mia-error h3 {
    margin: 8px 0 20px;
    font-size: 18px;
    font-weight: 500;
    color: #0f172a;
}
.mia-list {
    margin: 0;
    padding: 0;
    list-style: none;
}
.mia-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}
.mia-list li:last-child {
    border-bottom: none;
}
.mia-dl {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px 16px;
    margin: 0 0 16px;
}
.mia-dl dt {
    color: #64748b;
}
.mia-dl dd {
    margin: 0;
    color: #0f172a;
}
.mia-perms {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}
.mia-perms__group {
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 10px;
}
.ag-os .mia-perms__title {
    font-weight: 600;
    color: #0f172a;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 4px;
}
.mia-danger-zone {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

/* ===== Таблицы ===== */
.ag-os .ag-table-container {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}
.ag-os .ag-table {
    width: 100%;
    border-collapse: collapse;
}
.ag-os .ag-table th {
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #334155;
    background: #fafafa;
    border-bottom: 1px solid #e2e8f0;
}
.ag-os .ag-table td {
    padding: 16px;
    vertical-align: middle;
    border-bottom: 1px solid #e2e8f0;
}
.ag-os .ag-table tbody tr:last-child td {
    border-bottom: none;
}
.ag-os .ag-table tbody tr:hover {
    background-color: #f8fafc;
}
.ag-os .ag-td-main {
    font-weight: 500;
    color: #0f172a;
}
.ag-os .ag-td-sub {
    margin-top: 4px;
    color: #64748b;
}
.ag-os .ag-empty {
    padding: 40px 16px;
    text-align: center;
    color: #64748b;
}
.mia-td-actions {
    text-align: right;
}
.mia-nowrap {
    white-space: nowrap;
}
.mia-details div + div {
    margin-top: 2px;
}
.mia-pager {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
}

/* ===== Бейджи и сообщения ===== */
.ag-os .ag-badge {
    display: inline-block;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
}
.ag-os .ag-badge-sm {
    padding: 3px 8px;
}
.ag-os .ag-badge-success {
    color: #15803d;
    background-color: #dcfce7;
}
.ag-os .ag-badge-muted {
    color: #475569;
    background-color: #f1f5f9;
}
.ag-os .ag-badge-violet {
    color: #6d28d9;
    background-color: #f5f3ff;
}
.ag-os .ag-badge-warning {
    color: #b45309;
    background-color: #fef3c7;
}
.ag-os .ag-badge-danger {
    color: #b91c1c;
    background-color: #fee2e2;
}
.ag-os .ag-alert {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 10px;
}
.ag-os .ag-alert-success {
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}
.ag-os .ag-alert-danger {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

@media (max-width: 900px) {
    .mia {
        flex-direction: column;
    }
    .mia-side {
        flex: none;
        padding: 12px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    .mia-brand {
        margin-bottom: 12px;
    }
    .mia-nav {
        display: flex;
        gap: 4px;
        overflow-x: auto;
    }
    .mia-nav__group,
    .mia-nav__item--soon {
        display: none;
    }
    .mia-nav__item + .mia-nav__item {
        margin-top: 0;
    }
    .mia-nav__item {
        white-space: nowrap;
    }
    .mia-main {
        padding: 16px;
    }
    .ag-os .ag-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .mia-row,
    .mia-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Товари, скрипти і Reels ===== */
.mia-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.ag-os .mia-filters .ag-form-control {
    width: auto;
    min-width: 200px;
}
.ag-os .mia-filters input[name="q"] {
    flex: 1 1 260px;
}
.ag-os .mia-filter-sku {
    width: 130px !important;
    min-width: 0 !important;
}
.mia-old-price {
    margin-left: 6px;
    color: #64748b;
    text-decoration: line-through;
}
.ag-td-sub.mia-old-price {
    margin-left: 0;
}
.mia-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}
.ag-os .mia-tabs__item {
    padding: 10px 16px;
    font-weight: 500;
    color: #334155;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.ag-os .mia-tabs__item:hover {
    text-decoration: none;
    color: #6d28d9;
}
.ag-os .mia-tabs__item--active {
    color: #6d28d9;
    border-bottom-color: #7c3aed;
}
.mia-bulk {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.ag-os .mia-bulk .ag-form-control {
    width: auto;
}
.mia-col-caption {
    max-width: 460px;
}
.mia-pre {
    white-space: pre-line;
    word-break: break-word;
}
.mia-clip {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.mia-caption {
    max-height: 420px;
    overflow-y: auto;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 10px;
}
.mia-quote {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #faf8ff;
    border-left: 3px solid #c4b5fd;
    border-radius: 6px;
}
.mia-subtitle {
    margin: 16px 0 8px;
    font-weight: 600;
    color: #0f172a;
}
.mia-link + .mia-link {
    margin-top: 6px;
}
.mia-link-row {
    display: grid;
    grid-template-columns: 1fr 190px;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}
.mia-mt {
    margin-top: 16px;
}
.mia-dl--top {
    margin-top: 16px;
}
.ag-os .mia-textarea {
    height: auto;
    min-height: 96px;
    padding: 10px 12px;
    resize: vertical;
}
.ag-os .mia-textarea--tall {
    min-height: 260px;
}
.ag-os .mia-file {
    padding-top: 7px;
}
.mia-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.ag-os .mia-inline .ag-form-control {
    width: auto;
}
.mia-details-box {
    margin-bottom: 16px;
}
.mia-details-box summary {
    margin-bottom: 8px;
    font-weight: 500;
    color: #6d28d9;
    cursor: pointer;
}
.mia-warn {
    color: #b45309;
}
.mia-row--even {
    grid-template-columns: 1fr 1fr;
}
.mia-mb {
    margin-bottom: 16px;
}
