@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&family=Syne:wght@700;800&display=swap');

:root {
    --bg: #0f0f13;
    --bg-secondary: #16161d;
    --surface: #1c1c26;
    --surface-2: #23232f;
    --surface-hover: #2a2a38;

    --border: #2e2e3e;
    --border-light: #3a3a50;

    --accent: #f0a500;
    --accent-hover: #ffc130;
    --accent-glow: rgba(240,165,0,0.12);
    --accent-dim: rgba(196,135,0,0.3);

    --text-primary: #f0eef8;
    --text-secondary: #8e8da6;
    --text-muted: #55546a;

    --green: #2dd98a;
    --green-glow: rgba(45,217,138,0.12);
    --red: #ff5470;
    --red-glow: rgba(255,84,112,0.12);
    --blue: #5b8af5;
    --blue-glow: rgba(91,138,245,0.12);
    --orange: #ff8c42;
    --orange-glow: rgba(255,140,66,0.12);
    --purple: #a78bfa;
    --purple-glow: rgba(167,139,250,0.12);

    --font-display: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'Courier New', monospace;

    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

body {
    background-color: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────────────── */
h1, h2, h3, h4 { font-family: var(--font-display); }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }

.text-2xl  { font-size: 1.75rem; }
.text-xl   { font-size: 1.375rem; }
.text-lg   { font-size: 1.125rem; }
.text-base { font-size: 0.9rem; }
.text-sm   { font-size: 0.875rem; }
.text-xs   { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-accent    { color: var(--accent); }

.font-mono   { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-600    { font-weight: 600; }
.font-bold   { font-weight: 700; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 18px; border-radius: var(--radius); font-family: var(--font-body);
    font-weight: 600; font-size: 0.875rem; cursor: pointer;
    transition: all 0.2s ease; border: none; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

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

.btn-primary {
    background-color: var(--accent); color: #111; font-weight: 700;
}
.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-hover); transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-secondary {
    background-color: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background-color: var(--surface-hover); border-color: var(--border-light); }

.btn-ghost {
    background: none; color: var(--text-secondary); border: 1px solid transparent;
}
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); background-color: var(--surface-2); }

.btn-danger {
    background-color: transparent; color: var(--red); border: 1px solid var(--red);
}
.btn-danger:hover:not(:disabled) { background-color: var(--red-glow); }

/* ── Layout ──────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; width: 240px; height: 100vh;
    background-color: var(--bg-secondary); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 100;
}

.main-content {
    margin-left: 240px; padding: 32px 40px; flex: 1; min-height: 100vh;
}

.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border);
}

/* ── Cards ───────────────────────────────────────── */
.card {
    background-color: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
}
.card:hover { border-color: var(--border-light); }

.stat-card {
    background-color: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px 28px;
    display: flex; flex-direction: column; gap: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; height: 3px;
    width: 100%; background: var(--border); transition: background 0.2s;
}
.stat-card.highlight::before { background: var(--accent); }
.stat-card.highlight { border-color: var(--accent-dim); box-shadow: 0 0 30px var(--accent-glow); }
.stat-card.green::before { background: var(--green); }
.stat-card.green { border-color: var(--green-glow); }
.stat-card.red::before { background: var(--red); }
.stat-card.red { border-color: color-mix(in srgb, var(--red) 30%, transparent); }

.stat-card-label {
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-secondary);
}
.stat-card-value {
    font-family: var(--font-display); font-size: 2.75rem; font-weight: 800; line-height: 1;
}
.stat-card-value.accent { color: var(--accent); }
.stat-card-value.green  { color: var(--green); }
.stat-card-value.red    { color: var(--red); }

