:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #22c55e;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.1);
    --sidebar-width: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    line-height: 1.5; 
    -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: var(--primary); }
a:hover { text-decoration: underline; }

/* === LOGIN === */
.login-wrapper { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { background: var(--surface); padding: 40px; border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 400px; }
.login-card h2 { text-align: center; margin-bottom: 24px; color: var(--text); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; color: var(--text-muted); }
.form-group input, .form-group select { 
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); 
    border-radius: var(--radius); font-size: 15px; transition: border-color 0.2s; 
    background: var(--surface);
}
.form-group input:focus, .form-group select:focus { 
    outline: none; border-color: var(--primary); 
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); 
}
.btn { 
    display: inline-flex; align-items: center; justify-content: center; 
    width: 100%; padding: 10px 16px; background: var(--primary); 
    color: white; border: none; border-radius: var(--radius); 
    font-size: 15px; font-weight: 500; cursor: pointer; transition: background 0.2s; 
}
.btn:hover { background: var(--primary-hover); }
.alert-error { background: #fef2f2; color: var(--danger); padding: 12px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; border: 1px solid #fecaca; }

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

/* Sidebar */
.sidebar { 
    width: var(--sidebar-width); background: var(--surface); 
    border-right: 1px solid var(--border); padding: 24px 16px; 
    display: flex; flex-direction: column; 
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 100;
}
.sidebar-brand { 
    font-size: 18px; font-weight: 700; color: var(--primary); 
    margin-bottom: 24px; padding: 0 8px; 
    display: flex; align-items: center; gap: 8px; 
}
.nav-link { 
    display: flex; align-items: center; gap: 10px; 
    padding: 10px 12px; color: var(--text-muted); 
    border-radius: var(--radius); margin-bottom: 4px; 
    font-weight: 500; transition: all 0.2s; 
    font-size: 14px;
}
.nav-link:hover, .nav-link.active { 
    background: #eff6ff; color: var(--primary); text-decoration: none; 
}
.sidebar-footer { 
    margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); 
}
.sidebar-footer .user-info { 
    font-size: 13px; color: var(--text-muted); margin-bottom: 8px; padding: 0 8px;
}

/* Main content */
.main-content { flex: 1; padding: 32px; overflow-y: auto; min-width: 0; }
.page-header { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-header h1 { font-size: 24px; font-weight: 600; }

/* Mobile menu button */
.menu-toggle { 
    display: none; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 8px 10px; cursor: pointer;
    font-size: 20px; line-height: 1;
}

/* Overlay для мобильного меню */
.sidebar-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 99;
}

