* { box-sizing: border-box; }

:root {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #1f2937;
    background: #f8f9fb;
    font-synthesis: none;
}

body { margin: 0; min-height: 100vh; background: #f8f9fb; }
.hidden { display: none !important; }
button, input, select { font: inherit; }

button {
    min-height: 34px;
    padding: 6px 11px;
    cursor: pointer;
    color: #374151;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 6px;
}

button:hover:not(:disabled) { background: #f3f4f6; }
button:disabled { cursor: default; opacity: .5; }

input, select {
    height: 36px;
    padding: 0 10px;
    color: #1f2937;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 6px;
    outline: none;
}

input:focus, select:focus, button:focus-visible {
    border-color: #68758a;
    box-shadow: 0 0 0 2px rgba(104, 117, 138, .15);
    outline: none;
}

label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: #596579;
    font-size: 12px;
    font-weight: 600;
}

.primary { color: #fff; background: #202938; border-color: #202938; }
.primary:hover:not(:disabled) { background: #111827; }
.full { width: 100%; }
.muted { color: #7a8495; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.login-card {
    width: 100%;
    max-width: 390px;
    padding: 28px;
    background: #fff;
    border: 1px solid #e1e5ea;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(31, 41, 55, .06);
}

.logo {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    color: #fff;
    background: #202938;
    border-radius: 7px;
    font-weight: 700;
}

.logo.small { width: 30px; height: 30px; border-radius: 6px; font-size: 12px; }
.login-card h1 { margin: 18px 0 3px; font-size: 25px; }
.login-card p { margin: 0; }
.login-card form { display: grid; gap: 16px; margin-top: 24px; }

.error {
    padding: 10px 12px;
    color: #a52a22;
    background: #fff3f2;
    border-radius: 6px;
    font-size: 13px;
}

header {
    height: 52px;
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
    align-items: center;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid #e3e6eb;
}

.brand, .user-box, .top-nav { display: flex; align-items: center; }
.brand { gap: 9px; font-size: 14px; }
.top-nav { align-self: stretch; gap: 18px; }

.nav-button {
    position: relative;
    min-height: 0;
    padding: 0 2px;
    color: #6b7280;
    background: transparent;
    border: 0;
    border-radius: 0;
    font-size: 13px;
}

.nav-button:hover:not(:disabled) { color: #1f2937; background: transparent; }
.nav-button.active { color: #111827; font-weight: 600; }
.nav-button.active::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 2px;
    background: #202938;
}

.user-box { justify-content: flex-end; gap: 12px; color: #606b7c; font-size: 13px; }
.link-button { min-height: 0; padding: 3px; color: #606b7c; background: transparent; border: 0; }
.link-button:hover:not(:disabled) { color: #111827; background: transparent; }

main { max-width: 1600px; margin: 0 auto; padding: 20px 24px 32px; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page-title h1 { margin: 0; color: #111827; font-size: 21px; line-height: 1.25; }
.page-title p { margin: 3px 0 0; font-size: 12px; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 0; }
.filters label { min-width: 180px; }
.filters label:last-child { min-width: 115px; }

.stats { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 9px; color: #737e8f; font-size: 12px; }
.stats strong { color: #4b5563; font-weight: 600; }
.stats-separator { color: #c0c5cd; }

.table-card { background: #fff; border-top: 1px solid #dfe3e8; border-bottom: 1px solid #dfe3e8; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
    color: #7a8495;
    background: #fafbfc;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .025em;
    text-align: left;
    text-transform: uppercase;
}

th, td { padding: 8px 11px; border-bottom: 1px solid #eceef1; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8f9fb; }

.product-summary { display: flex; align-items: center; gap: 9px; min-width: 220px; max-width: 350px; }
.product-image, .product-image-fallback { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 6px; }
.product-image { object-fit: cover; border: 1px solid #e2e5e9; }

.product-image-fallback {
    display: grid;
    place-items: center;
    padding: 3px;
    color: #8a94a3;
    background: #f0f2f4;
    font-size: 9px;
    line-height: 1.1;
    text-align: center;
}

.product-image + .product-image-fallback { display: none; }
.product-title { overflow: hidden; color: #283241; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.price-cell { display: grid; gap: 1px; }
.price-cell strong { color: #283241; font-weight: 600; }
.old-price { color: #9ba3af; font-size: 11px; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    color: #586273;
    background: #f0f2f4;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge.ok { color: #2f6942; background: #edf7f0; }
.badge.no { color: #7a8495; background: #f0f2f4; }

.marketplace-badge {
    min-width: 48px;
    justify-content: center;
    border: 1px solid transparent;
    font-weight: 700;
    letter-spacing: .025em;
    text-transform: uppercase;
}

.marketplace-badge.ozon {
    color: #0464c8;
    background: #e8f5ff;
    border-color: #b9ddf8;
}

.marketplace-badge.wildberries {
    color: #7a249d;
    background: #f5eafd;
    border-color: #dfc1ef;
}

.marketplace-badge.yandex {
    color: #5f4c00;
    background: #fff8d6;
    border-color: #ffcc00;
}

#accountsPage .account-card.provider-ozon {
    border-left: 2px solid #38a7e3;
}

#accountsPage .account-card.provider-wildberries {
    border-left: 2px solid #9a45bd;
}

#accountsPage .account-card.provider-yandex {
    border-left: 2px solid #ffcc00;
}

body #notificationsPage .notification-card.provider-ozon {
    border-left-color: #38a7e3;
}

body #notificationsPage .notification-card.provider-wildberries {
    border-left-color: #9a45bd;
}

body #notificationsPage .notification-card.provider-yandex {
    border-left-color: #ffcc00;
}

.optimization-page .optimization-product.provider-yandex {
    border-left-color: #ffcc00;
    background: linear-gradient(90deg, rgba(255, 204, 0, .12), #fff 18%);
}

.optimization-page .optimization-product.provider-yandex:hover {
    border-color: #ead66e;
    border-left-color: #e6b800;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0 0;
    background: #f8f9fb;
    color: #6b7280;
    font-size: 12px;
}

.message { margin: 10px 0; padding: 9px 11px; color: #315f8f; background: #eff6ff; border-radius: 6px; font-size: 13px; }
.message.error-message { color: #a52a22; background: #fff3f2; }

.accounts-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
    gap: 14px;
}

.account-provider-column {
    min-width: 0;
    display: grid;
    gap: 10px;
}

.account-provider-column-header {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 2px 7px;
    border-bottom: 2px solid #e1e5ea;
}

.account-provider-column-header h2 {
    margin: 0;
    color: #283241;
    font-size: 14px;
    font-weight: 600;
}

.account-provider-column-yandex .account-provider-column-header {
    border-bottom-color: #ffcc00;
}

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

.account-provider-empty {
    padding: 15px;
    color: #7a8495;
    background: #f8f9fb;
    border: 1px dashed #dfe3e8;
    border-radius: 7px;
    font-size: 12px;
    text-align: center;
}

.account-card { padding: 15px; background: #fff; border: 1px solid #e1e5ea; border-radius: 7px; }
.account-card.inactive { background: #fafafa; opacity: .8; }
.account-card-header, .account-actions, .account-card-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.account-card h3 { margin: 0; font-size: 15px; }
.account-card-meta { display: grid; gap: 7px; margin: 14px 0; color: #7a8495; font-size: 12px; }
.account-card-meta strong { overflow: hidden; color: #4b5563; font-weight: 500; text-overflow: ellipsis; }
.account-actions { justify-content: flex-start; }
.account-history {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 12px;
    margin-top: 12px;
    padding-top: 11px;
    border-top: 1px solid #e8ebef;
    color: #657084;
    font-size: 12px;
}
.account-history-status { min-width: 0; }
.account-history-status strong { display: block; color: #344054; font-size: 12px; font-weight: 600; }
.account-history-status span { display: block; margin-top: 3px; overflow-wrap: anywhere; }
.account-history-controls { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.account-history-controls button { min-height: 28px; padding: 5px 8px; font-size: 11px; white-space: nowrap; }
@media (max-width: 680px) {
    .account-history { grid-template-columns: 1fr; }
    .account-history-controls { justify-content: flex-start; }
}
.danger-button { color: #9a3029; }
.success-button { color: #2f6942; }

.modal-backdrop {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(17, 24, 39, .3);
}

.modal {
    width: min(100%, 460px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 14px 40px rgba(17, 24, 39, .14);
}

.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.modal-header h2, .modal-header p { margin: 0; }
.modal-header h2 { font-size: 19px; }
.modal-header p { margin-top: 3px; font-size: 12px; }
.modal-close { min-width: 32px; padding: 3px; border: 0; font-size: 22px; }
.modal form { display: grid; gap: 13px; }
.security-note { padding: 9px 10px; color: #606b7c; background: #f5f6f8; border-radius: 6px; font-size: 12px; line-height: 1.4; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.image-preview {
    position: fixed;
    z-index: 2000;
    width: 280px;
    height: 280px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 8px;
    pointer-events: none;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 7px;
    box-shadow: 0 8px 24px rgba(17, 24, 39, .12);
}

.image-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }

@media (hover: hover) and (pointer: fine) {
    .image-preview:not(.hidden) { display: flex; }
    .product-image { cursor: zoom-in; }
}

@media (max-width: 760px) {
    header { grid-template-columns: auto 1fr auto; padding: 0 14px; }
    .accounts-grid { grid-template-columns: 1fr; }
    .brand strong { display: none; }
    .top-nav { justify-content: center; }
    .user-box span { display: none; }
    main { padding: 16px 12px 26px; }
}

@media (max-width: 520px) {
    .page-title { align-items: flex-start; }
    .page-title button { flex: 0 0 auto; }
    .filters label { min-width: calc(50% - 5px); flex: 1 1 calc(50% - 5px); }
    .filters label:last-child { min-width: 120px; }
    .stats-separator { display: none; }
    .stats span:not(.stats-separator) { margin-right: 8px; }
}

@media (hover: none), (pointer: coarse) {
    .image-preview { display: none !important; }
}
