* {
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: #f5f7fb;
    margin: 0;
    padding: 10px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.container {
    max-width: 100%;
    width: 100%;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    min-height: 95vh;
}

.header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 12px;
    padding: 16px 24px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    flex-shrink: 0;
}

.logo-img {
    height: 55px;
    width: auto;
    object-fit: contain;
    border-radius: 8px;
}

.header-text {
    display: flex;
    flex-direction: column;
}

.company-name {
    color: #ffffff;
    font-size: 30px;
    font-weight: 700;
    margin: 0;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.company-slogan {
    color: rgba(255, 255, 255, 0.8);
    font-size: 15px;
    margin: 2px 0 0 0;
    font-weight: 500;
    letter-spacing: 0.5px;
}

h1 {
    font-size: 22px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 14px 0;
    letter-spacing: -0.3px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    background: #f8fafc;
    padding: 14px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #e9edf2;
    width: 100%;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px 10px;
    flex-wrap: wrap;
    flex: 0 1 auto;
}

.control-group label {
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    white-space: nowrap;
}

select, input[type="text"], .flatpickr-input {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid #d1d9e6;
    background: white;
    font-size: 14px;
    color: #1e293b;
    outline: none;
    transition: 0.2s;
    min-width: 120px;
    -webkit-appearance: none;
    appearance: none;
    text-overflow: ellipsis;
}

#tableSelect {
    min-width: 150px;
    max-width: 220px;
}

select:focus, input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23334155' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
    cursor: pointer;
}

select option {
    padding: 4px 8px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn {
    background: #3b82f6;
    border: none;
    color: white;
    padding: 7px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid #3b82f6;
    white-space: nowrap;
    touch-action: manipulation;
    flex-shrink: 0;
}

.btn:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.btn:active {
    transform: scale(0.97);
}

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

.separator {
    width: 1px;
    height: 30px;
    background: #d1d9e6;
    flex-shrink: 0;
}

.chart-wrapper {
    position: relative;
    height: 500px;
    margin-top: 4px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e9edf2;
    padding: 16px 14px 8px 14px;
    flex: 1;
    min-height: 350px;
    width: 100%;
}

.info-box {
    margin-top: 16px;
    padding: 14px 20px;
    background: #f1f5f9;
    border-radius: 10px;
    font-size: 14px;
    color: #1e293b;
    display: flex;
    flex-wrap: wrap;
    gap: 14px 40px;
    border: 1px solid #e2e8f0;
    width: 100%;
}

.info-box .label {
    font-weight: 400;
    color: #475569;
}

.info-box span:not(.label) {
    font-weight: 500;
    color: #0f172a;
}

.no-data {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
    font-size: 18px;
}

.footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid #e9edf2;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.footer-text {
    margin: 0;
    font-size: 14px;
    color: #ffffff;
    font-weight: 400;
}

.author-name {
    font-weight: 600;
    color: #ffffff;
}

.footer-year {
    margin: 0;
    font-size: 14px;
    color: #94a3b8;
    font-weight: 300;
}