/* === LANGUAGE DROPDOWN === */
.lang-dropdown { position: relative; }
.lang-toggle {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    cursor: pointer; font-size: 14px; color: var(--text-muted);
    transition: all 0.2s;
}
.lang-toggle:hover { border-color: var(--primary); color: var(--primary); }
.lang-menu {
    display: none; position: absolute; top: calc(100% + 4px); right: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    min-width: 140px; z-index: 200; overflow: hidden;
}
.lang-menu.show { display: block; }
.lang-menu a {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; color: var(--text); font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.lang-menu a:last-child { border-bottom: none; }
.lang-menu a:hover { background: #f1f5f9; text-decoration: none; }
.lang-menu a.active { color: var(--primary); font-weight: 600; background: #eff6ff; }
.lang-menu a .check { margin-left: auto; opacity: 0; }
.lang-menu a.active .check { opacity: 1; }

/* === DASHBOARD === */
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); 
    gap: 20px; margin-bottom: 32px; 
}
.stat-card { 
    background: var(--surface); padding: 24px; 
    border-radius: var(--radius); box-shadow: var(--shadow); 
    border: 1px solid var(--border); display: flex; flex-direction: column; 
}
.stat-card .icon { font-size: 32px; margin-bottom: 12px; }
.stat-card h3 { font-size: 32px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.stat-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }
.stat-card .link { margin-top: auto; font-size: 14px; font-weight: 500; }

.info-card {
    background: var(--surface); padding: 24px; 
    border-radius: var(--radius); border: 1px solid var(--border);
}
.info-card h3 { margin-bottom: 8px; font-size: 16px; }
.info-card p { color: var(--text-muted); font-size: 14px; }

/* === TABLES (адаптивные) === */
.table-wrapper { 
    background: var(--surface); border-radius: var(--radius); 
    border: 1px solid var(--border); overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
}
.data-table { width: 100%; border-collapse: collapse; min-width: 500px; }
.data-table th { 
    padding: 12px 16px; text-align: left; font-weight: 600; 
    color: var(--text-muted); background: #f8fafc; 
    border-bottom: 1px solid var(--border); font-size: 13px;
    white-space: nowrap;
}
.data-table td { 
    padding: 12px 16px; border-bottom: 1px solid var(--border); 
    font-size: 14px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: #f8fafc; }

/* Бейджи статусов */
.badge { 
    display: inline-block; padding: 4px 10px; border-radius: 12px; 
    font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-error { background: #fee2e2; color: #991b1b; }

/* === МОБИЛЬНАЯ АДАПТАЦИЯ === */
@media (max-width: 768px) {
    .menu-toggle { display: block; }
    
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.open + .sidebar-overlay { display: block; }
    
    .main-content { padding: 16px; width: 100%; }
    
    .page-header { flex-direction: row; align-items: center; }
    .page-header h1 { font-size: 20px; }
    
    .stats-grid { grid-template-columns: 1fr; gap: 12px; }
    .stat-card { padding: 18px; }
    .stat-card h3 { font-size: 26px; }
    
    /* Скрываем длинные тексты на мобильных */
    .hide-mobile { display: none; }
    
    /* Кнопки на мобильных растягиваются */
    .btn-auto-mobile { width: 100%; }
    
    /* Компактные отступы в таблицах */
    .data-table th, .data-table td { padding: 10px 12px; font-size: 13px; }
    
    .login-card { padding: 24px; }
}

@media (max-width: 480px) {
    .main-content { padding: 12px; }
    .page-header h1 { font-size: 18px; }
    .lang-toggle { padding: 5px 10px; font-size: 13px; }
}


/* === MAILBOX CARDS (для мобильных) === */
.mailbox-cards {
    display: none; /* Скрыто на десктопе */
    flex-direction: column;
    gap: 12px;
}

.mailbox-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.mailbox-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.mailbox-email {
    font-weight: 600;
    font-size: 15px;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    flex: 1;
    min-width: 0; /* Критично! Без этого flex-элемент не сжимается */
}

.mailbox-card-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.mailbox-card-actions {
    display: flex;
    gap: 8px;
    flex-direction: column;
}

.mailbox-card-actions .btn {
    width: auto;
    padding: 8px 14px;
    font-size: 13px;
}

/* Показываем карточки только на мобильных */
@media (max-width: 768px) {
    .table-wrapper { display: none; }
    .mailbox-cards { display: flex; }
    
    /* Фильтр на мобильном растягивается */
    .mobile-filter { width: 100%; }
}

/* На планшетах и десктопе скрываем карточки */
@media (min-width: 769px) {
    .mailbox-cards { display: none !important; }
    .table-wrapper { display: block; }
}


/* === DNS RECORDS === */
.dns-records {
    display: flex;
    flex-direction: column; /* Строго сверху вниз */
    gap: 16px;
    max-width: 700px;       /* Ограничиваем ширину для удобства чтения на десктопе */
    margin: 0 auto;         /* Центрируем колонку */
}

.dns-card {
    background: #1e293b;
    color: #f1f5f9;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.dns-card-title {
    color: #60a5fa;
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #334155;
}

.dns-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.dns-label {
    color: #c4b5fd;
    font-weight: 600;
    font-size: 13px;
    min-width: 80px;
    flex-shrink: 0;
}

.dns-value {
    color: #fde68a;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
    background: #0f172a;
    padding: 4px 8px;
    border-radius: 4px;
    flex: 1;
    min-width: 0;
    word-break: break-all;
}

.copy-btn {
    background: #334155;
    border: 1px solid #475569;
    color: #f1f5f9;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    transition: all 0.2s;
    flex-shrink: 0;
}

.copy-btn:hover {
    background: #475569;
    border-color: #64748b;
}



/* Выравнивание информационных карточек на странице доменов */
.domain-info-card {
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

/* Стили для кастомного модального окна */
.custom-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
.custom-modal-overlay.show {
    display: flex;
}
.custom-modal {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    max-width: 400px;
    width: 90%;
    text-align: center;
}
.custom-modal h3 { margin-top: 0; color: var(--text); }
.custom-modal p { color: var(--text-muted); margin-bottom: 24px; line-height: 1.5; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }
.modal-actions .btn { width: auto; flex: 1; }
.btn-secondary { background: var(--text-muted); }
.btn-secondary:hover { background: #475569; }



@media (max-width: 480px) {
    .dns-row {
        flex-direction: column;
        align-items: stretch;
    }
    .dns-label { min-width: auto; }
    .copy-btn { align-self: flex-end; }
}
