:root {
    --color-primary: #0d6e8c;
    --color-primary-dark: #0a566f;
    --color-sidebar: #12233a;
    --color-sidebar-dark: #0c192b;
    --color-accent: #38b6d8;
    --color-bg: #f4f6f9;
    --sidebar-width: 250px;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--color-bg);
    color: #2c3e50;
}

/* ---------- Layout general ---------- */
.app-wrapper { display: flex; min-height: 100vh; }

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: var(--sidebar-width);
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--color-sidebar) 0%, var(--color-sidebar-dark) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: var(--color-accent);
    color: #fff; border-radius: .6rem; font-size: 1.3rem;
}
.brand-name { color: #fff; font-weight: 700; font-size: 1.15rem; line-height: 1; }
.brand-name span { color: var(--color-accent); }
.brand-sub { font-size: .72rem; opacity: .7; }
.brand-logo { width: 40px; height: 40px; border-radius: .6rem; flex-shrink: 0; }
.brand-logo-lg { width: 68px; height: 68px; display: block; margin: 0 auto .8rem; border-radius: 1rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem 0; }

.nav-section {
    padding: .9rem 1.25rem .35rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .62rem 1.25rem;
    color: #cbd5e1;
    font-size: .92rem;
    border-left: 3px solid transparent;
    text-decoration: none;
    transition: all .15s ease;
}
.sidebar .nav-link i { width: 20px; text-align: center; font-size: 1.05rem; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active {
    background: rgba(56,182,216,.14);
    border-left-color: var(--color-accent);
    color: #fff;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: .8rem;
}
.sf-role { font-weight: 600; color: #fff; }
.sf-v { opacity: .6; font-size: .72rem; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: #fff;
    padding: .7rem 1.5rem;
    border-bottom: 1px solid #e6e9ef;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    position: sticky;
    top: 0;
    z-index: 1030;
}
.topbar-title { font-weight: 600; font-size: 1.05rem; color: var(--color-sidebar); }

.topbar-user { display: flex; align-items: center; gap: .6rem; }
.tu-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.tu-name { font-size: .85rem; font-weight: 600; line-height: 1.1; }
.tu-role { font-size: .72rem; color: #7c8797; }

/* ---------- Content ---------- */
.content { padding: 1.5rem; flex: 1; }
.content-footer {
    padding: .8rem 1.5rem;
    border-top: 1px solid #e6e9ef;
    background: #fff;
    color: #64748b;
}

/* ---------- Tarjetas ---------- */
.card { border: 1px solid #e6e9ef; border-radius: .75rem; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card-header { background: #fff; border-bottom: 1px solid #eef1f5; font-weight: 600; }

.stat-card {
    border-radius: .8rem;
    padding: 1.1rem 1.25rem;
/* ---------- Tablas ---------- */
.table-modern { margin-bottom: 0; }
.table-modern thead th {
    background: #f8fafc;
    color: #475569;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid #e2e8f0;
}
.table-modern tbody tr:hover { background: #f8fafc; }

.patient-link {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
}
.patient-link:hover { text-decoration: underline; }

/* ---------- Dashboard menu ---------- */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.menu-tile {
    background: #fff;
    border: 1px solid #e6e9ef;
    border-radius: .8rem;
    padding: 1.3rem;
    text-align: center;
    text-decoration: none;
    color: #2c3e50;
    transition: all .15s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.menu-tile i { font-size: 2rem; color: var(--color-primary); display: block; margin-bottom: .5rem; }
.menu-tile span { font-weight: 600; font-size: .9rem; }
.menu-tile:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.08); border-color: var(--color-accent); color: var(--color-primary); }

/* ---------- Formularios ---------- */
.form-section-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 1.5rem 0 .8rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    border-bottom: 2px solid #eef1f5;
    padding-bottom: .4rem;
}
.form-section-title:first-child { margin-top: 0; }

.required::after { content: " *"; color: #dc3545; }

/* ---------- Perfil / badges ---------- */
.badge-soft-primary { background: #e3f3f9; color: #0d6e8c; }
.badge-soft-warning { background: #fff3cd; color: #8a6d1a; }
.badge-soft-success { background: #d1fae5; color: #0f766e; }
.badge-soft-danger { background: #fee2e2; color: #b91c1c; }
.badge-soft-secondary { background: #e2e8f0; color: #475569; }

.avatar-lg {
    width: 120px; height: 120px;
    border-radius: 50%;
    background: #e3f3f9;
    color: var(--color-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 3rem; font-weight: 700;
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .app-main { margin-left: 0; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
}

    color: #fff;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.06);
}
.stat-icon {
    width: 52px; height: 52px;
    border-radius: .8rem;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; opacity: .9; }

.bg-grad-teal { background: linear-gradient(135deg, #0d6e8c, #38b6d8); }
.bg-grad-indigo { background: linear-gradient(135deg, #4f46e5, #818cf8); }
.bg-grad-green { background: linear-gradient(135deg, #16a34a, #4ade80); }
.bg-grad-orange { background: linear-gradient(135deg, #ea580c, #fb923c); }
.bg-grad-red { background: linear-gradient(135deg, #b91c1c, #f87171); }

/* Caja de clave de licencia (Panel Super Admin) */
.license-key-box {
    font-family: 'Courier New', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: .5px;
    padding: 1rem 1.25rem;
    background: #f1f5f9;
    border: 2px dashed #94a3b8;
    border-radius: .6rem;
    color: #0f172a;
    user-select: all;
    word-break: break-all;
}
.license-key-box.copied {
    border-color: #16a34a;
    background: #d1fae5;
    color: #0f766e;
}
