:root {
    color-scheme: light;
    font-family: Inter, Roboto, "Segoe UI", Arial, sans-serif;
    --navy: #1a202c;
    --bg: #f7fafc;
    --action: #3182ce;
    --danger: #e53e3e;
    --text: #1f2937;
    --muted: #4a5568;
    --card-shadow: 0 8px 28px rgba(26, 32, 44, 0.1);
    --surface: #ffffff;
    --border: #e2e8f0;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

.hidden {
    display: none !important;
}

.layout-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    min-width: 250px;
    max-width: 250px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--navy);
    color: #f7fafc;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
}

.logo-wrap h1 {
    margin: 0;
    font-size: 1.45rem;
}

.logo-subtitle {
    margin: 0.35rem 0 0;
    color: #cbd5e0;
    font-size: 0.85rem;
}

.sidebar-nav {
    margin-top: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    border: 0;
    background: transparent;
    color: #cbd5e0;
    text-align: left;
    padding: 0.7rem 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-weight: 700;
}

.nav-item span {
    color: inherit;
}

.nav-icon {
    font-size: 1.35rem;
    line-height: 1;
    width: 1.6rem;
    text-align: center;
}

.nav-item:hover {
    color: #ffffff;
    background: rgba(247, 250, 252, 0.18);
}

.nav-item-active {
    color: #ffffff;
    background: rgba(49, 130, 206, 0.4);
    border-left: 4px solid #63b3ed;
    padding-left: calc(0.75rem - 4px);
    box-shadow: inset 0 0 0 1px rgba(99, 179, 237, 0.45);
}

.help-panel {
    background: rgba(247, 250, 252, 0.08);
    border: 1px solid rgba(247, 250, 252, 0.12);
    border-radius: 12px;
    padding: 0.75rem;
}

.help-panel h2 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.help-panel p {
    margin: 0.35rem 0;
    color: #e2e8f0;
    font-size: 0.85rem;
}

.main-content {
    margin-left: 250px;
    width: calc(100% - 250px);
    padding: 1.2rem;
    overflow: auto;
}

.status-bar {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    position: sticky;
    top: 0;
    z-index: 5;
}

.status-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
}

.status-inline {
    margin-top: 0.8rem;
}

.view {
    margin-top: 1rem;
}

.welcome-card {
    border: 1px solid #bee3f8;
    background: #ebf8ff;
}

.welcome-card h2 {
    margin: 0 0 0.4rem;
}

.welcome-text {
    margin: 0 0 0.8rem;
    color: #2d3748;
    font-size: 0.95rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}

.kpi-card h3 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted);
}

.kpi-value {
    margin: 0.4rem 0 0;
    font-size: 1.8rem;
    font-weight: 700;
}

.kpi-value.small {
    font-size: 1.1rem;
}

.kpi-card.danger .kpi-value {
    color: var(--danger);
}

.split-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
}

.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--card-shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
    margin-bottom: 0.7rem;
}

.row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6rem;
}

.input,
.textarea,
select {
    width: 100%;
    border: 1px solid #d2d6dc;
    border-radius: 8px;
    padding: 0.6rem 0.7rem;
    font-size: 0.95rem;
    background: #fff;
}

.textarea {
    resize: vertical;
}

.inline-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.button {
    border: 0;
    border-radius: 8px;
    padding: 0.58rem 0.88rem;
    cursor: pointer;
    font-weight: 600;
    background: var(--action);
    color: #fff;
}

.button-secondary {
    background: #4a5568;
}

.button-warning {
    background: #d69e2e;
    color: #1a202c;
}

.button-ghost {
    background: transparent;
    border: 1px solid #cbd5e0;
    color: #1a202c;
}

.button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.button-link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.drop-zone {
    margin-top: 0.7rem;
    border: 2px dashed #a0aec0;
    border-radius: 10px;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #4a5568;
    background: #edf2f7;
    cursor: pointer;
}

.drop-zone.drag-active {
    border-color: var(--action);
    background: #ebf8ff;
}

.mapping-wizard {
    margin-top: 0.8rem;
    border: 1px solid #cbd5e0;
    border-radius: 10px;
    padding: 0.75rem;
}

.mapping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.6rem;
    margin: 0.6rem 0;
}

