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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f4f4;
    -webkit-text-size-adjust: 100%;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 15px;
}

header {
    background: #333;
    color: white;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 12px;
}

header h1 {
    text-align: center;
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.main-nav {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.main-nav a {
    color: white;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 8px;
    transition: background-color 0.3s;
    font-size: 14px;
}

.main-nav a:hover, .main-nav a:active {
    background-color: rgba(255,255,255,0.2);
}

/* Формы */
.form-group {
    margin-bottom: 1.2rem;
}

label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: bold;
    font-size: 16px;
}

select, input[type="text"], input[type="number"] {
    width: 100%;
    padding: 14px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
    background-color: white;
}

select {
    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='currentColor' 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: 20px;
    padding-right: 40px;
}

/* Кнопки */
.btn-primary, .btn-success, .btn-secondary {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 1rem;
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

/* Страница визита */
.visit-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.visit-container h2 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    text-align: center;
}

.visit-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.visit-info p {
    margin-bottom: 8px;
    font-size: 15px;
}

/* Чек-лист */
.checklist-items {
    margin-bottom: 20px;
}

.checklist-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.checklist-item:active {
    border-color: #007bff;
}

.checklist-item.required {
    border-left: 5px solid #dc3545;
}

.checklist-item label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.checklist-item input[type="checkbox"] {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
    margin-top: 2px;
}

.item-description {
    flex: 1;
    line-height: 1.4;
}

.percentage-input {
    margin-top: 12px;
    padding-left: 36px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.percentage-input input {
    width: 80px;
    padding: 10px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
}

.percentage-input span {
    font-size: 13px;
    color: #666;
}

/* Кнопки формы */
.form-actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-actions button {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    min-height: 52px;
}

/* Форма начала визита */
.start-visit-form {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.start-visit-form h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    text-align: center;
}

/* Дашборд продаж */
.sales-dashboard {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.sales-dashboard h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
    gap: 10px;
}

.dashboard-total {
    font-size: 1.1rem;
    font-weight: bold;
}

.machine-status {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
}

.machine-status .status-icon {
    margin-right: 10px;
    font-size: 1.2rem;
}

.machine-status .machine-name {
    flex: 1;
    font-weight: 500;
    font-size: 14px;
}

.machine-status .sales-count {
    font-weight: bold;
    color: #333;
    font-size: 16px;
}

.status-online { color: #28a745; }
.status-offline { color: #dc3545; }

/* Админ панель */
.admin-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 15px;
}

.admin-container h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
}

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

.admin-section h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.machine-item {
    border: 1px solid #ddd;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 10px;
    background: #f9f9f9;
}

.machine-stats {
    margin-top: 8px;
    font-size: 13px;
    color: #666;
}

/* Отчеты */
.reports-container {
    max-width: 100%;
    margin: 0 auto;
}

.reports-container h2 {
    font-size: 1.3rem;
    margin-bottom: 15px;
}

.report-filters {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
}

.report-filters button {
    margin-top: 0;
}

/* Вкладки */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: #f0f0f0;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.tab-btn:hover { background: #e0e0e0; }
.tab-btn.active { background: #007bff; color: white; }

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

.report-card {
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 15px;
}

.report-card h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.reports-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Таблица прогнозов */
.forecast-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.forecast-table th, .forecast-table td {
    padding: 8px 5px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.forecast-table th {
    background: #f0f0f0;
    font-weight: 500;
    font-size: 12px;
}

.forecast-table tr.warning { background: #fff3cd; }
.forecast-table tr.critical { background: #f8d7da; }

.forecast-table .stock-input {
    width: 55px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.forecast-table .btn-save {
    padding: 5px 8px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

/* Таблица склада */
.warehouse-table {
    width: 100%;
    border-collapse: collapse;
}

.warehouse-table th, .warehouse-table td {
    padding: 10px 5px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.warehouse-table th { background: #f0f0f0; }

.warehouse-table .stock-input {
    width: 70px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.warehouse-table .btn-save {
    padding: 5px 10px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Статистика */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-item {
    text-align: center;
    padding: 15px 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.stat-value {
    font-size: 22px;
    font-weight: bold;
    color: #007bff;
}

.error { color: #dc3545; }

/* Скролл истории */
#serviceHistory > div:last-child {
    max-height: 300px;
    overflow-y: auto;
}

/* Десктоп */
@media (min-width: 768px) {
    .container { max-width: 900px; }
    .report-filters { flex-direction: row; align-items: flex-end; }
    .reports-grid { grid-template-columns: 1fr 1fr; display: grid; }
    .form-actions { flex-direction: row; }
    .form-actions button { width: auto; flex: 1; }
    .tabs { flex-direction: row; }
    .tab-btn { flex: none; padding: 12px 24px; }
}