@media (max-width: 1024px) {
    .container {
        padding: 14px 16px 18px;
    }
    
    .header {
        padding: 14px 18px;
    }
    
    .company-name {
        font-size: 17px;
    }
    
    .company-slogan {
        font-size: 11px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 6px;
    }
    
    .container {
        padding: 10px 10px 14px;
        border-radius: 12px;
    }
    
    .header {
        padding: 12px 14px;
        margin-bottom: 14px;
    }
    
    .header-content {
        gap: 10px;
    }
    
    .logo-img {
        height: 40px;
    }
    
    .company-name {
        font-size: 15px;
        letter-spacing: 1px;
    }
    
    .company-slogan {
        font-size: 10px;
    }
    
    h1 {
        font-size: 17px;
        margin-bottom: 10px;
    }
    
    .controls {
        padding: 10px 12px;
        gap: 8px 12px;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .control-group {
        flex: 1 1 auto;
        min-width: calc(50% - 10px);
    }
    
    .control-group label {
        font-size: 12px;
        min-width: 50px;
    }
    
    select, input[type="text"], .flatpickr-input {
        font-size: 12px;
        padding: 5px 10px;
        min-width: 80px;
        height: 32px;
    }
    
    #tableSelect {
        min-width: 100px;
        max-width: 150px;
    }
    
    select {
        padding-right: 26px;
        background-position: right 6px center;
        background-size: 10px;
    }
    
    .btn {
        font-size: 12px;
        padding: 5px 14px;
        height: 32px;
        min-width: 70px;
    }
    
    .separator {
        display: none;
    }
    
    .chart-wrapper {
        height: 350px;
        padding: 10px 8px 4px 8px;
        min-height: 280px;
    }
    
    .info-box {
        padding: 10px 14px;
        font-size: 12px;
        gap: 8px 18px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .info-box > div {
        flex: 1 1 auto;
        min-width: calc(33% - 10px);
    }
    
    .footer {
        margin-top: 14px;
        padding-top: 12px;
    }
    
    .footer-text, .footer-year {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 4px;
    }
    
    .container {
        padding: 8px 6px 12px;
        border-radius: 8px;
    }
    
    .header {
        padding: 10px 10px;
        border-radius: 8px;
    }
    
    .logo-img {
        height: 32px;
    }
    
    .company-name {
        font-size: 13px;
        letter-spacing: 0.5px;
    }
    
    .company-slogan {
        font-size: 9px;
    }
    
    h1 {
        font-size: 15px;
        margin-bottom: 8px;
    }
    
    .controls {
        padding: 8px 8px;
        gap: 6px 8px;
        border-radius: 8px;
    }
    
    .control-group {
        min-width: calc(50% - 6px);
        flex: 1 1 calc(50% - 6px);
    }
    
    .control-group label {
        font-size: 11px;
        min-width: 40px;
    }
    
    select, input[type="text"], .flatpickr-input {
        font-size: 11px;
        padding: 4px 8px;
        min-width: 60px;
        height: 28px;
        border-radius: 6px;
    }
    
    #tableSelect {
        min-width: 80px;
        max-width: 120px;
    }
    
    select {
        padding-right: 22px;
        background-position: right 4px center;
        background-size: 8px;
    }
    
    .btn {
        font-size: 11px;
        padding: 4px 10px;
        height: 28px;
        min-width: 60px;
        border-radius: 6px;
    }
    
    .chart-wrapper {
        height: 280px;
        padding: 8px 4px 2px 4px;
        min-height: 220px;
        border-radius: 8px;
    }
    
    .info-box {
        padding: 8px 10px;
        font-size: 11px;
        gap: 6px 10px;
        border-radius: 8px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .info-box > div {
        flex: 1 1 auto;
        min-width: calc(33% - 8px);
        text-align: center;
    }
    
    .footer {
        margin-top: 10px;
        padding-top: 10px;
    }
    
    .footer-text, .footer-year {
        font-size: 10px;
    }
}

.flatpickr-calendar {
    font-size: 13px;
}

.flatpickr-day.selected {
    background: #3b82f6;
    border-color: #3b82f6;
}

.flatpickr-day:hover {
    background: #e2e8f0;
}

@media (max-width: 480px) {
    .flatpickr-calendar {
        width: 280px !important;
        font-size: 12px;
    }
    .flatpickr-days {
        width: 260px !important;
    }
    .flatpickr-day {
        width: 35px !important;
        height: 35px !important;
        line-height: 35px !important;
    }
    .flatpickr-weekdays {
        width: 260px !important;
    }
    .flatpickr-rContainer {
        width: 260px !important;
    }
}

@media (hover: none) and (pointer: coarse) {
    select, 
    input, 
    .btn {
        font-size: 16px !important; 
    }
    
    .btn:hover {
        background: #3b82f6;
    }
    
    .btn:active {
        background: #2563eb;
        transform: scale(0.96);
    }
}

#correlationGroup {
    display: none;
}

#correlationGroup label {
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    white-space: nowrap;
}

#correlationDaysSlider {
    width: 120px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #d1d9e6;
    border-radius: 2px;
    outline: none;
}

#correlationDaysSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
}

#correlationDaysSlider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
}

#correlationDaysValue {
    font-weight: 600;
    color: #3b82f6;
    min-width: 30px;
    display: inline-block;
    text-align: center;
}

#correlationInfo {
    display: none;
    background: #f0fdf4;
    border-color: #86efac;
}

