:root {
    --primary-color: #2563EB;
    --primary-light: #3B82F6;
    --primary-dark: #1D4ED8;
    --secondary-color: #64748B;
    --accent-color: #EF4444;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    
    --bg-primary: #F8FAFC;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-input: #F8FAFC;
    --bg-hover: #F1F5F9;
    
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-light: #94A3B8;
    --text-white: #FFFFFF;
    
    --border-color: #E2E8F0;
    --border-light: #F1F5F9;
    --border-accent: #E2E8F0;
    
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    
    --transition: all 0.2s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-card);
    padding: 40px;
    position: relative;
    overflow: hidden;
}

h1, h2, h3 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.3;
}

h1 {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 24px;
    position: relative;
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--text-primary);
    font-weight: 600;
}

h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

.section {
    margin-bottom: 32px;
    padding: 32px;
    border-radius: var(--border-radius);
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.section:hover {
    box-shadow: var(--shadow-hover);
}

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

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    background: var(--bg-input);
    transition: var(--transition);
    color: var(--text-primary);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input:read-only, input:disabled {
    background-color: #F8FAFC;
    color: var(--text-secondary);
    border-color: var(--border-light);
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
    gap: 20px;
}

.col {
    flex: 1;
    min-width: 200px;
}

.dates-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
    gap: 20px;
    background: var(--bg-primary);
    padding: 24px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-light);
}

.dates-col {
    flex: 1;
    min-width: 200px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: white;
}

th, td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

tr {
    transition: var(--transition);
}

tr:nth-child(even) {
    background-color: var(--bg-primary);
}

tr:hover {
    background-color: var(--bg-hover);
}

table input, table select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

table input:focus, table select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-danger {
    background: var(--accent-color);
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-success {
    background: var(--success-color);
}

.btn-success:hover {
    background: #059669;
}

.btn-export {
    background: #7C3AED;
}

.btn-export:hover {
    background: #6D28D9;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

.add-task {
    margin-top: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--primary-color);
    font-weight: 500;
    padding: 12px 20px;
    border: 1.5px dashed var(--border-color);
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    background: white;
}

.add-task:hover {
    border-color: var(--primary-color);
    background: var(--bg-primary);
}

.add-task i {
    font-size: 18px;
    font-weight: bold;
}

.hidden {
    display: none;
}

.file-upload {
    margin-bottom: 20px;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.file-upload:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}


.file-upload-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 16px;
}

.file-status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.status-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    animation: spin 1s linear infinite;
}

.status-icon.success {
    animation: none;
    background: linear-gradient(135deg, #F0FDF4 0%, #DCFCE7 100%);
}

.status-icon.error {
    animation: shake 0.5s ease-in-out;
    background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
}

.status-text {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.file-upload-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-light);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: var(--transition);
}

.stat-badge:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
}

.stat-badge .stat-icon {
    font-size: 16px;
    line-height: 1;
}

