:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); height: 100vh; display: flex; flex-direction: column; }

/* --- Login --- */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { background: var(--card-bg); padding: 2rem; border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 400px; }
.login-card h1 { text-align: center; margin-top: 0; color: var(--primary); }

/* --- Layout --- */
.top-bar { background: var(--card-bg); padding: 0 1.5rem; height: 60px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 1px 2px rgba(0,0,0,0.05); z-index: 10; }
.brand { font-weight: 700; font-size: 1.25rem; color: var(--primary); }
.user-menu { display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; }
.btn-text { color: var(--danger); text-decoration: none; font-weight: 500; }

.content { flex: 1; padding: 1.5rem; overflow-y: auto; max-width: 1200px; margin: 0 auto; width: 100%; }

/* --- Components --- */
.btn { padding: 0.5rem 1rem; border: none; border-radius: 8px; font-weight: 500; cursor: pointer; transition: 0.2s; font-size: 0.9rem; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.primary { background: var(--primary); color: white; }
.primary:hover:not(:disabled) { background: var(--primary-hover); }
.success { background: var(--success); color: white; }
.danger { background: var(--danger); color: white; }
.secondary { background: white; border: 1px solid var(--border); color: var(--text); }
.outline { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.outline:hover:not(:disabled) { background: var(--danger); color: white; }
.full-width { width: 100%; justify-content: center; padding: 0.75rem; }
.flex-1 { flex: 1; }

.input-group { margin-bottom: 1rem; }
.input-group label { display: block; margin-bottom: 0.5rem; font-size: 0.9rem; font-weight: 500; }
.input-group input { width: 100%; padding: 0.75rem; border: 1px solid var(--border); border-radius: 8px; font-size: 1rem; }
.alert { padding: 0.75rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert.error { background: #fee2e2; color: #991b1b; }

/* --- Toolbar --- */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.toolbar h2 { margin: 0; font-size: 1.5rem; }
.actions { display: flex; gap: 0.75rem; }

/* --- Table (Desktop) --- */
.table-wrapper { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th { background: #f9fafb; text-align: left; padding: 1rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-light); font-weight: 600; border-bottom: 1px solid var(--border); }
td { padding: 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 0.95rem; }
tr:last-child td { border-bottom: none; }
tr:hover { background: #f9fafb; }

.badge { padding: 0.25rem 0.6rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-admin { background: #fef3c7; color: #d97706; }
.badge-user { background: #dbeafe; color: #1d4ed8; }

/* UUID Column Styles */
.uuid-cell { 
    font-family: monospace; 
    font-size: 0.9rem; 
    color: var(--primary); 
    cursor: pointer; 
    user-select: all;
    position: relative;
    transition: color 0.2s;
}
.uuid-cell:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}
.uuid-cell::after {
    content: 'Скопировано!';
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    white-space: nowrap;
    font-family: sans-serif;
}
.uuid-cell.copied::after {
    opacity: 1;
}
.uuid-cell.copied {
    color: var(--success);
}

.row-actions { display: flex; gap: 0.5rem; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

/* --- Mobile Cards --- */
.mobile-only { display: none; }
.card-list { display: flex; flex-direction: column; gap: 1rem; }
.user-card { background: var(--card-bg); padding: 1rem; border-radius: var(--radius); box-shadow: var(--shadow); position: relative; border: 1px solid var(--border); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; }
.card-email { font-weight: 600; font-size: 1.1rem; display: block; margin-bottom: 0.25rem; }
.card-id { font-size: 0.8rem; color: var(--text-light); }
.card-row { display: flex; justify-content: space-between; margin-bottom: 0.5rem; font-size: 0.9rem; }
.card-label { color: var(--text-light); font-size: 0.8rem; }
.card-actions { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border); display: flex; gap: 0.75rem; }

/* --- Bottom Bar (Mobile) --- */
.bottom-bar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card-bg); padding: 0.75rem 1rem; box-shadow: 0 -2px 10px rgba(0,0,0,0.05); display: flex; gap: 1rem; z-index: 50; align-items: center; }
.mobile-spacer { height: 80px; }

/* --- Modal --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); z-index: 100; display: none; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; }
.modal-overlay.active { display: flex; opacity: 1; }

/* Desktop Modal: Scrollable if content is too big */
.modal-card { 
    background: var(--card-bg); 
    width: 90%; 
    max-width: 550px; 
    /* Изменено: ограничиваем высоту и добавляем скролл, чтобы контент не уходил за экран */
    max-height: 90vh; 
    overflow-y: auto; 
    border-radius: var(--radius); 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); 
    animation: slideUp 0.3s ease; 
    display: flex; 
    flex-direction: column; 
}

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.modal-header h3 { margin: 0; font-size: 1.25rem; }
.close { font-size: 1.5rem; cursor: pointer; color: var(--text-light); line-height: 1; }

#userForm { padding: 1.5rem; flex: 1; } 

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: 0.4rem; font-size: 0.9rem; font-weight: 500; color: var(--text-light); }
.field input, .field select { width: 100%; padding: 0.6rem; border: 1px solid var(--border); border-radius: 6px; font-size: 1rem; }
.uuid-wrap { display: flex; gap: 0.5rem; }
.btn-icon { background: #f3f4f6; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; padding: 0 0.8rem; }

.date-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.check-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; cursor: pointer; white-space: nowrap; }

.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: #f9fafb; display: flex; justify-content: flex-end; gap: 0.75rem; flex-shrink: 0; }
.msg { margin-top: 1rem; margin-bottom: 1rem; font-size: 0.9rem; text-align: center; } /* Добавлен margin-bottom */
.msg.error { color: var(--danger); }
.msg.success { color: var(--success); }

/* --- Responsive Queries --- */
@media (max-width: 768px) {
    .desktop-only { display: none; }
    .mobile-only { display: flex; }
    .content { padding: 1rem; padding-bottom: 0; }
    .form-grid { grid-template-columns: 1fr; gap: 0; }
    
    .table-wrapper { display: none; }
    
    /* Mobile Modal: Full screen */
    .modal-card { width: 100%; height: 100%; max-height: 100%; border-radius: 0; overflow: hidden; }
    #userForm { flex: 1; overflow-y: auto; padding-bottom: 2rem; }
    
    .uuid-cell::after { display: none; }
}