:root {
    --bg: #0f1117;
    --bg2: #1a1d27;
    --bg3: #242836;
    --accent: #6c5ce7;
    --accent2: #a29bfe;
    --text: #e8e8e8;
    --text2: #9ca3af;
    --green: #00b894;
    --red: #e17055;
    --orange: #fdcb6e;
    --border: #2d3348;
    --radius: 12px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0a0b12 0%, #12142a 40%, #1a1d3a 70%, #0f1117 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 50%, rgba(108,92,231,0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 50%, rgba(0,184,148,0.05) 0%, transparent 50%);
    animation: bgFloat 20s ease-in-out infinite;
}

@keyframes bgFloat {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-2%, 2%); }
}

.login-card {
    background: rgba(26, 29, 39, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(108,92,231,0.2);
    border-radius: 16px;
    padding: 40px;
    position: relative;
    z-index: 1;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 28px;
    color: var(--accent2);
}

.login-card .subtitle {
    text-align: center;
    color: var(--text2);
    margin-bottom: 30px;
    font-size: 14px;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text2);
    font-size: 13px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text2);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 11px 14px;
    background: rgba(36, 40, 54, 0.6);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: all 0.25s;
    backdrop-filter: blur(4px);
}

.form-group input:hover, .form-group select:hover, .form-group textarea:hover {
    border-color: rgba(108,92,231,0.3);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.1);
    background: rgba(36, 40, 54, 0.9);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    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='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: #fff;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #5a4bd1);
    box-shadow: 0 2px 8px rgba(108,92,231,0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent2), var(--accent));
    box-shadow: 0 4px 15px rgba(108,92,231,0.4);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--green), #00a884);
    box-shadow: 0 2px 8px rgba(0,184,148,0.3);
}

.btn-success:hover {
    box-shadow: 0 4px 15px rgba(0,184,148,0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--red), #d63031);
    box-shadow: 0 2px 8px rgba(225,112,85,0.3);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

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

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1a1d2e 0%, var(--bg2) 100%);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(108,92,231,0.15);
    margin-bottom: 16px;
}

.sidebar-logo h2 {
    background: linear-gradient(90deg, #a29bfe, #6c5ce7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 22px;
    letter-spacing: -0.5px;
}

.sidebar-logo span {
    color: var(--text2);
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 0 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text2);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 2px;
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(108,92,231,0.1);
    color: var(--text);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(108,92,231,0.15), rgba(108,92,231,0.05));
    color: var(--accent2);
    border-left: 3px solid var(--accent);
    padding-left: 11px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(108,92,231,0.15);
    color: var(--text2);
    font-size: 12px;
    background: rgba(0,0,0,0.1);
}

.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

/* Cards */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(108,92,231,0.1);
}

.card-header h2 {
    font-size: 18px;
    letter-spacing: -0.3px;
}

.card-header h3 {
    font-size: 16px;
    color: var(--accent2);
}

.card-header h4 {
    font-size: 14px;
}

/* Project list */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.project-card {
    background: linear-gradient(135deg, var(--bg2), var(--bg3));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--green));
    opacity: 0;
    transition: opacity 0.3s;
}

.project-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(108,92,231,0.15);
}

.project-card:hover::before {
    opacity: 1;
}

.project-card h3 {
    margin-bottom: 8px;
    font-size: 16px;
}

.project-card .meta {
    color: var(--text2);
    font-size: 13px;
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-draft { background: var(--bg3); color: var(--text2); }
.status-planning { background: #2d3a8c; color: #818cf8; }
.status-approved { background: #1a4731; color: #34d399; }
.status-in_progress { background: #4a3728; color: var(--orange); }
.status-completed { background: #1a4731; color: var(--green); }

/* Table */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(45,51,72,0.5);
    font-size: 13px;
}

tr:nth-child(even) td {
    background: rgba(108,92,231,0.02);
}

tr:nth-child(odd) td {
    background: rgba(0,0,0,0.1);
}

table input, table select {
    transition: all 0.2s;
}

table input:hover, table select:hover {
    border-color: rgba(108,92,231,0.4);
    box-shadow: 0 0 8px rgba(108,92,231,0.15);
}

table input:focus, table select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(108,92,231,0.25);
    background: rgba(36,40,54,0.95);
}

th {
    color: var(--text2);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(108,92,231,0.05);
}

tr:hover td {
    background: rgba(108,92,231,0.08);
    transition: all 0.2s;
    box-shadow: inset 0 0 20px rgba(108,92,231,0.05);
}

tr:hover {
    cursor: pointer;
}

.text-right { text-align: right; }

.total-row td {
    font-weight: 700;
    font-size: 15px;
    border-top: 2px solid var(--accent);
    background: rgba(108,92,231,0.08);
    color: var(--accent2);
}

/* SVG container */
.svg-container {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    overflow: auto;
    max-height: none;
}

.svg-container svg {
    width: 100%;
    height: auto;
    min-height: 400px;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text2);
    padding: 20px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    color: var(--text2);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.tab:hover { color: var(--text); background: rgba(108,92,231,0.05); border-radius: 8px 8px 0 0; }
.tab.active { color: var(--accent2); border-bottom-color: var(--accent); background: rgba(108,92,231,0.08); border-radius: 8px 8px 0 0; }

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 14px 24px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    z-index: 9999;
    animation: slideIn 0.3s ease;
}

.toast-success { background: var(--green); }
.toast-error { background: var(--red); }

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

/* Two columns form */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ===================== MOBILE ===================== */
@media (max-width: 768px) {
    /* Сайдбар — скрываем, показываем гамбургер */
    .app-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex-direction: row;
        padding: 10px;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .sidebar-logo { padding: 0 10px 0 0; border-bottom: none; margin-bottom: 0; }
    .sidebar-logo h2 { font-size: 16px; }
    .sidebar-logo span { display: none; }
    .sidebar-nav { display: flex; flex-direction: row; gap: 4px; padding: 0; flex: 1; }
    .nav-item { padding: 6px 12px; font-size: 12px; white-space: nowrap; border-left: none !important; padding-left: 12px !important; }
    .nav-item.active { border-left: none !important; border-bottom: 2px solid var(--accent); border-radius: 4px; }
    .sidebar-footer { display: none; }

    /* Контент */
    .main-content { padding: 12px; }

    /* Формы */
    .form-grid { grid-template-columns: 1fr; gap: 10px; }

    /* Таблицы */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 600px; font-size: 11px; }
    th, td { padding: 6px 8px; }

    /* Карточки проектов */
    .project-grid { grid-template-columns: 1fr; }

    /* Табы */
    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
    .tab { padding: 8px 14px; font-size: 12px; white-space: nowrap; }

    /* Кнопки */
    .btn { padding: 8px 14px; font-size: 12px; }
    .btn-full { width: 100%; }

    /* Шапка проекта */
    .card-header { flex-direction: column; align-items: flex-start; gap: 8px; }

    /* Summary карточки */
    .estimate-summary { grid-template-columns: 1fr 1fr; }
    .summary-card .value { font-size: 18px; }

    /* Модалки */
    .modal { width: 95%; padding: 20px; max-height: 90vh; }
    .choice-grid { grid-template-columns: 1fr; }

    /* Визард */
    .wizard-steps { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .step-label { display: none; }
    .wizard-step { padding: 6px 8px; }
    .option-cards { gap: 6px; }
    .option-card { padding: 8px 12px; min-width: 70px; font-size: 12px; }

    /* Plan tabs */
    .plan-tabs { flex-wrap: wrap; }
    .plan-tab { padding: 6px 12px; font-size: 11px; }

    /* SVG */
    .svg-container { padding: 8px; }

    /* Рендеры */
    .renders-grid { grid-template-columns: 1fr; }

    /* Логин */
    .login-card { width: 95%; padding: 24px; }

    /* Guide блок на главной */
    .card-header h2 { font-size: 16px; }

    /* Check grid */
    .check-grid { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
    .estimate-summary { grid-template-columns: 1fr; }
    .sidebar-logo h2 { font-size: 14px; }
    table { min-width: 500px; }
}

/* Estimate summary */
.estimate-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.summary-card {
    background: linear-gradient(135deg, var(--bg3), var(--bg2));
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    transition: all 0.2s;
}

.summary-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.summary-card .value {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(90deg, var(--accent2), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.summary-card .label {
    font-size: 11px;
    color: var(--text2);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Choice cards (new project) */
.choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.choice-card {
    background: var(--bg3);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.choice-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
}

.choice-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.choice-card h3 { margin-bottom: 8px; }
.choice-card p { color: var(--text2); font-size: 13px; }

/* Wizard steps */
.wizard-steps {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 20px;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text2);
    white-space: nowrap;
}

.wizard-step.active {
    background: var(--accent);
    color: #fff;
}

.wizard-step.done {
    color: var(--green);
    cursor: pointer;
}

.step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.wizard-step.active .step-num { background: rgba(255,255,255,0.2); }
.wizard-step.done .step-num { background: var(--green); color: #fff; }

.step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    min-width: 16px;
}

.step-label { display: inline; }

@media (max-width: 768px) {
    .step-label { display: none; }
    .wizard-steps { padding: 0; }
}

/* Option cards (material/room selection) */
.option-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.option-card {
    background: var(--bg3);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 12px 18px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    min-width: 90px;
    font-size: 14px;
}

.option-card:hover { border-color: var(--accent); }
.option-card.selected { border-color: var(--accent); background: rgba(108,92,231,0.15); color: var(--accent2); }

.opt-icon { font-size: 20px; margin-bottom: 4px; }

/* Check grid */
.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.check-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/* Upload zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(108,92,231,0.05);
}

/* Range input */
/* Renders gallery */
.renders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.render-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.2s;
}

.render-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.render-card img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
}

.render-label {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text2);
    text-align: center;
}

/* Plan sub-tabs */
.plan-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg3);
    border-radius: 8px;
    padding: 4px;
}

.plan-tab {
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text2);
    transition: all 0.2s;
}

.plan-tab:hover { color: var(--text); }
.plan-tab.active { background: var(--accent); color: #fff; }

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    height: 6px;
}

/* Voice input */
.voice-input {
    position: relative;
}

.voice-input textarea {
    width: 100%;
    padding: 10px 50px 10px 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    resize: vertical;
    font-family: inherit;
}

.voice-input textarea:focus { border-color: var(--accent); }

.voice-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--bg2);
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-btn:hover { background: var(--accent); }
.voice-btn.recording {
    background: var(--red);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(225,112,85,0.4); }
    50% { box-shadow: 0 0 0 10px rgba(225,112,85,0); }
}
