* {
    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;
}

.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: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.header h1 {
    color: #6a1b9a;
    font-size: 24px;
}

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

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

.tab {
    flex: 1;
    padding: 16px 30px;
    background: #ffe0b2;
    border: 2px solid #ffb74d;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    color: #e65100;
    cursor: pointer;
    transition: all 0.2s;
}

.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;
    gap: 15px;
    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;
    gap: 20px;
    margin-bottom: 20px;
}

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

.summary-block {
    background: rgb(255, 242, 242);
    border: 1px solid rgb(255, 200, 200);
    border-radius: 8px;
    padding: 15px 20px;
    min-width: 300px;
    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;
    gap: 15px;
}

.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;
    min-width: 150px;
}

.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;
    min-width: 150px;
}

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

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

.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;
    min-width: 150px;
}

.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: 5% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 700px;
    position: relative;
}

.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;
}
