@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');

:root {
    --bg-deep: #050505;
    --bg-card: #0f1218;
    --border: #1f2937;
    --accent: #3b82f6;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --danger: #ef4444;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-deep);
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    /* Смещение -13px идеально выравнивает перекрестие по центру иконки щита */
    background-position: center calc(50% - 13px);
    color: var(--text-main);
    margin: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden;
}

/* === LOGIN === */
#login-view {
    position: fixed; inset: 0; z-index: 100;
    display: flex; justify-content: center; align-items: center;
    background: #000;
}
.login-card {
    background: #111; border: 1px solid #333;
    padding: 3rem; border-radius: 20px; text-align: center;
    box-shadow: 0 0 100px rgba(59, 130, 246, 0.15);
    max-width: 380px; width: 100%; position: relative; overflow: hidden;
}
.login-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, transparent, #3b82f6, transparent);
}
.brand-logo { font-size: 3.5rem; margin-bottom: 1rem; }
.login-title { font-weight: 800; font-size: 1.5rem; margin: 0 0 5px 0; letter-spacing: 1px; color: white; }
.login-sub { color: #555; font-size: 0.9rem; margin-bottom: 2rem; text-transform: uppercase; letter-spacing: 2px; }
#access-denied-msg {
    background: rgba(220, 38, 38, 0.1); border: 1px solid #7f1d1d;
    color: #fca5a5; padding: 12px; border-radius: 6px; margin-bottom: 20px; font-size: 0.85rem;
    display: none;
}
.btn-primary {
    background: #fff; color: #000; padding: 14px; border-radius: 10px;
    text-decoration: none; font-weight: 700; width: 100%; box-sizing: border-box;
    display: flex; justify-content: center; align-items: center; gap: 10px;
    transition: 0.3s; cursor: pointer;
}
.btn-primary:hover { background: #e5e5e5; }

/* === APP === */
#app-view { display: flex; flex-direction: column; height: 100%; opacity: 0; transition: opacity 0.5s; }

header {
    background: rgba(5, 5, 5, 0.9); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border); padding: 0.8rem 1.5rem;
    display: flex; justify-content: space-between; align-items: center; z-index: 50;
}
.brand { font-weight: 900; font-size: 1.2rem; display: flex; align-items: center; gap: 12px; letter-spacing: 2px; color: white; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 10px #22c55e; }

/* === SEARCH === */
.search-wrapper {
    padding: 1.5rem; flex-shrink: 0; position: relative; z-index: 40;
    display: flex; justify-content: center;
}
.search-box { width: 100%; max-width: 700px; position: relative; }
#searchInput {
    width: 100%; background: rgba(15, 23, 42, 0.5);
    border: 1px solid #334155; color: white; font-size: 1.1rem; padding: 18px 50px;
    border-radius: 16px; outline: none; box-sizing: border-box;
    backdrop-filter: blur(12px); transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}
#searchInput::placeholder { color: #64748b; font-weight: 400; }
#searchInput:focus {
    border-color: var(--accent); background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15), 0 20px 40px -10px rgba(0,0,0,0.5);
}
.search-icon {
    position: absolute; left: 20px; top: 50%; transform: translateY(-50%);
    color: #64748b; font-size: 1.1rem; pointer-events: none; transition: 0.3s;
}
#searchInput:focus + .search-icon { color: var(--accent); }

/* === CONTENT & GRID === */
/* Добавили padding-top 10px чтобы карточкам было куда всплывать при наведении */
.content-area { 
    flex: 1; 
    overflow-y: auto; 
    padding: 0 1.5rem 2rem; 
    position: relative;
    /* Центрируем содержимое (и сетку, и щит) по одной оси */
    display: flex;
    flex-direction: column;
    align-items: center; 
}
.cards-grid {
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.2rem; 
    
    /* Добавляем ширину, чтобы сетка занимала всё место внутри центрированного родителя */
    width: 100%;
    max-width: 1400px; 
    margin: 0 auto;
}

/* === CARD === */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; overflow: hidden; display: flex; flex-direction: column;
    /* Улучшенная анимация */
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
}

/* ХОВЕР: Без scale, только подъем и тень */
.card:hover {
    transform: translateY(-5px);
    border-color: #374151;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
    z-index: 10;
}

