* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
    color: #333;
}

/* Страница логина */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.landing-container {
    width: 100%;
    max-width: 450px;
}

.landing-header {
    text-align: center;
    margin-bottom: 30px;
}

.landing-header h1 {
    color: #6a1b9a;
    font-size: 28px;
    margin-bottom: 8px;
}

.landing-subtitle {
    color: #757575;
    font-size: 16px;
}

.auth-block {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

.auth-tabs {
    display: flex;
}

.auth-tab {
    flex: 1;
    padding: 14px;
    border: none;
    background: #f5f5f5;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    color: #757575;
    transition: all 0.2s;
}

.auth-tab.active {
    background: white;
    color: #6a1b9a;
    box-shadow: 0 -2px 0 #6a1b9a inset;
}

.auth-form {
    padding: 30px;
}

.success-message {
    color: #2e7d32;
    margin-top: 10px;
    text-align: center;
    font-size: 14px;
}

.admin-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    margin-bottom: 30px;
    text-align: center;
    color: #6a1b9a;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

button[type="submit"] {
    width: 100%;
    padding: 12px;
    background: #6a1b9a;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

button[type="submit"]:hover {
    background: #4a148c;
}

.error-message {
    color: #d32f2f;
    margin-top: 10px;
    text-align: center;
}

/* Dashboard */
.header {
    background: white;
    padding: 16px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.header h1 {
    color: #6a1b9a;
    font-size: clamp(16px, 2.5vw, 24px);
    white-space: nowrap;
}

.container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
}

/* Вкладки */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.tab {
    flex: 1 1 200px;
    padding: 16px 20px;
    background: #ffe0b2;
    border: 2px solid #ffb74d;
    border-radius: 8px;
    font-size: clamp(14px, 2vw, 18px);
    font-weight: 600;
    color: #e65100;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.tab:hover {
    background: #ffcc80;
}

.tab.active {
    background: #ff9800;
    border-color: #f57c00;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.cargo-placeholder {
    background: white;
    border-radius: 8px;
    padding: 60px;
    text-align: center;
    color: #757575;
    font-size: 18px;
}

.cargo-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
}

.order-history-cell {
    text-align: center;
    font-weight: 500;
    color: #388e3c;
    position: relative;
    white-space: nowrap;
}

.total-ordered-cell {
    text-align: center;
    font-weight: 600;
    color: #e65100;
}

.total-will-cell {
    text-align: center;
    font-weight: 600;
    color: #333;
}

.total-will-red {
    background: #ffcdd2;
}

.total-will-yellow {
    background: #fff9c4;
}

.total-will-green {
    background: #c8e6c9;
}

.am-cell {
    text-align: center;
    padding: 4px;
}

.am-header {
    width: 40px;
    text-align: center;
}

.star {
    cursor: pointer;
    font-size: 20px;
    color: #e0e0e0;
    transition: color 0.2s;
    user-select: none;
}

.star:hover {
    color: #ffd54f;
}

.star-active {
    color: #ffc107;
}

.fav-row {
    background: #fffde7;
}

.resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    background: transparent;
}

.resize-handle:hover {
    background: rgba(106, 27, 154, 0.3);
}

.photo-tooltip {
    display: none;
    position: absolute;
    z-index: 2000;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    padding: 5px;
    pointer-events: none;
}

.photo-tooltip img {
    max-width: 300px;
    max-height: 300px;
    border-radius: 6px;
    display: block;
}

.name-cell {
    cursor: pointer;
}

.photo-tooltip {
    pointer-events: auto;
}

.btn-edit-item {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #9e9e9e;
    padding: 2px 4px;
    margin-left: 4px;
    border-radius: 3px;
    transition: all 0.2s;
}

.btn-edit-item:hover {
    color: #1565c0;
    background: #e3f2fd;
}

.order-date-header {
    white-space: nowrap;
}