#correlationInfo .label {
    color: #166534;
}

#correlationInfo span:not(.label) {
    color: #14532d;
    font-weight: 600;
}

@media (max-width: 768px) {
    #correlationGroup {
        flex: 1 1 100%;
        justify-content: flex-start;
        margin-top: 4px;
    }
    
    #correlationDaysSlider {
        width: 80px;
    }
    
    #correlationInfo {
        padding: 8px 12px;
        font-size: 11px;
        gap: 6px 12px;
        flex-direction: column;
    }
    
    #correlationInfo > div {
        flex: 1 1 auto;
        min-width: 100%;
        text-align: left;
        display: flex;
        justify-content: space-between;
        padding: 2px 0;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }
    
    #correlationInfo > div:last-child {
        border-bottom: none;
    }
}

.pump-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 20px;
	margin: 20px 0 12px;
}

.pump-card {
	background: #ffffff;
	border-radius: 16px;
	border: 1px solid #e9edf2;
	padding: 20px 18px 18px;
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
	transition: 0.2s;
	display: flex;
	flex-direction: column;
}

.pump-card:hover {
	border-color: #cbd5e1;
	box-shadow: 0 6px 14px rgba(0, 0, 0, 0.04);
}

.pump-card h3 {
	font-size: 22px;
	font-weight: 600;
	color: #0f172a;
	margin: 0 0 4px 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.pump-card .badge {
	font-size: 13px;
	font-weight: 500;
	background: #eef2ff;
	color: #4f46e5;
	padding: 2px 14px;
	border-radius: 20px;
	letter-spacing: 0.3px;
}

.pump-card .type-tag {
	font-size: 14px;
	color: #475569;
	margin-bottom: 14px;
	border-bottom: 1px dashed #e2e8f0;
	padding-bottom: 10px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.pump-stats {
	display: flex;
	flex-direction: column;
	gap: 7px;
	font-size: 15px;
	line-height: 1.5;
}

.pump-stats .row {
	display: flex;
	justify-content: space-between;
	padding: 5px 0;
	border-bottom: 1px solid #f1f5f9;
}

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

.pump-stats .label {
	color: #64748b;
	font-weight: 400;
}

.pump-stats .value {
	font-weight: 500;
	color: #0f172a;
	text-align: right;
}

.pump-stats .value.highlight {
	color: #2563eb;
	font-weight: 600;
}

.pump-stats .value.good {
	color: #16a34a;
}

.pump-stats .value.warn {
	color: #ca8a04;
}

.pump-stats .value.danger {
	color: #dc2626;
}

.pump-card .sub-section {
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid #e9edf2;
	font-size: 14px;
	color: #334155;
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 6px 10px;
}

.pump-card .sub-section span {
	background: #f8fafc;
	padding: 3px 12px;
	border-radius: 20px;
	white-space: nowrap;
}

.pump-card .sub-section .strong {
	font-weight: 600;
	color: #0f172a;
}

.status-indicator {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 14px;
	font-weight: 500;
}

.status-dot {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	display: inline-block;
	flex-shrink: 0;
	transition: all 0.3s ease;
}

.status-dot.stopped {
	background: #94a3b8;
	box-shadow: 0 0 0 2px #e2e8f0;
}

.status-dot.running {
	background: #22c55e;
	box-shadow: 0 0 0 2px #bbf7d0;
}

.status-dot.fault {
	background: #ef4444;
	box-shadow: 0 0 0 2px #fecaca;
}

.status-dot.fault-running {
	background: #ef4444;
	box-shadow: 0 0 0 2px #fecaca;
	animation: blink-red 0.8s ease-in-out infinite;
}

@keyframes blink-red {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.3; }
}

.status-text {
	color: #0f172a;
}

.status-text.stopped { color: #64748b; }
.status-text.running { color: #16a34a; }
.status-text.fault { color: #dc2626; }
.status-text.fault-running { color: #dc2626; }

.header-chart-btn {
	background: rgba(255, 255, 255, 0.15);
	border: 1px solid rgba(255, 255, 255, 0.25);
	color: white;
	padding: 8px 20px;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: 0.2s;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-left: auto;
	flex-shrink: 0;
	white-space: nowrap;
}

.header-chart-btn:hover {
	background: rgba(255, 255, 255, 0.25);
	border-color: rgba(255, 255, 255, 0.4);
	transform: translateY(-1px);
}

.header-chart-btn:active {
	transform: scale(0.97);
}

.header-chart-btn svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
}

@media (max-width: 1024px) {
	.pump-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 16px;
	}
}

@media (max-width: 768px) {
	.header-chart-btn {
		font-size: 12px;
		padding: 6px 14px;
	}
	.header-chart-btn svg {
		width: 15px;
		height: 15px;
	}
}

@media (max-width: 640px) {
	.pump-grid {
		grid-template-columns: 1fr;
		gap: 14px;
	}
	.pump-card h3 {
		font-size: 20px;
	}
	.pump-stats {
		font-size: 14px;
	}
	.pump-card .sub-section {
		font-size: 13px;
		flex-direction: column;
		align-items: flex-start;
		gap: 5px;
	}
	.status-indicator {
		font-size: 13px;
	}
	.header-chart-btn {
		font-size: 11px;
		padding: 5px 12px;
	}
}

.loading-placeholder {
	text-align: center;
	padding: 40px 20px;
	color: #94a3b8;
	font-size: 16px;
	grid-column: 1 / -1;
}

.loader {
	border: 3px solid #e9edf2;
	border-top: 3px solid #3b82f6;
	border-radius: 50%;
	width: 36px;
	height: 36px;
	animation: spin 0.9s linear infinite;
	margin: 0 auto 12px;
}

@keyframes spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

.error-box {
	background: #fef2f2;
	border: 1px solid #fecaca;
	border-radius: 12px;
	padding: 16px 20px;
	color: #991b1b;
	text-align: center;
	grid-column: 1 / -1;
}

.error-box button {
	background: #dc2626;
	border: none;
	color: white;
	padding: 6px 18px;
	border-radius: 8px;
	margin-top: 8px;
	font-weight: 500;
	cursor: pointer;
}

.error-box button:hover {
	background: #b91c1c;
}

.last-update {
	text-align: right;
	font-size: 12px;
	color: #94a3b8;
	margin: 4px 0 0 0;
}

.header .company-slogan {
	color: rgba(255, 255, 255, 0.8);
}

.container {
	min-height: 90vh;
}

h1 {
	font-size: 24px;
	font-weight: 600;
	color: #1e293b;
	margin: 6px 0 0 0;
	letter-spacing: -0.3px;
}

.subhead {
	color: #475569;
	font-size: 15px;
	margin: 2px 0 6px 0;
}

.header-content {
	display: flex;
	align-items: center;
	gap: 20px;
	width: 100%;
}

.header-text {
	flex: 1;
}

.company-name {
	font-size: 32px;
}

.company-slogan {
	font-size: 16px;
}

@media (max-width: 768px) {
	.company-name {
		font-size: 18px;
	}
	.company-slogan {
		font-size: 12px;
	}
	h1 {
		font-size: 20px;
	}
	.subhead {
		font-size: 13px;
	}
}

@media (max-width: 480px) {
	.company-name {
		font-size: 15px;
	}
	.company-slogan {
		font-size: 10px;
	}
	h1 {
		font-size: 17px;
	}
}

/* Блок заголовка + уровни */
.title-levels-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 6px 0 6px 0;
    gap: 8px 16px;
}

.title-group {
    flex: 1 1 auto;
}

.title-group h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #1e293b;
    letter-spacing: -0.3px;
}

.title-group .subhead {
    color: #475569;
    font-size: 15px;
    margin: 2px 0 0 0;
}

/* Индикаторы уровней */
.level-indicators {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    padding: 4px 0;
}

.level-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Адаптация для планшетов и мобильных */
@media (max-width: 768px) {
    .title-levels-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .level-indicators {
        align-self: flex-start;
        gap: 6px;
    }
    .level-dot {
        width: 24px;
        height: 24px;
    }
    .title-group h1 {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .level-dot {
        width: 20px;
        height: 20px;
    }
    .level-indicators {
        gap: 5px;
    }
    .title-group h1 {
        font-size: 17px;
    }
    .title-group .subhead {
        font-size: 13px;
    }
}