.import-report {
    margin-top: 0.8rem;
    border: 1px solid #d2d6dc;
    border-radius: 8px;
    padding: 0.7rem;
}

.shop-connections-list {
    margin-top: 0.8rem;
    display: grid;
    gap: 0.55rem;
}

.shop-connection-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.65rem 0.7rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.shop-connection-item.is-active {
    border-color: #90cdf4;
    background: #ebf8ff;
}

.shop-connection-item.is-editing {
    border-color: #f6ad55;
    background: #fffaf0;
}

.shop-conn-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.table-wrap {
    overflow: auto;
}

.table-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}

.table-filters label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.86rem;
    color: var(--muted);
}

.table-filter-actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.table-pagination {
    margin-top: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.page-size-select {
    width: 92px;
    min-width: 92px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
}

.selection-col {
    width: 46px;
    text-align: center;
}

.row-select {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

tr.row-selected td {
    background: #ebf8ff;
}

tr.row-updated-flash td {
    animation: rowFlashGreen 1.4s ease-out;
}

@keyframes rowFlashGreen {
    0% {
        background: #c6f6d5;
    }

    100% {
        background: transparent;
    }
}

th,
td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.92rem;
}

th {
    background: #edf2f7;
}

.empty {
    color: #718096;
    text-align: center;
}

.history-log {
    margin: 0;
    padding-left: 1.1rem;
    max-height: 340px;
    overflow: auto;
}

.history-log li {
    margin-bottom: 0.4rem;
}

.supplier-mail-sections {
    display: grid;
    gap: 0.75rem;
}

.supplier-mail-section {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
    background: #f8fbff;
}

.supplier-mail-header {
    display: flex;
    justify-content: space-between;
    gap: 0.65rem;
    align-items: center;
    flex-wrap: wrap;
}

.supplier-mail-header h3 {
    margin: 0;
    font-size: 1rem;
}

.supplier-mail-list {
    margin: 0.55rem 0 0;
    padding-left: 1.2rem;
}

.supplier-mail-list li {
    margin-bottom: 0.3rem;
}

.supplier-mail-btn {
    white-space: nowrap;
}

.supplier-csv-btn {
    white-space: nowrap;
}

.edit-article-btn {
    padding: 0.35rem 0.55rem;
    font-size: 0.9rem;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 30;
}

.modal-card {
    width: min(520px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}

.bulk-action-bar {
    position: fixed;
    left: 270px;
    right: 20px;
    bottom: 16px;
    z-index: 25;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 0.75rem 0.9rem;
}

.bulk-action-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.bulk-quick-assign {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

#quickSupplierEmail {
    min-width: 230px;
}

.marquee-selection {
    position: fixed;
    border: 1px solid #3182ce;
    background: rgba(49, 130, 206, 0.2);
    pointer-events: none;
    z-index: 40;
}

.status {
    border-radius: 8px;
    padding: 0.7rem;
    font-weight: 600;
    font-size: 0.92rem;
}

.status-idle {
    background: #ebf8ff;
    color: #2b6cb0;
}

.status-ok {
    background: #f0fff4;
    color: #276749;
}

.status-error {
    background: #fff5f5;
    color: #c53030;
}

.hint {
    margin: 0.45rem 0 0;
    color: #4a5568;
    font-size: 0.86rem;
}

.auth-block {
    margin-top: 0.6rem;
}

.global-loader {
    position: fixed;
    inset: 0;
    background: rgba(26, 32, 44, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.spinner {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 4px solid #bee3f8;
    border-top-color: var(--action);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.legal-footer {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 1rem 0 0.5rem;
}

.legal-footer a {
    color: var(--action);
    text-decoration: none;
}

.legal-shell {
    width: min(900px, 100% - 2rem);
    margin: 1.5rem auto 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 1.2rem;
}

.legal-shell h1 {
    margin-top: 0;
}

.legal-shell h2 {
    margin-top: 1rem;
}

.legal-back {
    margin-top: 1.2rem;
}

@media (max-width: 980px) {
    .sidebar {
        position: static;
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .layout-shell {
        flex-direction: column;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .kpi-grid,
    .split-grid {
        grid-template-columns: 1fr;
    }

    .table-filters {
        grid-template-columns: 1fr;
    }

    .bulk-action-bar {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }
}