.date-picker-hidden {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.btn-calendar {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 1px 3px;
    margin-left: 2px;
    border-radius: 3px;
    transition: all 0.2s;
}

.btn-calendar:hover {
    background: rgba(255,255,255,0.3);
}

.btn-delete-order {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: #e0e0e0;
    margin-left: 6px;
    padding: 1px 5px;
    border-radius: 3px;
    transition: all 0.2s;
}

.btn-delete-order:hover {
    color: white;
    background: #d32f2f;
}

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

.controls {
    background: white;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 1 300px;
}

.summary-block {
    background: rgb(255, 242, 242);
    border: 1px solid rgb(255, 200, 200);
    border-radius: 8px;
    padding: 15px 20px;
    min-width: 0;
    flex: 0 1 320px;
    font-size: 14px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    gap: 20px;
}

.summary-row span:last-child {
    font-weight: 600;
    white-space: nowrap;
}

.summary-total {
    font-weight: 600;
    color: #6a1b9a;
}

.summary-divider {
    border-top: 1px solid rgb(255, 200, 200);
    margin: 8px 0;
}

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

.update-info {
    color: #757575;
    font-size: 14px;
}

.btn-primary {
    background: #6a1b9a;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.btn-primary:hover {
    background: #4a148c;
}

.btn-primary:disabled,
.btn-fbo:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-fbo {
    background: #1565c0;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.btn-fbo:hover {
    background: #0d47a1;
}

.btn-prices {
    background: #2e7d32;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.btn-prices:hover {
    background: #1b5e20;
}

.btn-prices:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-save {
    background: #ff6f00;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.btn-save:hover {
    background: #e65100;
}

.btn-save:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #bdbdbd;
}

.price-cell {
    text-align: right;
    font-weight: 500;
}

.discount-cell {
    text-align: center;
    font-weight: 600;
    color: #d32f2f;
}

.btn-secondary {
    background: #757575;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #616161;
}

.btn-settings {
    background: #5c6bc0;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-settings:hover {
    background: #3f51b5;
}

.btn-user {
    background: #00897b;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-user:hover {
    background: #00695c;
}

.table-container {
    background: white;
    border-radius: 8px;
    overflow-x: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
}

#cargoTable {
    table-layout: fixed;
    font-size: 12px;
}

#cargoTable th {
    font-size: 12px;
}

#allProductsTable {
    table-layout: fixed;
}

thead {
    background: #f5f5f5;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

th {
    font-weight: 600;
    color: #6a1b9a;
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 22px;
    transition: background 0.2s;
}

th:hover {
    background: #ede7f6;
}

th::after {
    content: '⇅';
    position: absolute;
    right: 6px;
    opacity: 0.3;
    font-size: 12px;
}

th.sort-asc::after {
    content: '▲';
    opacity: 0.8;
}

th.sort-desc::after {
    content: '▼';
    opacity: 0.8;
}

.stock-cell {
    font-weight: 600;
    color: #1976d2;
}

.ordered-cell {
    font-weight: 600;
    color: #388e3c;
}

.order-input {
    width: 50px;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 13px;
}

.btn-add {
    background: #388e3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.btn-add:hover {
    background: #2e7d32;
}

.btn-history {
    background: #1976d2;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.btn-history:hover {
    background: #1565c0;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #757575;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    background: white;
    margin: 3% auto;
    padding: 24px;
    border-radius: 8px;
    width: 92%;
    max-width: 700px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #757575;
}

.close:hover {
    color: #333;
}

.history-table {
    margin-top: 20px;
}

#lastUpdate {
    color: #757575;
    font-size: 14px;
}

/* Global image rule */
img {
    max-width: 100%;
    height: auto;
}

/* Base responsive breakpoints */
@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
    }

    .header h1 {
        font-size: 16px;
    }

    .top-panel {
        flex-direction: column;
    }

    .summary-block {
        flex: 1 1 100%;
    }

    .cargo-header {
        flex-wrap: wrap;
    }

    .modal-content {
        width: 96%;
        margin: 2% auto;
        padding: 16px;
    }

    .admin-section {
        padding: 12px;
        overflow-x: auto;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }

    .tabs {
        flex-direction: column;
    }

    .control-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ============================================================
   Integration Pages — Unified Styles
   Usage: set --int-accent on container, e.g. style="--int-accent:#1565c0"
   ============================================================ */
