:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #334155;
    --secondary-hover: #475569;
    --accent: #10b981;
    --danger: #ef4444;
    --font-family: 'Inter', sans-serif;
    --radius-lg: 16px;
    --radius-md: 8px;
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.1), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.05), transparent 25%);
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.view-hidden {
    display: none !important;
}

.view-active {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Glassmorphism Classes */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
}

/* Auth View */
#auth-view {
    justify-content: center;
    align-items: center;
}

.auth-box {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    animation: fadeIn 0.4s ease-out;
}

.logo-area {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-img {
    max-width: 200px;
    height: auto;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.2));
}

.logo-area h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #3b82f6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.half {
    flex: 1;
}

label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

input:not([type="checkbox"]),
select {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--bg-card-border);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

input:not([type="checkbox"]):focus,
select:focus {
    border-color: var(--primary);
}

select {
    appearance: auto;
    color: #f8fafc !important;
    background-color: #0f172a !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

option {
    background-color: #0f172a !important;
    color: #f8fafc !important;
}

/* Custom Checkbox Group Styling */
.checkbox-group {
    height: 180px;
    overflow-y: auto;
    text-align: left;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
}

.checkbox-group::-webkit-scrollbar {
    width: 6px;
}

.checkbox-group::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.checkbox-group::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.checkbox-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.checkbox-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--primary);
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.3);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.checkbox-item input[type="checkbox"]:checked {
    background-color: var(--primary);
}

.checkbox-item input[type="checkbox"]:checked::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.checkbox-item.group-category {
    font-weight: 600;
    margin-top: 0.5rem;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.6rem;
}

.checkbox-item.group-license {
    margin-left: 1.5rem;
    font-size: 0.9rem;
    color: #94a3b8;
}

.checkbox-item.group-license input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border: 2px solid #64748b;
}

.checkbox-item.group-license input[type="checkbox"]:checked {
    border-color: var(--primary);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s ease;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: rgba(59, 130, 246, 0.1);
}

.btn-remove-minimal {
    padding: 0 1rem;
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove-minimal:hover {
    background: rgba(239, 68, 68, 0.1);
}

.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    width: auto;
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    margin-left: 5px;
}

.auth-switch a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Sidebar Quota */
.sidebar-quota {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.05);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.quota-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-quota .badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 700;
    width: 100%;
    text-align: center;
}

/* Dashboard Layout */
#dashboard-view {
    padding: 2rem;
    gap: 2rem;
    display: flex;
    flex-direction: row;
}

/* Sidebar */
.sidebar {
    width: 260px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 4rem);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.logo-img-sidebar {
    height: 35px;
    width: auto;
    object-fit: contain;
}

.sidebar-header h2 {
    font-size: 1.25rem;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-links li {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-links li:hover,
.nav-links li.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-links li.active {
    border-left: 3px solid var(--primary);
}

.user-widget {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--bg-card-border);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info span {
    font-weight: 600;
    font-size: 0.9rem;
}

#logout-btn {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: none;
}

#logout-btn:hover {
    color: var(--danger);
}

/* Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 4rem);
    overflow-y: auto;
}

.panel {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.3s;
}

.panel-active {
    display: flex;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-weight: 600;
    font-size: 1.5rem;
}

.badge {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.file-card {
    padding: 1rem 1.5rem !important;
}

.file-card h3 {
    margin-bottom: 0.5rem !important;
}

.file-status {
    margin-bottom: 0.5rem !important;
}

.status-icon {
    font-size: 1.5rem !important;
}

.quick-actions {
    padding: 1.5rem;
    flex: 1;
}

.checkbox-group {
    height: 250px !important; /* Aumentado conforme solicitado */
}

.file-card h3,
.quick-actions h3 {
    font-size: 1.1rem;
    margin-bottom: 1.2rem;
    color: var(--text-muted);
}

.file-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.status-icon {
    font-size: 2rem;
}

.file-details h4 {
    font-size: 1.1rem;
}

.file-details p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.compare-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
    align-items: stretch;
}

.compare-group select,
.compare-group input:not([type="checkbox"]) {
    flex: 1 1 150px;
    min-width: 150px !important;
    font-size: 0.9rem;
    margin-bottom: 0 !important;
}

.compare-group .btn {
    flex: 1 1 120px;
    min-width: 120px !important;
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.history-table th {
    padding: 1rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--bg-card-border);
    font-size: 0.9rem;
    font-weight: 500;
}

.history-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    font-size: 0.9rem;
}

.history-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
}

/* Simple Result Table formatting injected dynamically */
.res-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.res-table th {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.8rem;
    text-align: left;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.res-table td {
    padding: 0.8rem;
    border-bottom: 1px solid var(--bg-card-border);
}

.deficit {
    color: var(--danger);
    font-weight: 600;
}

.surplus {
    color: var(--accent);
    font-weight: 600;
}

#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background: var(--bg-card);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-glass);
    animation: slideInRight 0.3s;
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.success {
    border-left-color: var(--accent);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}