* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    --primary: #2196F3; --primary-dark: #1976D2; --success: #4CAF50; --danger: #F44336;
    --warning: #FF9800; --dark: #E0E0E0; --gray: #90A4AE;
    --bg: #121212; --card-bg: #1E1E1E; --border: #333; --input-bg: #2C2C2C;
    --shadow: 0 2px 8px rgba(0,0,0,0.3); --radius: 12px; --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg); color: var(--dark); -webkit-font-smoothing: antialiased; overscroll-behavior: none;
}

.container { max-width: 900px; margin: 0 auto; padding: 16px; min-height: 100vh; }
.screen { min-height: 100vh; min-height: 100dvh; background: var(--bg); animation: fadeIn 0.3s ease; }
.hidden { display: none !important; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.app-logo { text-align: center; padding: 20px 0 10px; font-size: 32px; font-weight: 800; background: linear-gradient(135deg, var(--primary), #00BCD4); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.app-subtitle { text-align: center; color: var(--gray); font-size: 14px; margin-bottom: 24px; }

.card { background: var(--card-bg); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); }

.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 12px; font-weight: 600; color: var(--gray); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

input, select, textarea {
    width: 100%; padding: 14px 16px; border: 2px solid var(--border); border-radius: var(--radius-sm);
    font-size: 16px; font-family: inherit; background: var(--input-bg); color: var(--dark);
    transition: all 0.2s ease; -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(33,150,243,0.2); }
textarea { min-height: 80px; resize: vertical; line-height: 1.5; }
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='%2390A4AE' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px; cursor: pointer; }

button { border: none; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.2s ease; font-family: inherit; padding: 10px 18px; }
button:active { transform: scale(0.97); }

.btn { padding: 12px 20px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-ghost { background: transparent; color: var(--gray); width: auto; }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 20px; width: auto; }
.btn-block { width: 100%; }

/* Проекты — сетка */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 20px 0; }
.project-card { background: var(--card-bg); border-radius: var(--radius); padding: 20px 16px; text-align: center; cursor: pointer; box-shadow: var(--shadow); border: 2px solid var(--border); transition: all 0.2s ease; }
.project-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.project-card:active { border-color: var(--primary); transform: scale(0.96); }
.project-card .project-icon { font-size: 36px; margin-bottom: 8px; }
.project-card .project-name { font-size: 14px; font-weight: 600; color: var(--dark); word-break: break-word; }
.project-card .project-count { font-size: 12px; color: var(--gray); margin-top: 4px; }

/* Таблица */
.table-wrapper { background: var(--card-bg); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin: 16px 0; }
.table-header {
    display: grid;
    grid-template-columns: 28px 70px 1fr 65px 85px 85px 32px 32px;
    background: #252525; padding: 10px 4px; font-size: 9px; font-weight: 700;
    color: var(--gray); text-transform: uppercase; letter-spacing: 0.3px;
    border-bottom: 2px solid var(--border); min-width: 520px;
}
.table-row {
    display: grid;
    grid-template-columns: 28px 70px 1fr 65px 85px 85px 32px 32px;
    padding: 10px 4px; font-size: 11px; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background 0.15s; align-items: center; min-width: 520px;
}
.table-row:hover { background: #2A2A2A; }
.table-row.selected { background: #1a3a5c; border-left: 2px solid var(--primary); }

.photo-indicator { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.no-photo { background: #555; }
.conclusion-positive { color: #4CAF50; font-weight: 600; }
.conclusion-negative { color: #EF5350; font-weight: 600; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--gray); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }

/* Фото */
.photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin: 12px 0; }
.photo-thumb { aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); cursor: pointer; border: 2px solid var(--border); width: 100%; }
.photo-thumb:hover { border-color: var(--primary); }
.photo-wrapper { position: relative; }
.photo-delete { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; background: var(--danger); color: white; border: none; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.file-icon { display: flex; flex-direction: column; align-items: center; justify-content: center; background: #2A2A2A; cursor: pointer; text-align: center; padding: 8px; }
.file-icon:hover { background: #333; }

/* Навигация */
.nav-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; margin-bottom: 12px; }
.nav-title { font-size: 18px; font-weight: 700; }
.nav-back { background: none; border: none; font-size: 28px; cursor: pointer; color: var(--primary); width: auto; line-height: 1; }

.admin-fab { position: fixed; bottom: 24px; left: 24px; width: 48px; height: 48px; border-radius: 50%; background: var(--warning); color: white; font-size: 20px; border: none; cursor: pointer; box-shadow: 0 4px 16px rgba(255,152,0,0.4); z-index: 100; display: flex; align-items: center; justify-content: center; }

.error-msg { color: var(--danger); text-align: center; font-size: 14px; margin-top: 8px; padding: 8px; background: rgba(244,67,54,0.1); border-radius: var(--radius-sm); }

/* Модалки */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--card-bg); border-radius: var(--radius); padding: 24px; width: 90%; max-width: 420px; box-shadow: 0 4px 24px rgba(0,0,0,0.5); max-height: 85vh; overflow-y: auto; border: 1px solid var(--border); }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; color: var(--dark); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Просмотрщик */
.photo-viewer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: black; z-index: 300; display: flex; align-items: center; justify-content: center; }
.photo-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

@media (max-width: 768px) {
    .container { padding: 12px; }
    .table-row, .table-header { font-size: 10px; }
    .projects-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .project-card { padding: 16px 12px; }
}