.int-page-layout { display:flex; gap:32px; flex-wrap:wrap; padding-top:20px; }
.int-page-form { flex:1 1 500px; background:white; border-radius:12px; padding:32px; box-shadow:0 2px 12px rgba(0,0,0,0.06); }
.int-page-help { flex:0 1 320px; border-radius:12px; padding:24px; border:1px solid var(--int-help-border, #ede7f6); background:var(--int-help-bg, #f8f9ff); }
.int-page-help h3 { color:var(--int-accent); font-size:16px; margin-bottom:12px; }
.int-page-help ol { padding-left:20px; font-size:14px; color:#555; line-height:1.8; }
.int-page-help-link { color:var(--int-accent); font-size:13px; cursor:pointer; margin-top:12px; display:inline-block; }
.int-page-section { margin-bottom:24px; }
.int-page-section-title { font-size:15px; font-weight:600; color:var(--int-accent); margin-bottom:12px; padding-bottom:6px; border-bottom:1px solid var(--int-help-border, #ede7f6); }
.int-page-form .form-group { margin-bottom:16px; }
.int-page-form .form-group label { font-size:14px; font-weight:500; margin-bottom:4px; display:block; }
.int-page-form .form-group input,
.int-page-form .form-group textarea,
.int-page-form .form-group select { width:100%; padding:10px 12px; border:1px solid #ddd; border-radius:8px; font-size:14px; box-sizing:border-box; }
.int-page-form .form-group input:focus,
.int-page-form .form-group textarea:focus,
.int-page-form .form-group select:focus { border-color:var(--int-accent); box-shadow:0 0 0 3px rgba(0,0,0,0.05); outline:none; }
.int-page-btn { width:100%; padding:14px; background:var(--int-accent); color:white; border:none; border-radius:8px; font-size:16px; font-weight:600; cursor:pointer; }
.int-page-btn:hover { filter:brightness(0.85); }
.int-page-btn:disabled { opacity:0.5; cursor:not-allowed; }
.int-page-btn-secondary { background:#757575; }
.int-page-btn-secondary:hover { background:#616161; }
.int-page-toggle { display:flex; align-items:center; gap:10px; padding:12px 0; }
.int-page-toggle input { width:auto; }
.int-page-toggle label { margin:0; font-size:14px; cursor:pointer; }
.int-page-toggle .toggle-hint { font-size:12px; color:#9e9e9e; }
.int-page-optional { font-size:12px; color:#9e9e9e; font-style:italic; margin-bottom:12px; }
.int-page-status { text-align:center; margin-top:12px; font-size:14px; }

/* ============================================================
   Integration Page — Info Panel, Modals, Badges
   ============================================================ */

/* Информационная панель */
.int-info-panel {
    display: flex;
    gap: 12px;
    align-items: center;
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    font-size: 14px;
    color: #555;
}
.int-info-panel b { color: #6a1b9a; }

/* Модальные окна */
.int-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.int-modal.open { display: flex; }
.int-modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.int-modal-content h3 {
    margin: 0 0 16px 0;
    color: #6a1b9a;
    font-size: 16px;
}
.int-modal-close {
    position: absolute;
    top: 12px; right: 16px;
    font-size: 22px;
    cursor: pointer;
    color: #757575;
    background: none;
    border: none;
    line-height: 1;
}
.int-modal-close:hover { color: #d32f2f; }
.int-modal-body { font-size: 14px; color: #555; line-height: 1.6; margin-bottom: 20px; }
.int-modal-body p { margin: 0 0 8px; }
.int-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.int-modal-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
    background: #6a1b9a;
    color: white;
}
.int-modal-btn:hover { background: #7b1fa2; }
.int-modal-btn-cancel { background: #757575; }
.int-modal-btn-cancel:hover { background: #616161; }

/* Бейдж «Основной» — зелёный стиль */
.int-card-badge-primary {
    background: #e8f5e9;
    color: #2e7d32;
}


/* === SaaS Upgrade Modal === */
.upgrade-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: upgradeModalFadeIn 0.2s ease;
}
@keyframes upgradeModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.upgrade-modal-box {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: upgradeModalSlideUp 0.3s ease;
}
@keyframes upgradeModalSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.upgrade-modal-icon {
    font-size: 48px;
    margin-bottom: 16px;
}
.upgrade-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #333;
    margin: 0 0 8px;
}
.upgrade-modal-message {
    font-size: 14px;
    color: #757575;
    margin: 0 0 16px;
    line-height: 1.5;
}
.upgrade-modal-plan {
    background: #f3e5f5;
    color: #6a1b9a;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
}
.upgrade-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.upgrade-modal-btn-primary {
    background: #6a1b9a;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.upgrade-modal-btn-primary:hover {
    background: #4a148c;
}
.upgrade-modal-btn-secondary {
    background: #f5f5f5;
    color: #757575;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}
.upgrade-modal-btn-secondary:hover {
    background: #e0e0e0;
}
