/* ==========================================================================
   VALERS ERP - Enterprise Design System (Sleek Slate Dark Edition)
   100% Vector Icons, High Precision & Enterprise Aesthetics
   ========================================================================== */

:root {
    --bg-main: #090d16;
    --bg-card: #0f172a;
    --bg-card-hover: #162035;
    --bg-header: rgba(15, 23, 42, 0.85);
    --bg-input: #1e293b;
    --bg-input-focus: #182234;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --primary: #0ea5e9;
    --primary-glow: rgba(14, 165, 233, 0.25);
    --primary-hover: #38bdf8;
    --accent: #f59e0b;

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --success-border: rgba(16, 185, 129, 0.3);
    
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.12);
    --error-border: rgba(239, 68, 68, 0.3);

    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --warning-border: rgba(245, 158, 11, 0.3);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-normal: 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    --border-radius-sm: 6px;
    --border-radius: 10px;
    --border-radius-lg: 16px;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-light: rgba(255, 255, 255, 0.14);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ==========================================================================
   Vector Icons (.app-icon)
   ========================================================================== */
.app-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    flex-shrink: 0;
    transition: transform var(--transition-fast), stroke var(--transition-fast);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Header / Navbar */
.navbar {
    background-color: var(--bg-header);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    height: 68px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.navbar-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

.brand-icon-box {
    width: 34px;
    height: 34px;
    border-radius: var(--border-radius-sm);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.25) 0%, rgba(56, 189, 248, 0.1) 100%);
    border: 1px solid rgba(56, 189, 248, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #38bdf8;
    box-shadow: 0 0 12px rgba(14, 165, 233, 0.2);
}

.navbar-tag {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.navbar-menu {
    display: flex;
    gap: 0.4rem;
    height: 100%;
    align-items: center;
}

.nav-link {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.45rem 0.95rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
    height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.nav-link:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
    color: #38bdf8;
    background-color: rgba(14, 165, 233, 0.12);
    border-color: rgba(14, 165, 233, 0.3);
    font-weight: 600;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.75rem;
    border-radius: 50px;
    font-size: 0.82rem;
    color: var(--text-main);
}

.user-role-badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(14, 165, 233, 0.18);
    color: #38bdf8;
    padding: 1px 6px;
    border-radius: 4px;
}

/* Layout container */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 2.25rem 2rem;
    animation: fadeIn var(--transition-normal);
}

/* Typography */
h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

h2 {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
}

h3 {
    font-size: 1.18rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 0.25rem;
    margin-bottom: 2rem;
    font-size: 0.95rem;
    line-height: 1.4;
}

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

.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.form-control,
select,
input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.form-control:focus,
select:focus,
input:focus {
    outline: none;
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
    background-color: var(--bg-input-focus);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.15rem;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
    text-decoration: none;
}

.btn-primary {
    background: #0284c7;
    color: white;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.25);
}

.btn-primary:hover {
    background: #0369a1;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.35);
}

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-color-light);
}

.btn-ghost-danger {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--error);
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    border-radius: var(--border-radius-sm);
}

.btn-ghost-danger:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Split Layout */
.split-layout {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.split-form {
    flex: 1 1 420px;
}

.split-view {
    flex: 1.5 1 540px;
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4);
    margin-bottom: 1.5rem;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-card);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

th {
    background-color: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1rem;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-success {
    background-color: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success);
}

.badge-error {
    background-color: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error);
}

.badge-warning {
    background-color: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--warning);
}

.badge-info {
    background-color: rgba(14, 165, 233, 0.12);
    border: 1px solid rgba(14, 165, 233, 0.3);
    color: #38bdf8;
}

/* Timeline Components */
.timeline-container {
    position: relative;
    padding-left: 2.25rem;
    margin-top: 1.5rem;
}

.timeline-container::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background-color: rgba(255, 255, 255, 0.08);
}

.timeline-item {
    position: relative;
    margin-bottom: 1.75rem;
    padding-left: 0.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: calc(-2.25rem + 5px);
    top: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 2px solid #38bdf8;
    box-shadow: 0 0 0 3px var(--bg-card);
    transition: var(--transition-fast);
}

.timeline-item.completed::before {
    border-color: var(--success);
    background-color: var(--success);
}

.timeline-item.rejected::before {
    border-color: var(--error);
    background-color: var(--error);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.timeline-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 0.2rem;
}

.timeline-detail {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.timeline-meta-badge {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* Toast Alerts */
.alert-float-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.alert-toast {
    display: flex;
    align-items: center;
    padding: 0.9rem 1.25rem;
    border-radius: var(--border-radius-sm);
    color: white;
    font-weight: 500;
    font-size: 0.88rem;
    animation: fadeIn var(--transition-fast);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    gap: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.alert-toast-success {
    background-color: #065f46;
    border-color: #059669;
}

.alert-toast-error {
    background-color: #991b1b;
    border-color: #dc2626;
}

.alert-toast-warning {
    background-color: #92400e;
    border-color: #d97706;
}

.alert-toast-close {
    cursor: pointer;
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.8;
}

.alert-toast-close:hover {
    opacity: 1;
}

/* Login Page */
.login-layout {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 460px;
    padding: 2.75rem;
    border: 1px solid var(--border-color-light);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.6);
}

/* Spinner */
.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1rem;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s infinite linear;
}

.spinner-text {
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 500;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 7, 18, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1.5rem;
    animation: fadeIn 0.18s ease;
}

.modal-content-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color-light);
    border-radius: var(--border-radius);
    max-width: 540px;
    width: 100%;
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-body {
    padding: 1.5rem;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.qr-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 1rem 0;
}

.qr-image {
    width: 190px;
    height: 190px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}

.secret-key-display {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1rem;
    letter-spacing: 0.15em;
    background: var(--bg-input);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: #38bdf8;
    user-select: all;
}

/* KPI Cards & Metrics Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.kpi-card {
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.4rem;
    border-radius: var(--border-radius);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 12px 25px -8px rgba(0, 0, 0, 0.5);
}

.kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.kpi-title {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.kpi-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.kpi-subtitle {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* Centrado Ejecutivo de Login */
.login-container {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    background: radial-gradient(circle at 50% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 60%), var(--bg-main);
}

.login-card {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    padding: 2.5rem 2.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

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

.login-logo h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--text-main);
}

.login-logo p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}