:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", Helvetica, Arial, sans-serif;
    --bg: #eef5fb;
    --surface: #ffffff;
    --surface-soft: #f4f7fb;
    --surface-strong: #edf3f9;
    --text: #1f2937;
    --muted: #64748b;
    --accent: #2563eb;
    --accent-soft: #dbeafe;
    --accent-2: #0f766e;
    --danger: #dc2626;
    --success: #16a34a;
    --border: rgba(15, 23, 42, 0.12);
    --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%); color: var(--text); }
body { line-height: 1.6; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell { display: grid; grid-template-columns: 300px 1fr; min-height: 100vh; }
.sidebar {
    background: #0f172a;
    color: #e2e8f0;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}
.sidebar-footer {
    margin-top: auto;
}
.sidebar-footer .btn {
    width: 100%;
    background: transparent;
    color: rgba(226,232,240,0.95);
    border-color: transparent;
    box-shadow: none;
    padding: .75rem 1rem;
    text-align: left;
}
/* Ensure hover on sidebar logout stays light and readable on dark sidebar */
.sidebar-footer .btn:hover {
    background: rgba(255,255,255,0.06) !important;
    border-color: transparent !important;
    color: #ffffff !important;
}
.sidebar-footer .btn:focus-visible {
    outline: 2px solid rgba(255,255,255,0.16);
    outline-offset: 2px;
}
.sidebar .brand { display: flex; align-items: center; gap: 0.9rem; }
.sidebar .logo {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb, #0f766e);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    overflow: hidden;
}
.sidebar .logo img { width: 100%; height: 100%; object-fit: cover; }
.sidebar .brand h1 { margin: 0; font-size: 1.15rem; }
.sidebar .brand p { margin: 0.15rem 0 0; color: #94a3b8; font-size: .92rem; }
.sidebar nav { display: grid; gap: 1rem; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1rem 1rem;
    border-radius: 14px;
    background: transparent;
    color: #e2e8f0;
    font-weight: 600;
    transition: background .2s ease, transform .2s ease;
}
.sidebar nav a .nav-icon {
    width: 26px;
    height: 26px;
    display: inline-grid;
    place-items: center;
    line-height: 1;
    color: #fff;
}
.sidebar nav a .nav-icon svg { width: 26px; height: 26px; }
.sidebar nav a:hover,
.sidebar nav a.active {
    background: rgba(37, 99, 235, .18);
    transform: translateX(2px);
}
.sidebar nav a:hover .nav-icon,
.sidebar nav a.active .nav-icon { color: #fff; }
.sidebar .section-title { margin: 0; font-size: .9rem; text-transform: uppercase; letter-spacing: .1em; color: #94a3b8; }
.sidebar .nav-group { display: grid; gap: 0.4rem; }
.workspace { background: transparent; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.5rem 2rem; }
.topbar h2 { margin: 0; font-size: 1.2rem; letter-spacing: -0.02em; }
.topbar .top-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.content-area { flex: 1; padding: 0 2rem 2rem; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.page-header h1 { margin: 0; font-size: 1.5rem; }
.page-header p { margin: 0; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; border: 1px solid transparent; border-radius: 8px; padding: .7rem 1rem; font-weight: 600; letter-spacing: .01em; transition: transform .15s ease, background-color .15s ease, color .15s ease, border-color .15s ease; cursor: pointer; box-shadow: none; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-secondary { background: #f8fafc; color: #334155; border-color: #e2e8f0; }
.btn-secondary:hover { background: #f1f5f9; color: #0f172a; border-color: #cbd5e1; }
.btn-danger { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.btn-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.btn-success:hover { background: #dcfce7; color: #14532d; border-color: #86efac; }

.card { border-radius: 22px; background: var(--surface); /*box-shadow: var(--shadow);*/ border: 1px solid #e5e7eb; padding: 1.5rem; margin-bottom: 1.5rem; }
.card-alt { background: var(--surface-soft); border: 1px solid rgba(37, 99, 235, .12); }
.hero { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.hero-card { border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); padding: 1.5rem; }
.hero-card h2 { margin-top: 0; font-size: 1.35rem; }
.hero-card p { color: var(--muted); margin: .75rem 0 0; }
.hero-dashboard { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.hero-main { background: linear-gradient(135deg, #eff6ff 0%, #f8fbff 100%); border: 1px solid rgba(37, 99, 235, .12); display: flex; flex-direction: column; justify-content: space-between; gap: 1.25rem; }
.eyebrow { margin: 0 0 .4rem; color: var(--accent); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .78rem; }
.hero-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.stat-card { border-radius: 18px; background: linear-gradient(145deg, #ffffff, #f8fbff); padding: 1rem; border: 1px solid rgba(15, 23, 42, 0.06); }
.stat-card strong { display: block; font-size: 1.6rem; color: #0f172a; margin: .2rem 0; }
.stat-label { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.stat-card small { color: var(--muted); }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.dashboard-card { min-height: 100%; }
.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.quick-action { display: flex; flex-direction: column; gap: .35rem; padding: 1rem; border-radius: 16px; background: #f8fbff; border: 1px solid rgba(37, 99, 235, 0.12); color: #0f172a; }
.quick-action span { font-size: 1.4rem; }
.quick-action strong { font-size: 1rem; }
.quick-action small { color: var(--muted); }
.list-stack { display: grid; gap: .75rem; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 1rem; border-radius: 16px; background: #f8fbff; border: 1px solid rgba(15, 23, 42, 0.06); }
.list-item p { margin: .2rem 0 0; color: var(--muted); }
.list-item span { color: var(--muted); font-size: .95rem; }
.toolbar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-bottom: 1rem; }
.toolbar h2 { margin: 0; font-size: 1.5rem;line-height: 2rem; }
.toolbar p { margin: 0; font-size: 1.0rem; }

.toolbar-col{
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}


.table-container { overflow-x: auto; border-radius: 18px; background: #ffffff; border: 1px solid rgba(15, 23, 42, 0.06); }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 1rem 1rem; text-align: left; border-bottom: 1px solid rgba(15, 23, 42, 0.06); }
th { color: var(--muted); font-size: .95rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid rgba(15, 23, 42, 0.08); background: #eee; }
td { color: #334155; font-size: .975rem; }
tr:hover td { background: rgba(37, 99, 235, 0.05); }
.table-row-card { background: #f8fbff; border-radius: 16px; margin-bottom: .75rem; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; padding: 1rem; }
.table-row-card span { display: block; }
.table-row-card .label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; margin-bottom: .35rem; }
.table-row-card .value { font-weight: 600; color: #0f172a; }
.table-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .35rem .75rem; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.badge-success { background: rgba(16, 185, 129, .12); color: #047857; }
.badge-danger { background: rgba(239, 68, 68, .12); color: #b91c1c; }
.badge-warning { background: rgba(245, 158, 11, .12); color: #92400e; }
.form-grid { display: grid; gap: 1rem; }

.text-muted-foreground {
    color: hsl(220 9% 46%);
}

/* Center forms inside content areas with horizontal margins */
.margin-form {
    margin-left: 200px;
    margin-right: 200px;
}

/* Auth split layout for custom login */
.auth-card.signed-style { max-width: 1100px; margin: 2rem auto; padding: 0; border-radius: 12px; overflow: hidden; display: grid; grid-template-columns: 1fr 540px; }
.auth-left {
    background: linear-gradient(180deg,#0f66d1 0%, #0d4fb2 100%);
    color: #fff; padding: 3.5rem; display:flex; flex-direction:column; justify-content:center; gap:1rem; position:relative;
}
.auth-left h2 { color:#fff; font-size:2rem; margin: 0 0 .25rem; }
.auth-left p { color: rgba(255,255,255,0.9); max-width: 420px; }
.auth-left .brand { display:flex; gap:.75rem; align-items:center; }
.auth-right { background: #fff; padding: 3.5rem; display:flex; flex-direction:column; justify-content:center; }
.role-toggle { display:inline-flex; gap:.5rem; background: #f3f4f6; padding: .25rem; border-radius: 12px; }
.role-toggle button { border: none; background: transparent; padding: .6rem 1rem; border-radius: 10px; cursor: pointer; font-weight:700; color:#475569; }
.role-toggle button.active { background: #fff; box-shadow: 0 8px 24px rgba(37,99,235,0.12); color: #0f172a; }
.login-field { margin-top: 1rem; }
.login-field label { display:block; margin-bottom:.4rem; font-weight:700; color:#334155; }
.login-field input { width:100%; padding: .9rem 1rem; border-radius: 12px; border:1px solid #e6eefc; }
.btn-cta { display:inline-flex; align-items:center; justify-content:center; gap:.5rem; padding: .95rem 1.25rem; background: linear-gradient(90deg,#0f66d1,#0f766e); color:#fff; border-radius:12px; border:none; font-weight:800; box-shadow: 0 20px 40px rgba(15,66,150,0.15); width:100%; }
.small-muted { color:#94a3b8; font-size:.92rem; }
.auth-foot { margin-top: 2rem; display:flex; justify-content:space-between; gap:1rem; color:#94a3b8; font-size:.85rem; }
@media (max-width: 900px) {
    .auth-card.signed-style { grid-template-columns: 1fr; }
    .auth-left { padding: 2rem; }
    .auth-right { padding: 2rem; }
}

.margin-bottom-30 {
    margin-bottom: 30px;
}

/* Ensure forms remain usable on narrow screens */
@media (max-width: 1100px) {
    .content-area .card form,
    .content-area form { margin: 1rem; }
}
.form-grid.columns-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: block; font-weight: 600; margin-bottom: .35rem; color: #334155; }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: .8rem 1rem; background: #fff; color: var(--text); }
textarea { min-height: 140px; resize: vertical; }
.form-note { color: var(--muted); margin-top: .5rem; font-size: .92rem; }
.imc-indicator { display: inline-block; margin-top: .35rem; padding: .35rem .75rem; border-radius: 999px; font-size: .95rem; font-weight: 700; }
.imc-indicator--bajo { background: #dbeafe; color: #1e3a8a; }
.imc-indicator--normal { background: #dcfce7; color: #166534; }
.imc-indicator--sobrepeso { background: #fef9c3; color: #92400e; }
.imc-indicator--obesidad-1 { background: #fed7aa; color: #b45309; }
.imc-indicator--obesidad-2 { background: #fecaca; color: #b91c1c; }
.imc-indicator--obesidad-3 { background: #f8d7da; color: #7f1d1d; border: 1px solid #fca5a5; }
label.required-field::after { content: ' *'; color: #dc2626; font-weight: 700; }
.search-form { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.search-form input[type="search"] { width: 280px; max-width: 100%; }
.pagination { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 1rem 0 0; }
.pagination li { display: inline; }
.pagination li a,
.pagination li span { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0 .9rem; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--text); text-decoration: none; }
.pagination li a:hover { background: rgba(37, 99, 235, .1); border-color: rgba(37, 99, 235, .3); }
.pagination li.active span { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination li.disabled span { opacity: .5; cursor: not-allowed; }
.flash { border-radius: 16px; padding: 1rem 1.2rem; margin-bottom: 1.25rem; display: flex; gap: .9rem; align-items: center; }
.flash-success { background: rgba(16, 185, 129, .12); color: #166534; }
.flash-error { background: rgba(220, 38, 38, .12); color: #7f1d1d; }
footer.site-footer { padding: 1.5rem 2rem; color: var(--muted); }
.divider { height: 1px; background: rgba(148, 163, 184, .12); margin: 1rem 0; }

.receta-preview-shell { max-width: 920px; margin: 0 auto; display: grid; gap: 1rem; }
.receta-actions { display: flex; justify-content: flex-end; gap: .75rem; flex-wrap: wrap; }
.receta-document {
    border-radius: 24px;
    overflow: hidden;
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: var(--shadow);
}
.receta-document__header {
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, #2563eb 0%, #0f766e 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}
.receta-document__header h2 { margin: .2rem 0 .25rem; font-size: 1.35rem; }
.receta-document__header p { margin: 0; color: rgba(255,255,255,0.9); }
.receta-document__meta {
    min-width: 220px;
    display: grid;
    gap: .35rem;
    padding: .9rem 1rem;
    border-radius: 16px;
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.24);
}
.receta-document__meta span {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,0.8);
}
.receta-document__meta strong {
    font-size: 1rem;
    color: #fff;
}
.receta-document__body { padding: 1.5rem 2rem 2rem; }
.receta-document__section {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 18px;
    padding: 1.25rem;
    background: #fcfdff;
}
.receta-document__section h3 {
    margin: 0 0 .75rem;
    color: var(--accent);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.receta-document__content {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 1rem;
    line-height: 1.8;
    color: #334155;
}
.receta-document__footer { display: flex; justify-content: flex-end; margin-top: 1.25rem; }
.receta-document__signature { min-width: 240px; text-align: center; }
.signature-line {
    width: 100%;
    border-top: 1px solid #94a3b8;
    margin-bottom: .8rem;
}
.receta-document__signature strong { display: block; margin-bottom: .2rem; color: #0f172a; }
.receta-document__signature p { margin: 0; color: var(--muted); font-size: .95rem; }

#preview { min-height: 280px; }
#preview .receta-document {
    border-radius: 18px;
    box-shadow: none;
}
#preview .receta-document__header {
    padding: 1rem 1.15rem;
}
#preview .receta-document__body {
    padding: 1rem 1.15rem 1.15rem;
}
#preview .receta-document__section {
    padding: 1rem;
}
#preview .receta-document__content {
    font-size: .95rem;
    line-height: 1.65;
}

@media print {
    body { background: #fff !important; }
    .sidebar, .topbar, .site-footer, .receta-actions, .btn { display: none !important; }
    .content-area { padding: 0; }
    .card { border: none; box-shadow: none; padding: 0; margin: 0; background: transparent; }
    .receta-preview-shell { max-width: none; margin: 0; gap: 0; }
    .receta-document {
        border: 1px solid #d1d5db;
        box-shadow: none;
        border-radius: 0;
    }
    .receta-document__header { padding: 1rem 1.25rem; }
    .receta-document__body { padding: 1rem 1.25rem 1.25rem; }
}

@media (max-width: 1100px) { 
    .app-shell { grid-template-columns: 1fr; } 
    .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 1.25rem 1rem; } 
    .sidebar nav { display: flex; flex-wrap: wrap; gap: .65rem; } 
    .workspace { min-height: auto; } 
    .hero-dashboard { grid-template-columns: 1fr; } 
    .dashboard-grid { grid-template-columns: 1fr; } 
}
@media (max-width: 760px) { 
    .app-shell { padding: 0; } 
    .sidebar { padding: 1rem; } 
    .topbar, .content-area { padding: 1rem; } 
    .hero, .hero-dashboard, .dashboard-grid, .stats-grid, .quick-actions, .grid-2, .grid-3, .grid-4, .form-grid.columns-2 { grid-template-columns: 1fr; } 
    .list-item { flex-direction: column; align-items: flex-start; } 
}
