:root {
    --primary: #0f172a;
    --primary-soft: #1e293b;
    --accent: #2563eb;
    --accent-2: #1d4ed8;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #d9e2ec;
    --text: #0f172a;
    --muted: #64748b;
    --success: #166534;
    --success-bg: #dcfce7;
    --error: #991b1b;
    --error-bg: #fee2e2;
    --radius: 18px;
    --shadow: 0 18px 38px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #f8fbff 0%, #eef3f9 100%);
    color: var(--text);
}

a { text-decoration: none; color: inherit; }

code, pre {
    font-family: Consolas, "Courier New", monospace;
}

.main-shell {
    min-height: 100vh;
}

.topbar {
    height: 78px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    background: linear-gradient(90deg, #0f172a 0%, #172554 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.topbar-start {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.menu-toggle,
.sidebar-close {
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-radius: 12px;
    cursor: pointer;
}

.menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
    align-items: center;
    justify-content: center;
}

.mobile-overlay {
    display: none;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.32);
}

.brand-logo.big {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    font-size: 1.1rem;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.eyebrow {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.78;
    margin-bottom: 4px;
}

.eyebrow.dark {
    color: var(--accent);
    opacity: 1;
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.08);
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.08);
}

.user-role {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.35);
    font-size: 0.72rem;
    text-transform: uppercase;
}

.logout-link {
    color: #fff;
    opacity: 0.85;
}

.logout-link:hover {
    opacity: 1;
}

.page-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    min-height: calc(100vh - 78px);
}

.sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #172554 100%);
    color: #fff;
    padding: 22px 18px;
}

.sidebar-inner {
    position: sticky;
    top: 100px;
}

.sidebar-mobile-head {
    display: none;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sidebar-mobile-head strong {
    font-size: 1rem;
}

.sidebar-close {
    width: 40px;
    height: 40px;
    font-size: 1.4rem;
    line-height: 1;
}

.sidebar-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.6);
    margin-bottom: 12px;
    font-weight: 700;
}

.sidebar-label.mt {
    margin-top: 20px;
}

.home-link,
.admin-link {
    display: flex;
    gap: 12px;
    padding: 14px;
    border-radius: 16px;
    background: rgba(255,255,255,0.06);
    margin-bottom: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    transition: .2s ease;
}

.home-link:hover,
.home-link.active,
.admin-link:hover {
    background: rgba(255,255,255,0.12);
}

.home-link span,
.admin-link span {
    font-size: 1.1rem;
}

.home-link strong,
.admin-link strong {
    display: block;
    color: #fff;
}

.home-link small,
.admin-link small {
    color: rgba(255,255,255,0.72);
}

.menu-group {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    margin-bottom: 12px;
    overflow: hidden;
}

.menu-group summary {
    list-style: none;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 700;
}

.menu-group summary::-webkit-details-marker { display: none; }

.menu-badge,
.mini-badge {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: rgba(37,99,235,0.32);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #fff;
}

.submenu {
    padding: 0 10px 10px;
}

.submenu-link {
    display: block;
    padding: 12px;
    border-radius: 14px;
    color: rgba(255,255,255,0.86);
    transition: .2s ease;
    margin-bottom: 8px;
}

.submenu-link:hover,
.submenu-link.active {
    background: rgba(255,255,255,0.12);
}

.submenu-link strong {
    display: block;
    font-size: 0.93rem;
}

.submenu-link small {
    color: rgba(255,255,255,0.62);
    display: block;
    margin-top: 4px;
}

.content-area {
    min-width: 0;
    padding: 28px;
}

.content-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.page-heading {
    margin: 0;
    font-size: 1.85rem;
}

.hero-card,
.article-card,
.admin-card,
.mini-card,
.status-card {
    background: var(--surface);
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
    gap: 18px;
    padding: 28px;
}

.hero-copy h2 {
    margin: 0 0 10px;
    font-size: 2rem;
}