.stat-badge .stat-value {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Адаптивные стили для статистики */
@media (max-width: 768px) {
    .file-upload-header {
        padding: 14px 16px;
    }
    
    .file-upload-icon {
        width: 36px;
        height: 36px;
        margin-bottom: 8px;
    }
    
    .file-upload-header h3 {
        font-size: 1rem;
    }
    
    .file-upload-close {
        width: 28px;
        height: 28px;
        top: 6px;
        right: 6px;
    }
    
    .file-status-content {
        flex-direction: column;
        align-items: stretch;
        padding: 20px;
        gap: 16px;
        text-align: center;
    }
    
    .status-icon-wrapper {
        align-self: center;
    }
    
    .status-info {
        text-align: center;
    }
    
    .refresh-btn {
        width: 100%;
        justify-content: center;
    }
    
    .file-upload-stats {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 20px;
    }
    
    .stat-divider {
        display: none;
    }
    
    .stat-item {
        padding: 12px;
        background: white;
        border-radius: var(--border-radius-sm);
        border: 1px solid var(--border-light);
        justify-content: flex-start;
    }
}

.status-completed {
    color: var(--success-color);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-completed::before {
    content: '✓';
    background: var(--success-color);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.status-pending {
    color: var(--warning-color);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-pending::before {
    content: '⋯';
    background: var(--warning-color);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.kpi-table th, .kpi-table td {
    text-align: left;
}

.kpi-table input {
    text-align: left;
}

.comments-section textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.5;
}

.alert {
    padding: 16px 20px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid;
}

.alert-success {
    background: #F0FDF4;
    color: #166534;
    border-left-color: var(--success-color);
}

.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border-left-color: var(--accent-color);
}

.alert-info {
    background: #EFF6FF;
    color: #1E40AF;
    border-left-color: var(--primary-color);
}

.alert-warning {
    background: #FFFBEB;
    color: #92400E;
    border-left-color: var(--warning-color);
}

.kpi-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.export-section {
    text-align: center;
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.download-container {
    display: none;
    width: 100%;
    max-width: 500px;
    margin-top: 20px;
}

.download-container.show {
    display: block;
}

.download-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    color: white;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.download-box h3 {
    color: white;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.download-box p {
    margin-bottom: 20px;
    opacity: 0.9;
    line-height: 1.5;
}

.download-button {
    display: inline-block;
    padding: 18px 40px;
    background: white;
    color: #2563EB;
    border-radius: 12px;
    text-decoration: none;
    font-weight: bold;
    font-size: 20px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    margin-bottom: 15px;
}

.download-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}

.download-button:active {
    transform: translateY(-1px);
}

.instructions {
    font-size: 14px;
    opacity: 0.8;
    line-height: 1.4;
    margin-top: 10px;
}

.save-status {
    padding: 15px 20px;
    border-radius: var(--border-radius-sm);
    margin: 15px 0;
    display: none;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.save-status.show {
    display: flex;
}

.save-status.processing {
    background: #EFF6FF;
    color: #1E40AF;
    border-left: 4px solid var(--primary-color);
}

.save-status.success {
    background: #F0FDF4;
    color: #166534;
    border-left: 4px solid var(--success-color);
}

.save-status.error {
    background: #FEF2F2;
    color: #991B1B;
    border-left: 4px solid var(--accent-color);
}

.mobile-orientation-hint {
    display: none;
    background: linear-gradient(135deg, #FEF2F2, #FEE2E2);
    border: 2px solid #EF4444;
    border-radius: var(--border-radius);
    padding: 20px;
    margin: 20px 0;
    text-align: center;
    animation: pulse 2s infinite;
}

.mobile-orientation-hint.show {
    display: block;
}

.orientation-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: #EF4444;
}

.orientation-text {
    color: #991B1B;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.orientation-subtext {
    color: #DC2626;
    font-size: 0.9rem;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.file-status-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 12px;
}

.status-text {
    flex: 1;
    text-align: left;
}

.refresh-btn {
    background: var(--primary-color);
    white-space: nowrap;
}

.refresh-btn:hover {
    background: var(--primary-dark);
}

.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: white;
    margin-top: 20px;
    touch-action: pan-x pan-y pinch-zoom;
    transform-origin: top left;
    scrollbar-width: thin;
}

.table-header-hint {
    display: none;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 8px;
    font-style: italic;
}

/* Улучшенные стили для мобильных устройств */
@media (max-width: 768px) {
    body {
        padding: 12px;
        -webkit-text-size-adjust: 100%;
        touch-action: pan-x pan-y pinch-zoom;
        -webkit-user-zoom: zoom;
    }
    
    .container {
        padding: 24px 20px;
        border-radius: 16px;
        min-height: 100vh;
        transform-origin: top center;
    }
    
    h1 {
        font-size: 1.75rem;
        margin-bottom: 32px;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    .section {
        padding: 24px 20px;
        margin-bottom: 24px;
        overflow: visible;
        transform-origin: top center;
    }
    
    .row {
        flex-direction: column;
        gap: 16px;
        margin: 0;
    }
    
    .col {
        width: 100%;
    }
    
    .dates-row {
        flex-direction: column;
        gap: 16px;
        margin: 0;
    }
    
    .dates-col {
        width: 100%;
    }
    
    table {
        width: auto;
        min-width: 800px;
        margin: 0;
        font-size: 14px;
        transform-origin: top left;
    }
    
    th, td {
        padding: 12px 8px;
        white-space: nowrap;
        min-width: 120px;
    }
    
    table input, table select {
        width: 100%;
        padding: 12px 10px;
        font-size: 16px;
        border: 1px solid var(--border-color);
        border-radius: 6px;
        background: white;
        min-height: 48px;
        touch-action: manipulation;
        color: var(--text-primary);
    }
    
    table input::placeholder {
        color: var(--text-light);
        font-size: 14px;
        opacity: 1;
    }
    
    table select {
        color: var(--text-primary);
        appearance: none;
        -webkit-appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 16px;
        padding-right: 40px;
    }
    
    table input[type="date"] {
        min-height: 48px;
        color: var(--text-primary);
        position: relative;
    }
    
    table input[type="date"]:not(:focus):invalid::-webkit-datetime-edit {
        color: var(--text-light);
    }
    
    table input[type="text"] {
        min-height: 48px;
    }
    
    .btn {
        padding: 16px 20px;
        font-size: 16px;
        min-height: 52px;
        min-width: 48px;
        touch-action: manipulation;
    }
    
    .kpi-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .export-section {
        flex-direction: column;
        gap: 12px;
    }
    
    .file-upload {
        padding: 20px 16px;
    }
    
    .btn:hover {
        transform: none;
    }
    
    .section:hover {
        box-shadow: var(--shadow-card);
    }
    
    .add-task {
        width: 100%;
        justify-content: center;
        margin-top: 16px;
        padding: 16px;
        min-height: 52px;
    }

    .mobile-orientation-hint {
        display: block;
    }

    .file-status-content {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .status-text {
        text-align: center;
    }

    textarea {
        font-size: 16px;
        min-height: 120px;
    }
    
    .save-status {
        font-size: 14px;
        padding: 12px 16px;
        flex-direction: column;
        text-align: center;
    }
    
    .download-box {
        padding: 20px 15px;
    }
    
    .download-button {
        padding: 16px 30px;
        font-size: 18px;
    }
    
    .table-header-hint {
        display: block;
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px;
    }
    
    .container {
        padding: 16px 12px;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 24px;
        padding-bottom: 16px;
    }
    
    h2 {
        font-size: 1.2rem;
    }
    
    .section {
        padding: 20px 16px;
        margin-bottom: 20px;
    }
    
    table {
        font-size: 13px;
        min-width: 700px;
    }
    
    th, td {
        padding: 10px 6px;
        min-width: 100px;
    }
    
    table input, table select {
        padding: 10px 8px;
        font-size: 15px;
    }

    .mobile-orientation-hint {
        padding: 16px 12px;
    }

    .orientation-icon {
        font-size: 36px;
    }

    .orientation-text {
        font-size: 1rem;
    }
    
    .download-button {
        padding: 14px 25px;
        font-size: 16px;
    }
}

@media (max-width: 1024px) and (orientation: landscape) {
    .container {
        padding: 20px;
    }
    
    .table-container {
        overflow-x: auto;
    }
    
    table {
        min-width: 900px;
    }

    .mobile-orientation-hint {
        display: none !important;
    }
    
    .section {
        padding: 20px;
    }
    
    .dates-row {
        flex-direction: row;
    }
    
    .dates-col {
        flex: 1;
    }
}

@supports (-webkit-touch-callout: none) {
    input, select, textarea {
        border-radius: 8px;
    }
    
    .btn {
        -webkit-tap-highlight-color: transparent;
    }
    
    .table-container {
        -webkit-overflow-scrolling: touch;
    }
    
    table input, table select {
        appearance: none;
        -webkit-appearance: none;
        border-radius: 6px;
    }

    body {
        user-select: none;
        -webkit-user-select: none;
        -webkit-user-drag: none;
        -webkit-touch-callout: none;
    }
    
    input[type="date"] {
        min-height: 44px;
    }
    
    .download-button {
        -webkit-tap-highlight-color: rgba(255,255,255,0.3);
    }
}

.table-container::-webkit-scrollbar {
    height: 6px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

td:empty:before {
    content: "—";
    color: var(--text-light);
}

@media (pointer: coarse) {
    .table-container {
        touch-action: pan-x pan-y pinch-zoom;
    }
    
    table {
        font-size: max(14px, 16px);
    }
    
    table input, table select {
        min-height: 44px;
    }
}
