:root {
    --primary: #D9070E;
    --primary-dark: #a8050b;
    --primary-light: #f5d0d1;
    --bg: #f4f6f9;
    --sidebar-bg: #1e1e2d;
    --sidebar-text: #a2a3b7;
    --sidebar-active: #ffffff;
    --card-bg: #ffffff;
    --text: #333333;
    --text-light: #6c757d;
    --border: #e4e6ef;
    --success: #1bc5bd;
    --warning: #ffa800;
    --danger: #f64e60;
    --info: #8950fc;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.hidden { display: none !important; }

/* LOGIN */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e1e2d 0%, #2d2d44 100%);
}

.login-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}

.login-logo {
    width: 180px;
    margin-bottom: 24px;
}

.login-card h1 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 32px;
    color: var(--text);
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-light);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.error-msg {
    background: #fff5f5;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 16px;
    border: 1px solid #fecaca;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #15a39c; }

.btn-warning {
    background: var(--warning);
    color: #fff;
}
.btn-warning:hover { background: #e09600; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #d43d4f; }

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

.btn-full { width: 100%; }

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* DASHBOARD LAYOUT */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-logo {
    width: 130px;
    filter: brightness(0) invert(1);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-section {
    padding: 16px 24px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--sidebar-text);
    opacity: 0.6;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.88rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    color: var(--sidebar-active);
    background: rgba(255,255,255,0.03);
}

.nav-link.active {
    color: var(--sidebar-active);
    background: rgba(255,255,255,0.05);
    border-left-color: var(--primary);
}

.nav-link .material-icons {
    font-size: 20px;
}

.sidebar-footer {
    padding: 16px 0;
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
}

.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 32px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar h2 {
    flex: 1;
    font-size: 1.2rem;
    font-weight: 600;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-light);
    font-size: 0.9rem;
}

.content-area {
    padding: 32px;
    flex: 1;
}

/* CARDS */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

/* GRID */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ENTITY CARDS */
.entity-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s;
}

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

.entity-card .entity-name {
    font-weight: 600;
    font-size: 0.95rem;
}

/* FORM INLINE */
.form-inline {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.form-inline .form-group {
    margin-bottom: 0;
}

.form-inline input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
}

.form-inline input:focus {
    outline: none;
    border-color: var(--primary);
}

/* TABLE */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    word-break: break-word;
}

.data-table tr:hover td {
    background: #f8f9fc;
}

.table-wrapper {
    overflow-x: auto;
    margin-top: 16px;
}

/* STATUS BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #ede9fe; color: #5b21b6; }

/* TOAST */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 0.88rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* SCHEDULER */
.scheduler-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.scheduler-card .job-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.scheduler-card .job-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.scheduler-card .job-desc {
    color: var(--text-light);
    font-size: 0.82rem;
    margin-bottom: 12px;
}

.scheduler-card .job-meta {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 16px;
}

.scheduler-card .job-actions {
    display: flex;
    gap: 8px;
}

/* MONITOR */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* LOADING */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

/* RESPONSIVE */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
    .content-area {
        padding: 16px;
    }
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Sub-tables in details */
details {
    cursor: pointer;
}
details summary {
    color: var(--primary);
    font-weight: 500;
    font-size: 0.82rem;
}
details .table-wrapper {
    margin-top: 8px;
}
details .data-table {
    font-size: 0.78rem;
}
details .data-table th,
details .data-table td {
    padding: 6px 10px;
}

/* XML Block */
.xml-block {
    background: #f8f9fc;
    color: #2d3748;
    border: 1px solid var(--border);
    padding: 16px 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.78rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    max-height: 450px;
    overflow-y: auto;
    white-space: pre;
    line-height: 1.6;
    tab-size: 2;
}

/* Vertical key-value table */
.data-table td strong {
    color: var(--text);
    font-weight: 500;
}

/* MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    padding: 24px;
}

.modal {
    background: var(--card-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
    padding: 0 4px;
    transition: color 0.2s;
}
.modal-close:hover { color: var(--danger); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* CLIENTE LIST */
.cliente-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cliente-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid var(--border);
}

.cliente-list-item:hover {
    background: var(--bg);
    border-color: var(--primary-light);
}

.cliente-list-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cliente-list-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.cliente-list-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 2px;
}

/* DETAIL FORM (readonly) */
.detail-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.detail-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary-light);
}

.detail-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px 24px;
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-field label {
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-light);
}

.detail-field span {
    font-size: 0.9rem;
    color: var(--text);
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    min-height: 28px;
}