.hero-copy p {
    font-size: 1rem;
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: 18px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.status-card {
    padding: 20px;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.status-card ul {
    padding-left: 18px;
    line-height: 1.8;
    color: var(--muted);
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.mini-card {
    padding: 20px;
}

.mini-card h3 {
    margin: 16px 0 8px;
}

.mini-card p {
    margin: 0;
    color: var(--muted);
}

.article-card {
    padding: 26px;
    line-height: 1.75;
}

.article-card h1,
.article-card h2,
.article-card h3,
.article-card h4 {
    margin-top: 0;
    color: var(--primary);
}

.article-card p,
.article-card li {
    color: #334155;
}

.article-card img {
    max-width: 100%;
    border-radius: 16px;
    border: 1px solid var(--border);
    margin: 16px 0;
}

.article-card pre,
.helper-box pre {
    background: #0b1220;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 16px;
    overflow: auto;
    border: 1px solid rgba(255,255,255,0.05);
    cursor: copy;
    position: relative;
}

.article-card pre.copied::after,
.helper-box pre.copied::after {
    content: "Copiado";
    position: absolute;
    top: 10px;
    right: 12px;
    background: rgba(37,99,235,0.95);
    color: #fff;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
}

.article-card code {
    background: #e8eef8;
    color: #1e3a8a;
    padding: 2px 8px;
    border-radius: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
}

.btn.small {
    padding: 9px 12px;
    font-size: 0.85rem;
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
}

.btn.secondary {
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--border);
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.alert.success {
    background: var(--success-bg);
    color: var(--success);
    border-color: #86efac;
}

.alert.error {
    background: var(--error-bg);
    color: var(--error);
    border-color: #fca5a5;
}

.admin-grid {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 18px;
}

.admin-card {
    padding: 22px;
}

.admin-card.wide {
    min-width: 0;
}

.page-list {
    display: grid;
    gap: 10px;
}

.page-list-item {
    display: block;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
}

.page-list-item.active {
    border-color: #93c5fd;
    background: #eff6ff;
}

.page-list-item strong {
    display: block;
}

.page-list-item small {
    color: var(--muted);
}

.editor-label {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.editor-label span,
.form-grid span {
    font-size: 0.9rem;
    font-weight: 700;
}

.editor-area {
    width: 100%;
    min-height: 500px;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.92rem;
    resize: vertical;
    background: #fbfdff;
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid label {
    display: grid;
    gap: 8px;
}

input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.helper-box {
    padding: 16px;
    margin-top: 16px;
    border-radius: 16px;
    background: var(--surface-soft);
    border: 1px dashed #cbd5e1;
}

.muted {
    color: var(--muted);
}

.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 22px 0;
}

.upload-form {
    display: grid;
    gap: 12px;
}

.table-wrap {
    overflow: auto;
}

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

.data-table th,
.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    text-align: left;
}

.inline-form {
    display: grid;
    gap: 8px;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at top, #dbeafe 0%, #eff6ff 30%, #f8fafc 100%);
}

.login-shell {
    width: min(100%, 460px);
}

.login-card {
    background: rgba(255,255,255,0.96);
    border-radius: 28px;
    box-shadow: var(--shadow);
    border: 1px solid #e5edf6;
    padding: 30px;
}

.login-brand {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
}

.login-brand h1 {
    margin: 0 0 8px;
    font-size: 1.7rem;
}

.login-brand p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.login-footnote {
    margin-top: 18px;
    color: var(--muted);
}



.article-card a {
    color: var(--accent-2);
    word-break: break-word;
}

.article-card pre,
.helper-box pre,
.editor-area,
.data-table {
    max-width: 100%;
}

@media (max-width: 1100px) {
    .page-layout,
    .admin-grid,
    .hero-card,
    .grid-cards {
        grid-template-columns: 1fr;
    }

    .sidebar-inner {
        position: static;
    }
}

@media (max-width: 900px) {
    .topbar {
        height: auto;
        padding: 14px 16px;
        gap: 12px;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .user-chip {
        max-width: 100%;
        flex-wrap: wrap;
    }

    .page-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: min(88vw, 340px);
        height: 100vh;
        z-index: 40;
        overflow-y: auto;
        transform: translateX(-102%);
        transition: transform .24s ease;
        box-shadow: 0 22px 60px rgba(15, 23, 42, 0.28);
        padding-top: 18px;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-mobile-head {
        display: flex;
    }

    .mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.48);
        opacity: 0;
        visibility: hidden;
        transition: opacity .2s ease, visibility .2s ease;
        z-index: 35;
    }

    body.sidebar-open .mobile-overlay {
        display: block;
        opacity: 1;
        visibility: visible;
    }

    .content-area {
        padding: 18px;
    }

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

    .page-heading {
        font-size: 1.45rem;
    }

    .hero-card,
    .article-card,
    .admin-card,
    .mini-card,
    .status-card,
    .login-card {
        border-radius: 20px;
    }

    .article-card,
    .admin-card,
    .hero-card,
    .login-card {
        padding: 18px;
    }

    .data-table {
        min-width: 640px;
    }
}

@media (max-width: 640px) {
    .brand-title {
        font-size: 0.95rem;
    }

    .eyebrow {
        font-size: 0.68rem;
    }

    .hero-copy h2,
    .login-brand h1 {
        font-size: 1.45rem;
    }

    .login-brand {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-actions {
        align-items: stretch;
    }

    .logout-link {
        width: 100%;
        text-align: center;
        padding: 12px 14px;
        background: rgba(255,255,255,0.08);
        border-radius: 14px;
        border: 1px solid rgba(255,255,255,0.08);
    }

    .btn,
    .btn.small {
        width: 100%;
    }

    .article-card pre,
    .helper-box pre {
        font-size: 0.8rem;
        padding: 14px;
    }

    .editor-area {
        min-height: 360px;
        font-size: 0.85rem;
    }
}


.article-content img,
.content-area img,
article img,
main img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 12px 0;
    border-radius: 10px;
}