/* ── Status Badges ───────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 20px; font-size: 0.75rem;
    font-weight: 600; white-space: nowrap;
}
.badge::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; flex-shrink: 0;
}

.badge-green   { background: var(--green-glow);  color: var(--green); }
.badge-red     { background: var(--red-glow);    color: var(--red); }
.badge-accent  { background: var(--accent-glow); color: var(--accent); }
.badge-orange  { background: var(--orange-glow); color: var(--orange); }
.badge-blue    { background: var(--blue-glow);   color: var(--blue); }
.badge-default { background: var(--surface-2);   color: var(--text-secondary); }

/* ── Table ───────────────────────────────────────── */
.table-container {
    background-color: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
table { width: 100%; border-collapse: collapse; text-align: left; }
th {
    background-color: var(--surface-2); color: var(--text-secondary);
    font-weight: 600; font-size: 0.7rem; text-transform: uppercase;
    letter-spacing: 0.06em; padding: 12px 20px; border-bottom: 1px solid var(--border);
}
td {
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    font-size: 0.875rem; transition: background-color 0.15s;
    overflow-wrap: anywhere; word-break: break-word;
}
tr:hover td { background-color: var(--surface-hover); cursor: pointer; }
tr:last-child td { border-bottom: none; }

/* ── Text overflow safety (entradas extremamente longas) ── */
.text-truncate {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 100%; display: block;
}
.text-clamp-2 {
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; overflow-wrap: anywhere; word-break: break-word;
}

.col-shrink { width: 1%; white-space: nowrap; }

/* ── Inputs ──────────────────────────────────────── */
.input {
    background-color: var(--surface-2); border: 1px solid var(--border);
    color: var(--text-primary); padding: 10px 14px; border-radius: var(--radius);
    font-family: var(--font-body); font-size: 0.875rem; width: 100%;
    transition: all 0.2s; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input::placeholder { color: var(--text-muted); }

select.input { cursor: pointer; }
select.input option { background: var(--surface-2); }

.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); }

.input.input-invalid { border-color: var(--red); }
.input.input-invalid:focus { box-shadow: 0 0 0 3px var(--red-glow); }
.input-error-msg { font-size: 0.75rem; color: var(--red); }

/* ── Search ──────────────────────────────────────── */
.search-wrapper { position: relative; }
.search-wrapper .search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none;
}
.search-wrapper .input { padding-left: 36px; }

/* ── Form Grid ───────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ── Empty State ─────────────────────────────────── */
.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 72px 32px; text-align: center; gap: 12px;
}
.empty-state-icon {
    width: 56px; height: 56px; border-radius: 14px;
    background: var(--surface-2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); margin-bottom: 4px;
}
.empty-state-title { font-family: var(--font-display); font-size: 1rem; color: var(--text-primary); }
.empty-state-desc  { font-size: 0.875rem; color: var(--text-secondary); max-width: 320px; }

/* ── Toast ───────────────────────────────────────── */
.toast-container {
    position: fixed; top: 24px; right: 24px; z-index: 9999;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 12px 20px; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500;
    border: 1px solid; animation: toastIn 0.3s ease; pointer-events: none; min-width: 240px;
    display: flex; align-items: center; gap: 10px;
}
.toast-success { background: var(--green-glow); border-color: var(--green); color: var(--green); }
.toast-error   { background: var(--red-glow);   border-color: var(--red);   color: var(--red); }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.75); z-index: 1000;
    display: flex; justify-content: flex-end;
    backdrop-filter: blur(2px);
}
.modal-content {
    width: 580px; height: 100vh; background: var(--surface);
    border-left: 1px solid var(--border); box-shadow: -16px 0 48px rgba(0,0,0,0.6);
    position: relative; animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1); overflow-y: auto;
    display: flex; flex-direction: column;
}
.modal-header {
    padding: 28px 32px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0;
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.modal-body   { padding: 28px 32px; flex: 1; display: flex; flex-direction: column; gap: 24px; }
.modal-footer {
    padding: 20px 32px; border-top: 1px solid var(--border); flex-shrink: 0;
    display: flex; gap: 12px; justify-content: flex-end;
}
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 4px;
    transition: color 0.15s; border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text-primary); }

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

/* ── Sidebar links ───────────────────────────────── */
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; color: var(--text-secondary); text-decoration: none;
    border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 500;
    transition: all 0.15s; border-left: 2px solid transparent;
}
.sidebar-link:hover { background-color: var(--surface); color: var(--text-primary); }
.sidebar-link.active {
    background-color: var(--accent-glow); color: var(--accent);
    border-left-color: var(--accent);
}
.sidebar-link.active svg { color: var(--accent); }

/* ── Section Label ───────────────────────────────── */
.section-label {
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.1em; color: var(--text-muted); padding: 0 12px;
    margin-bottom: 4px; margin-top: 16px;
}

/* ── Status dot (legacy) ─────────────────────────── */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
.status-dot.green  { background: var(--green);  box-shadow: 0 0 8px rgba(45,217,138,0.4); }
.status-dot.red    { background: var(--red);    box-shadow: 0 0 8px rgba(255,84,112,0.4); }
.status-dot.orange { background: var(--orange); box-shadow: 0 0 8px rgba(255,140,66,0.4); }
.status-dot.accent { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }

/* ── Divider ─────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Scroll ──────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }