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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f0f2f5;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1a472a, #2d5a3b);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
}

.settings-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

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

/* Filters */
.filters {
    padding: 20px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

select, input, button {
    padding: 10px 16px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
}

select:focus, input:focus {
    outline: none;
    border-color: #2d5a3b;
    box-shadow: 0 0 0 3px rgba(45,90,59,0.1);
}

button {
    background: #2d5a3b;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

button:hover:not(:disabled) {
    background: #1a472a;
}

button:disabled, select:disabled, input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.small-btn {
    padding: 8px 12px;
    font-size: 16px;
    background: #6c757d;
}

.small-btn:hover {
    background: #5a6268;
}

.filter-group-wide {
    flex: 1;
    min-width: 280px;
}

.material-selectors {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}

.sensor-material-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sensor-material-row label {
    font-size: 12px;
    font-weight: 600;
    color: #444;
    text-transform: none;
    letter-spacing: 0;
}

.sensor-material-row select,
.material-selectors select {
    min-width: 220px;
    width: 100%;
}

.hint-text {
    font-size: 13px;
    color: #888;
    margin: 0;
}

/* Подсветка столбцов отчёта */
.report-table th.col-volume,
.report-table td.col-volume {
    background-color: rgba(52, 152, 219, 0.08);
}

.report-table th.col-weight,
.report-table td.col-weight {
    background-color: rgba(39, 174, 96, 0.08);
}

.report-table th.col-rate,
.report-table td.col-rate {
    background-color: rgba(241, 196, 15, 0.1);
}

.report-table th.col-area,
.report-table td.col-area {
    background-color: rgba(149, 165, 166, 0.06);
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px;
    font-size: 18px;
    color: #2d5a3b;
    display: none;
}

/* Results */
.results {
    display: none;
    padding: 24px;
}

/* Cards */
.cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 4px solid;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.card .value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.card .label {
    font-size: 14px;
    color: #666;
}

.card.seed { border-left-color: #27ae60; }
.card.fertilizer { border-left-color: #e67e22; }
.card.area { border-left-color: #8e44ad; }
.card.work { border-left-color: #f39c12; }

/* Chart */
.chart-container {
    width: 100%;
    min-height: 500px;
    margin-bottom: 30px;
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Tables */
.field-table, .works-table {
    margin-top: 30px;
    overflow-x: auto;
}

h3 {
    margin-bottom: 16px;
    color: #1a472a;
    font-size: 18px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

th, td {
    border: 1px solid #e0e0e0;
    padding: 12px 10px;
    text-align: left;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

tr:hover {
    background: #f5f5f5;
}

tr.warning {
    background-color: #fff3cd;
    border-left: 3px solid #ffc107;
}

tr.warning:hover {
    background-color: #ffe69e;
}

.warning-text {
    color: #856404;
    font-size: 11px;
    display: inline-block;
    margin-top: 4px;
}

/* Debug */
.debug {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 12px 16px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 20px;
    border-top: 1px solid #333;
}

.debug div {
    margin: 2px 0;
}

/* Modal */
.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;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 500px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-large {
    width: 700px;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #1a472a;
}

.modal-content label {
    display: block;
    margin: 15px 0 5px 0;
    font-weight: 600;
    color: #333;
}

.modal-content input {
    width: 100%;
    padding: 10px;
    margin: 5px 0;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 8px;
    display: none;
}

/* Material tabs */
.material-tabs, .sensor-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.tab-btn {
    background: none;
    color: #666;
    padding: 10px 20px;
    border-radius: 8px 8px 0 0;
    margin-bottom: -1px;
}

.tab-btn.active {
    background: white;
    color: #2d5a3b;
    border-bottom: 2px solid #2d5a3b;
}

.material-tab, .sensor-tab {
    display: none;
}

.material-tab.active, .sensor-tab.active {
    display: block;
}

.material-list {
    margin: 15px 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.material-list-header {
    display: grid;
    grid-template-columns: 1fr 100px 80px;
    background: #f8f9fa;
    padding: 10px;
    font-weight: 600;
    border-bottom: 1px solid #e0e0e0;
}

.material-row {
    display: grid;
    grid-template-columns: 1fr 100px 80px;
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
}

.material-row:last-child {
    border-bottom: none;
}

.material-row .default-badge {
    background: #27ae60;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
}

.material-row button {
    padding: 4px 8px;
    font-size: 12px;
    background: #dc3545;
    margin-right: 5px;
}

.material-row .set-default-btn {
    background: #6c757d;
}

.add-material {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.add-material h4 {
    margin-bottom: 10px;
    color: #555;
}

.add-material input {
    width: auto;
    display: inline-block;
    margin-right: 10px;
}

/* Calibration table */
.calibration-table {
    margin: 15px 0;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.calibration-row {
    display: grid;
    grid-template-columns: 100px 100px 60px;
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
}

.calibration-row.header {
    background: #f8f9fa;
    font-weight: 600;
    border-bottom: 1px solid #e0e0e0;
}

.calibration-row button {
    padding: 4px 8px;
    font-size: 11px;
    background: #dc3545;
}

.add-calibration {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.add-calibration input {
    width: 120px;
}

.info-text {
    color: #666;
    font-size: 13px;
    margin-bottom: 15px;
}

.reset-btn {
    margin-top: 15px;
    background: #6c757d;
    padding: 8px 16px;
}

.reset-btn:hover {
    background: #5a6268;
}

/* Responsive */
@media (max-width: 768px) {
    .cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .material-selectors {
        flex-wrap: wrap;
    }

    .modal-large {
        width: 95%;
    }
}