:root {
    --bg-dark: #0b0f19;
    --card-bg: rgba(17, 24, 39, 0.75);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover: rgba(31, 41, 55, 0.9);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;

    --emerald-primary: #10b981;
    --emerald-glow: rgba(16, 185, 129, 0.25);
    
    --cyan-primary: #06b6d4;
    --cyan-glow: rgba(6, 182, 212, 0.25);

    --amber-primary: #f59e0b;
    --amber-glow: rgba(245, 158, 11, 0.25);

    --purple-primary: #8b5cf6;
    --purple-glow: rgba(139, 92, 246, 0.25);

    --crimson-primary: #ef4444;
    
    --accent-blue: #2563eb;
    --accent-hover: #1d4ed8;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 10%, rgba(6, 182, 212, 0.12) 0px, transparent 50%),
        radial-gradient(at 90% 90%, rgba(16, 185, 129, 0.10) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    line-height: 1.4;
}

/* App Container */
.app-container {
    max-width: 1380px;
    margin: 0 auto;
    padding: 18px 24px;
}

/* Header Navbar */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 22px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    margin-bottom: 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--cyan-primary), var(--emerald-primary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    box-shadow: 0 0 16px var(--cyan-glow);
}

.logo-text h1 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-text h1 span {
    background: linear-gradient(135deg, var(--cyan-primary), var(--emerald-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text p {
    font-size: 12px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.dataset-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Controls & Selects */
.styled-select, input[type="text"], input[type="number"] {
    background: rgba(31, 41, 55, 0.7);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease;
}

.styled-select:focus, input[type="text"]:focus, input[type="number"]:focus {
    border-color: var(--cyan-primary);
    box-shadow: 0 0 10px var(--cyan-glow);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--cyan-primary), var(--accent-blue));
    color: #fff;
    box-shadow: 0 3px 10px var(--cyan-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--cyan-glow);
}

.btn-excel {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    box-shadow: 0 3px 10px var(--emerald-glow);
}

.btn-excel:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--emerald-glow);
}

.btn-csv {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    color: var(--text-main);
}

.btn-csv:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
}

.glow-cyan { border-left: 3px solid var(--cyan-primary); }
.glow-emerald { border-left: 3px solid var(--emerald-primary); }
.glow-amber { border-left: 3px solid var(--amber-primary); }
.glow-purple { border-left: 3px solid var(--purple-primary); }

.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.glow-cyan .kpi-icon { color: var(--cyan-primary); }
.glow-emerald .kpi-icon { color: var(--emerald-primary); }
.glow-amber .kpi-icon { color: var(--amber-primary); }
.glow-purple .kpi-icon { color: var(--purple-primary); }

.kpi-label {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-info h2 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
}

/* Toolbar & Filters */
.toolbar-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-bar-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

#searchInput {
    width: 100%;
    padding: 10px 38px;
    font-size: 13.5px;
    background: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: #fff;
}

#btnClearSearch {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
}

.filters-row {
    display: flex;
    gap: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.export-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.results-counter {
    font-size: 13px;
    color: var(--text-muted);
}

.results-counter strong {
    color: var(--cyan-primary);
}

.export-buttons {
    display: flex;
    gap: 10px;
}

/* Data Table - Precise & Compact Horizontal Spacing */
.table-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.table-wrapper {
    max-height: 560px;
    overflow-y: auto;
    overflow-x: auto;
}

.styled-table {
    width: 100%;
    table-layout: fixed; /* Enforces strict, precise column widths */
    border-collapse: collapse;
    font-size: 12.5px;
    text-align: left;
}

/* Column Width Allocations */
.styled-table th:nth-child(1), .styled-table td:nth-child(1) { width: 42px; text-align: center; } /* # */
.styled-table th:nth-child(2), .styled-table td:nth-child(2) { width: 115px; } /* RUC */
.styled-table th:nth-child(3), .styled-table td:nth-child(3) { width: 230px; } /* Declarante */
.styled-table th:nth-child(4), .styled-table td:nth-child(4) { width: 110px; } /* Codigo Unico */
.styled-table th:nth-child(5), .styled-table td:nth-child(5) { width: 180px; } /* Derecho Minero */
.styled-table th:nth-child(6), .styled-table td:nth-child(6) { width: 110px; } /* Dep */
.styled-table th:nth-child(7), .styled-table td:nth-child(7) { width: 120px; } /* Prov */
.styled-table th:nth-child(8), .styled-table td:nth-child(8) { width: 120px; } /* Dist */
.styled-table th:nth-child(9), .styled-table td:nth-child(9) { width: 110px; text-align: center; } /* Estado */

.styled-table th {
    position: sticky;
    top: 0;
    background: #111827;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.4px;
    padding: 10px 12px;
    border-bottom: 2px solid var(--card-border);
    z-index: 2;
    white-space: nowrap;
}

.styled-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Clean truncation with ellipsis for long text */
}

.styled-table tbody tr {
    transition: background-color 0.15s ease;
}

.styled-table tbody tr:hover {
    background-color: var(--card-hover);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-transform: uppercase;
}

.badge-vigente {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-suspendido {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.empty-state {
    text-align: center;
    padding: 36px !important;
    color: var(--text-muted);
    font-size: 14px;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: #111827;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 480px;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 18px;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
}

.modal-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.form-group label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.progress-box {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    padding: 10px;
    border-radius: var(--radius-sm);
    color: var(--cyan-primary);
    font-size: 12.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}