.card.is-debtor { border: 1px solid var(--danger); }
.card.is-debtor:hover { border-color: #f87171; box-shadow: 0 10px 30px -5px rgba(239, 68, 68, 0.2); }

.debtor-stripe {
    background: var(--danger); color: white; text-align: center;
    font-weight: 900; font-size: 0.7rem; padding: 5px; letter-spacing: 2px;
}

.card-header {
    padding: 16px; background: #13161c; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: flex-start;
}

/* === UNIFIED BLOCK === */
.unified-premise {
    display: flex; border-radius: 10px; overflow: hidden;
    border: 1px solid #2d3748;
}
.sec-part {
    background: #1f2937; color: #9ca3af; padding: 0 12px;
    font-size: 0.7rem; font-weight: 700; display: flex; align-items: center;
    border-right: 1px solid #2d3748; letter-spacing: 1px;
}
.info-part {
    display: flex; flex-direction: column; justify-content: center;
    padding: 6px 14px; background: #27303f; min-width: 60px;
}
.premise-type-label {
    font-size: 0.55rem; text-transform: uppercase; font-weight: 800;
    letter-spacing: 0.5px; margin-bottom: 2px; opacity: 0.7;
}
.num-value {
    font-size: 1.3rem; font-weight: 800; color: white;
    font-family: 'JetBrains Mono', monospace; line-height: 1;
}

/* COLORS */
.type-apt .info-part { background: rgba(59, 130, 246, 0.08); }
.type-apt .num-value { color: #60a5fa; }
.type-apt .premise-type-label { color: #93c5fd; }

.type-garage .info-part { background: rgba(249, 115, 22, 0.08); }
.type-garage .num-value { color: #fb923c; }
.type-garage .premise-type-label { color: #fdba74; }

.type-store .info-part { background: rgba(107, 114, 128, 0.08); }
.type-store .num-value { color: #d1d5db; }
.type-store .premise-type-label { color: #e5e7eb; }

.type-office .info-part { background: rgba(168, 85, 247, 0.08); }
.type-office .num-value { color: #c084fc; }
.type-office .premise-type-label { color: #e9d5ff; }

/* === CARS === */
.cars-stack { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.car-item { display: flex; flex-direction: column; align-items: flex-end; }
.ua-plate {
    display: flex; background: #fff; border-radius: 4px; overflow: hidden; height: 26px;
    border: 1px solid #9ca3af; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.ua-flag { width: 10px; background: linear-gradient(#0057b8 50%, #ffd700 50%); border-right: 1px solid #9ca3af; }
.plate-num {
    padding: 0 8px; font-family: 'JetBrains Mono', monospace; font-weight: 800; font-size: 15px;
    color: #000; display: flex; align-items: center; letter-spacing: 1px;
}
.blacklist-badge {
    background: #000; color: #ef4444; border: 1px solid #ef4444;
    font-size: 0.6rem; font-weight: 800; text-transform: uppercase;
    padding: 2px 6px; border-radius: 4px; margin-bottom: 4px; letter-spacing: 0.5px;
}

/* === PEOPLE === */
.people-section { display: flex; flex-direction: column; }
.person-row { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.person-row:last-child { border-bottom: none; }
.row-owner { border-left: 2px solid #3b82f6; background: rgba(59, 130, 246, 0.03); }
.row-tenant { border-left: 2px solid #eab308; background: rgba(234, 179, 8, 0.03); }
.role-badge { font-size: 0.65rem; text-transform: uppercase; font-weight: 800; margin-bottom: 6px; color: #6b7280; letter-spacing: 0.5px; }
.person-name { font-weight: 600; font-size: 1rem; margin-bottom: 10px; color: #e5e7eb; }

/* PHONE CHIPS */
.phones-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.phone-chip {
    text-decoration: none; padding: 6px 12px; border-radius: 8px; font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace; display: flex; align-items: center; gap: 8px;
    transition: 0.2s; border: 1px solid transparent;
}
.row-owner .phone-chip { background: #14281d; color: #4ade80; border-color: #15803d; }
.row-owner .phone-chip:hover { background: #166534; color: white; transform: translateY(-1px); }
.row-tenant .phone-chip { background: #2d2305; color: #facc15; border-color: #a16207; }
.row-tenant .phone-chip:hover { background: #854d0e; color: white; transform: translateY(-1px); }

/* === EMPTY STATE === */
.empty-state {
    /* Убираем абсолютное позиционирование */
    margin: auto; /* Автоматически встанет по центру свободного места */
    
    /* Ограничиваем ширину так же, как у сетки */
    width: 100%;
    max-width: 1400px;
    
    text-align: center; 
    color: #334155; 
    user-select: none;
}
.system-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.5; animation: pulse 2s infinite; }
@keyframes pulse { 0% { opacity: 0.3; } 50% { opacity: 0.6; text-shadow: 0 0 20px rgba(59, 130, 246, 0.5); } 100% { opacity: 0.3; } }
.system-text { font-weight: 800; font-size: 1.5rem; letter-spacing: 3px; color: #1e293b; }
/* В конец файла */

/* === UI CONTROLS === */
.icon-btn {
    background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1);
    color: #9ca3af; width: 36px; height: 36px; border-radius: 8px;
    font-size: 1rem; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: white; transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.5); }
.icon-btn.logout:hover { background: rgba(239, 68, 68, 0.2); color: #ef4444; border-color: rgba(239, 68, 68, 0.5); }
.icon-btn.admin-trigger { color: #3b82f6; border-color: rgba(59, 130, 246, 0.3); }
.icon-btn.admin-trigger:hover { background: rgba(59, 130, 246, 0.2); box-shadow: 0 0 15px rgba(59, 130, 246, 0.4); }

/* === MODERN MODAL === */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px); z-index: 200;
    display: flex; justify-content: center; align-items: center;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 650px; max-width: 95%; max-height: 85vh;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255,255,255,0.05);
    display: flex; flex-direction: column; overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(30px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

.modal-header {
    padding: 24px; border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex; justify-content: space-between; align-items: center;
    background: linear-gradient(to right, rgba(59, 130, 246, 0.1), transparent);
}
.modal-header h2 { margin: 0; font-size: 1.25rem; font-weight: 800; letter-spacing: 1px; color: white; display: flex; align-items: center; gap: 10px; }

.modal-body { padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 24px; }

/* ADD USER FORM */
.add-user-section {
    background: rgba(255, 255, 255, 0.02); border-radius: 16px; padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.add-form-row { display: grid; grid-template-columns: 1.5fr 1fr auto; gap: 12px; margin-top: 12px; }

.modern-input, .modern-select {
    background: rgba(0, 0, 0, 0.3); border: 1px solid #374151;
    color: white; padding: 12px 16px; border-radius: 12px;
    font-size: 0.95rem; outline: none; transition: 0.3s; width: 100%; box-sizing: border-box;
}
.modern-input:focus, .modern-select:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); background: rgba(0,0,0,0.5); }

.btn-glow {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white; border: none; padding: 0 24px; border-radius: 12px;
    font-weight: 700; cursor: pointer; transition: 0.3s;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
    display: flex; align-items: center; gap: 8px;
}
.btn-glow:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(37, 99, 235, 0.5); }
.btn-glow:active { transform: translateY(0); }

/* USERS TABLE */
.users-list-wrapper { border-radius: 16px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.05); }
.users-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.users-table th {
    text-align: left; color: #9ca3af; padding: 16px;
    background: rgba(255, 255, 255, 0.03); border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 700;
}
.users-table td { padding: 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.03); color: #e5e7eb; transition: 0.2s; }
.users-table tr:hover td { background: rgba(255, 255, 255, 0.02); }
.users-table tr:last-child td { border-bottom: none; }

.badge-admin { background: rgba(234, 179, 8, 0.15); color: #facc15; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.5px; border: 1px solid rgba(234, 179, 8, 0.2); }
.badge-superadmin { background: rgba(239, 68, 68, 0.15); color: #f87171; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.5px; border: 1px solid rgba(239, 68, 68, 0.2); box-shadow: 0 0 10px rgba(239, 68, 68, 0.1); }
.badge-user { background: rgba(255, 255, 255, 0.05); color: #9ca3af; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }

.btn-icon-only { background: transparent; border: none; color: #6b7280; cursor: pointer; padding: 6px; border-radius: 6px; transition: 0.2s; }
.btn-icon-only:hover { background: rgba(255, 255, 255, 0.1); color: white; }

/* PERMISSIONS EDITOR */
.permissions-editor {
    background: #0f1218; border: 1px solid #1f2937;
    border-radius: 16px; padding: 20px;
    animation: fadeIn 0.3s ease; position: relative;
    /* overflow: hidden удален, чтобы не обрезались кнопки и тени */
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
/* Полоска теперь сделана через border-left, чтобы не ломать верстку */
.permissions-editor {
    border-left: 4px solid #3b82f6;
}
/* Старый псевдоэлемент удаляем, он больше не нужен */
.permissions-editor::before { display: none; }
.perm-header { 
    font-size: 0.9rem; margin-bottom: 20px; color: #9ca3af; 
    display: flex; flex-direction: column; gap: 5px; /* Ставим в столбик для надежности */
    align-items: flex-start;
}
.perm-header span { color: white; font-weight: 700; font-family: 'JetBrains Mono'; }

/* TOGGLE SWITCHES */
.toggles-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.toggle-item {
    background: rgba(255, 255, 255, 0.03); padding: 12px; border-radius: 10px;
    display: flex; justify-content: space-between; align-items: center;
    border: 1px solid transparent; transition: 0.2s;
}
.toggle-item:hover { border-color: rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.05); }

/* The Switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #374151; transition: .4s; border-radius: 34px;
}
.slider:before {
    position: absolute; content: ""; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: #3b82f6; box-shadow: 0 0 10px rgba(59, 130, 246, 0.4); }
input:checked + .slider:before { transform: translateX(20px); }

.perm-actions { display: flex; gap: 12px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.05); }
.btn-save { flex: 1; background: #10b981; color: white; font-weight: 700; padding: 12px; border-radius: 10px; border: none; cursor: pointer; transition: 0.2s; }
.btn-save:hover { background: #059669; }
.btn-danger { background: rgba(239, 68, 68, 0.1); color: #ef4444; font-weight: 700; padding: 12px 20px; border-radius: 10px; border: 1px solid rgba(239, 68, 68, 0.2); cursor: pointer; transition: 0.2s; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); border-color: #ef4444; }