@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-bg: rgba(37, 99, 235, 0.1);
    --green: #059669;
    --green-dark: #047857;
    --green-bg: #ecfdf5;
    --green-bg-strong: #d1fae5;
    --amber: #b45309;
    --amber-bg: #fef3c7;
    --red: #b91c1c;
    --red-bg: #fee2e2;

    --navy: #0f172a;
    --navy-soft: #1e293b;
    --slate-400: #94a3b8;
    --slate-300: #cbd5e1;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e5e7eb;
    --bg-page: #f5f6f8;

    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 10px -2px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 2px 4px rgba(16, 24, 40, 0.04), 0 12px 24px -6px rgba(16, 24, 40, 0.12);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    background: var(--bg-page);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

svg { display: block; }

/* ======================= Login ======================= */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.08), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(5, 150, 105, 0.08), transparent 40%),
        var(--bg-page);
}

.login-box {
    width: 100%;
    max-width: 380px;
    margin: 0 1.5rem;
    padding: 2.75rem 2.25rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.login-logo {
    width: 80px;
    height: auto;
    display: block;
    margin: 0 auto 1.25rem;
    object-fit: contain;
}

.login-box h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 0.25rem;
}

.login-box .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0 0 1.75rem;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.login-box label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 0.75rem;
}

.login-box input {
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.login-box input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-bg);
}

.login-box button {
    margin-top: 1.5rem;
    padding: 0.75rem;
    background: var(--blue);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.login-box button:hover { background: var(--blue-dark); }
.login-box button:active { transform: translateY(1px); }

.error {
    background: var(--red-bg);
    color: var(--red);
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    margin: 0 0 0.5rem;
}

/* ======================= App shell ======================= */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: var(--navy);
    color: var(--slate-300);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.25rem 0.5rem 1.75rem;
}

.sidebar-logo {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-name {
    color: white;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--slate-400);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.06);
    color: white;
}

.nav-item.active {
    background: rgba(37, 99, 235, 0.25);
    color: white;
}

.nav-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(148, 163, 184, 0.6);
    padding: 1rem 0.75rem 0.35rem;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 0.25rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--blue);
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-user-name {
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--slate-400);
    text-transform: capitalize;
}

.logout-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 0.55rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--slate-300);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

/* ---------- Main area ---------- */

.main-area {
    flex: 1;
    min-width: 0;
}

.page-header {
    padding: 2.25rem 2.5rem 0;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 0.25rem;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin: 0;
}

main {
    max-width: 1180px;
    padding: 1.75rem 2.5rem 4rem;
}

section + section { margin-top: 2.5rem; }

section h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 1rem;
}

/* ---------- Metric cards ---------- */

.metricas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.1rem;
}

.card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon svg { width: 21px; height: 21px; }

.card-icon.blue { background: var(--blue-bg); color: var(--blue); }
.card-icon.green { background: var(--green-bg-strong); color: var(--green); }

.card-value {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.1;
}

.card-value.money { color: var(--green-dark); }

.card-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.card-detail {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
    margin-top: 0.15rem;
}

.card-hero {
    border-color: var(--green-bg-strong);
    border-width: 1px;
    border-left: 4px solid var(--green);
    background: linear-gradient(180deg, var(--green-bg) 0%, white 55%);
}

.card-hero .card-value { color: var(--green-dark); }
.card-hero .card-detail { border-top-color: rgba(5, 150, 105, 0.18); color: var(--green-dark); opacity: 0.75; }

/* ---------- Tables ---------- */

.table-wrap {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 0.85rem 1.4rem;
    font-size: 0.88rem;
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
}

tbody tr:not(:last-child) td {
    border-bottom: 1px solid #f1f3f5;
}

tbody tr {
    transition: background 0.12s;
}

tbody tr:hover {
    background: #fafbfc;
}

td.money, th.money {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

td.money {
    font-weight: 700;
    color: var(--text-primary);
}

.estado {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
}

.estado-vendida {
    background: var(--green-bg-strong);
    color: var(--green-dark);
}

.estado-pendiente {
    background: var(--amber-bg);
    color: var(--amber);
}

/* ---------- Empty state ---------- */

.empty-state {
    background: white;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
}

.empty-state svg {
    width: 32px;
    height: 32px;
    margin-bottom: 0.85rem;
    opacity: 0.6;
}

.empty-state p {
    margin: 0.15rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.empty-state-detail {
    font-size: 0.82rem !important;
    color: var(--text-muted) !important;
}

/* ---------- Configuración / formularios ---------- */

.settings-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.75rem 2rem;
    max-width: 420px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.settings-form label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 0.9rem;
}

.settings-form input {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.settings-form input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-bg);
}

.settings-form button {
    margin-top: 1.5rem;
    padding: 0.7rem;
    background: var(--blue);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.settings-form button:hover { background: var(--blue-dark); }
.settings-form button:active { transform: translateY(1px); }

.form-success {
    background: var(--green-bg-strong);
    color: var(--green-dark);
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    margin: 0 0 1rem;
}
