:root {
    --bg-color: #0a0a0a;
    --text-color: #ffffff;
    --accent-orange: #ff6b00;
    --accent-orange-glow: rgba(255, 107, 0, 0.3);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-bg-hover: rgba(255, 255, 255, 0.1);
    --secondary-bg: #111111;
    --border-color: rgba(255, 107, 0, 0.2);
    --success-color: #48bb78;
    --error-color: #f56565;
    --glass-blur: 20px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #000000;
    color: var(--text-color);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before { display: none; }

.container {
    max-width: 600px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

/* === Навигация === */
.nav {
    display: flex;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--glass-border);
    padding: 4px;
    margin: 4px 8px 8px;
    border-radius: 16px;
    flex-shrink: 0;
}

.nav-btn {
    flex: 1;
    padding: 10px 6px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    -webkit-user-select: none;
    user-select: none;
}

.nav-btn:hover {
    color: var(--text-color);
    background: var(--glass-bg-hover);
}

.nav-btn.active {
    color: var(--accent-orange);
    background: rgba(255, 107, 0, 0.1);
    box-shadow: 0 0 20px rgba(255, 107, 0, 0.15);
}

.nav-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* === Вкладки === */
.tab { display: none; flex: 1; overflow-y: auto; padding: 8px 12px 12px; }
.tab.active { display: flex; flex-direction: column; }

/* === Заголовки === */
h2 {
    font-size: 22px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--accent-orange), #ff9500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    stroke: var(--accent-orange);
}

/* === Формы === */
.info-card {
    margin-bottom: 12px;
    padding: 14px 16px;
    background: rgba(255, 107, 0, 0.08);
    border: 1px solid rgba(255, 107, 0, 0.18);
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.5;
    font-size: 14px;
}

.form-group {
    margin-bottom: 12px;
    padding: 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

.form-group select, .form-group textarea, .form-group input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
}

.form-group 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='%23ff6b00' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-group select option {
    background: #1a1a1a;
    color: #fff;
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
    min-height: 60px;
}

.form-group input[type="range"] {
    width: 70%;
    accent-color: var(--accent-orange);
}

.form-group select:focus,
.form-group textarea:focus,
.form-group input:focus {
    border-color: var(--accent-orange);
    box-shadow: 0 0 10px rgba(255, 107, 0, 0.15);
}

/* === Кнопки === */
.action-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent-orange), #ff9500);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(255, 107, 0, 0.3);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    -webkit-user-select: none;
    user-select: none;
}

.btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(255, 107, 0, 0.4);
}

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

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* === Результат генерации === */
.image-result { margin-top: 12px; text-align: center; }
.image-result img {
    max-width: 100%;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 107, 0, 0.1);
    border: 1px solid var(--glass-border);
}

.delivery-card {
    padding: 16px;
    border-radius: 14px;
    text-align: left;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.delivery-card strong {
    display: block;
    margin-bottom: 6px;
    font-size: 15px;
}

.delivery-card p {
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.45;
    font-size: 14px;
    white-space: pre-wrap;
}

.generated-preview {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
}

.delivery-card.success {
    background: rgba(72, 187, 120, 0.12);
    border: 1px solid rgba(72, 187, 120, 0.24);
}

.delivery-card.error {
    background: rgba(245, 101, 101, 0.12);
    border: 1px solid rgba(245, 101, 101, 0.24);
}

/* === Лоадер === */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    color: var(--accent-orange);
    font-size: 14px;
}

.loading::before {
    content: '';
    width: 22px;
    height: 22px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent-orange);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
    flex-shrink: 0;
}

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

/* === Статус сохранения === */
.save-status {
    margin-top: 10px;
    padding: 10px;
    border-radius: 12px;
    text-align: center;
    display: none;
    font-size: 14px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.save-status.success {
    display: block;
    background: rgba(72, 187, 120, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(72, 187, 120, 0.2);
}

.save-status.error {
    display: block;
    background: rgba(245, 101, 101, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(245, 101, 101, 0.2);
}

/* === Экран блокировки === */
.access-denied {
    position: fixed;
    inset: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.access-denied-content {
    text-align: center;
    padding: 40px 24px;
}

.access-icon {
    width: 64px;
    height: 64px;
    stroke: var(--accent-orange);
    margin-bottom: 20px;
    opacity: 0.7;
}

.access-denied h2 {
    justify-content: center;
    margin-bottom: 12px;
}

.access-denied p {
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
}

/* === Админ-панель === */
.nav-btn-admin.active {
    color: #48bb78;
    background: rgba(72, 187, 120, 0.1);
    box-shadow: 0 0 20px rgba(72, 187, 120, 0.15);
}

.add-user-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.add-user-row input {
    flex: 1;
    min-width: 0;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.add-btn {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: #fff;
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

.add-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(72, 187, 120, 0.4);
}

.add-btn:active {
    transform: scale(0.95);
}

.user-list {
    margin-top: 8px;
}

.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 8px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 107, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-avatar svg {
    width: 18px;
    height: 18px;
    stroke: var(--accent-orange);
}

.user-name {
    font-size: 14px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(255, 107, 0, 0.15);
    color: var(--accent-orange);
    margin-left: 6px;
    flex-shrink: 0;
}

.remove-btn {
    background: rgba(245, 101, 101, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(245, 101, 101, 0.2);
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

.remove-btn svg {
    width: 16px;
    height: 16px;
}

.remove-btn:hover {
    background: rgba(245, 101, 101, 0.2);
    transform: scale(1.05);
}

/* === Скроллбар === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 107, 0, 0.3);
    border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 107, 0, 0.5);
}

/* ===========================
   RESPONSIVE — маленькие экраны
   =========================== */
@media (max-width: 360px) {
    .nav-btn {
        padding: 8px 4px;
        font-size: 11px;
    }
    .nav-icon { width: 18px; height: 18px; }
    h2 { font-size: 18px; }
    .section-icon { width: 22px; height: 22px; }
    .form-group { padding: 10px; }
    .form-group label { font-size: 12px; }
    .form-group select, .form-group textarea { font-size: 13px; padding: 8px 10px; }
    .action-btn { padding: 12px; font-size: 14px; }
    .btn-icon { width: 18px; height: 18px; }
}

/* Средние экраны (iPhone SE, Galaxy S) */
@media (min-width: 361px) and (max-width: 414px) {
    .container { max-width: 100%; }
    .tab { padding: 8px 10px 10px; }
}

/* Стандартные экраны (iPhone 12/13/14, Pixel) */
@media (min-width: 415px) and (max-width: 500px) {
    .container { max-width: 100%; }
}

/* Планшеты и крупные экраны */
@media (min-width: 601px) {
    .container { max-width: 600px; }
    .nav { margin: 8px 0; border-radius: 18px; }
    .nav-btn { padding: 12px 10px; font-size: 14px; flex-direction: row; gap: 8px; }
    .nav-icon { width: 20px; height: 20px; }
    .tab { padding: 12px 20px 20px; }
    h2 { font-size: 26px; }
    .form-group { padding: 16px; }
    .form-group label { font-size: 15px; }
    .form-group select, .form-group textarea { font-size: 16px; padding: 12px 14px; }
    .action-btn { padding: 16px; font-size: 16px; }
}

/* Ландшафтная ориентация на телефонах */
@media (max-height: 500px) and (orientation: landscape) {
    .nav { margin: 2px 8px 4px; padding: 2px; border-radius: 12px; }
    .nav-btn { padding: 6px 8px; font-size: 12px; flex-direction: row; gap: 6px; }
    .nav-icon { width: 16px; height: 16px; }
    .tab { padding: 4px 10px 8px; }
    h2 { font-size: 18px; margin-bottom: 10px; }
    .form-group { margin-bottom: 8px; padding: 8px; }
    .form-group label { margin-bottom: 4px; font-size: 12px; }
    .form-group select, .form-group textarea { padding: 6px 8px; font-size: 13px; }
    .form-group textarea { min-height: 40px; }
    .action-btn { padding: 10px; font-size: 13px; margin-top: 8px; }
}

/* Высокие экраны (iPhone 14 Pro Max и т.п.) */
@media (min-height: 800px) and (max-width: 500px) {
    .form-group { margin-bottom: 14px; padding: 14px; }
}

/* Режим тёмной темы Telegram */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0a0a0a;
    }
}
