:root {
    --ink: #172033;
    --muted: #64748b;
    --line: #dbe3ef;
    --bg: #f3f6fb;
    --card: #ffffff;
    --nav: #111936;
    --primary: #ff7600;
    --primary-dark: #df6200;
    --danger: #c62828;
    --success: #16794d;
    --warning: #9a6500;
    --radius: 18px;
    --shadow: 0 14px 38px rgba(22, 34, 65, .10);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
img { max-width: 100%; display: block; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #24366e, #10172e 55%, #080c18); }
.login-card { width: min(440px, 100%); padding: 30px; border-radius: 24px; background: #fff; box-shadow: 0 28px 80px rgba(0,0,0,.35); }
.login-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.login-brand img { width: 70px; height: 70px; object-fit: contain; padding: 5px; border-radius: 18px; border: 1px solid var(--line); }
.login-brand span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-weight: 800; }
.login-brand h1 { margin: 4px 0 0; font-size: 1.55rem; }
.back-link { display: block; margin-top: 18px; text-align: center; color: var(--muted); font-size: .9rem; }

.admin-page { min-height: 100vh; }
.admin-sidebar { position: fixed; inset: 0 auto 0 0; width: 255px; z-index: 50; color: #fff; background: var(--nav); padding: 22px 16px; display: flex; flex-direction: column; }
.admin-brand { display: flex; align-items: center; gap: 12px; padding: 8px; margin-bottom: 24px; }
.admin-brand img { width: 50px; height: 50px; object-fit: contain; border-radius: 14px; background: #fff; padding: 4px; }
.admin-brand div { display: flex; flex-direction: column; }
.admin-brand span { color: rgba(255,255,255,.55); font-size: .78rem; }
.admin-sidebar nav { display: grid; gap: 5px; }
.admin-sidebar nav a { padding: 12px 13px; border-radius: 12px; color: rgba(255,255,255,.78); font-weight: 700; }
.admin-sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-actions { margin-top: auto; display: grid; gap: 8px; }
.sidebar-actions a { padding: 11px 13px; border-radius: 10px; background: rgba(255,255,255,.08); color: rgba(255,255,255,.75); font-size: .88rem; }

.admin-main { margin-left: 255px; width: calc(100% - 255px); padding: 32px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; max-width: 1250px; margin: 0 auto 24px; }
.admin-header span { color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 800; }
.admin-header h1 { margin: 4px 0 0; font-size: clamp(1.7rem, 3vw, 2.5rem); letter-spacing: -.04em; }
.panel { scroll-margin-top: 20px; max-width: 1250px; margin: 0 auto 28px; padding: 28px; background: var(--card); border: 1px solid #e7edf5; border-radius: 24px; box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; margin-bottom: 26px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.panel-heading > div { display: flex; align-items: center; gap: 12px; }
.panel-heading span { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px; color: #fff; background: var(--primary); font-size: .8rem; font-weight: 900; }
.panel-heading h2 { margin: 0; font-size: 1.45rem; }
.panel-heading p { margin: 0; color: var(--muted); max-width: 480px; }

.admin-form { display: grid; gap: 18px; }
.admin-form h3 { margin: 16px 0 -5px; font-size: 1rem; padding-left: 10px; border-left: 4px solid var(--primary); }
.admin-form label { display: grid; gap: 7px; color: #3c4960; font-size: .86rem; font-weight: 750; }
.admin-form input:not([type="checkbox"]):not([type="color"]), .admin-form textarea, .admin-form select { width: 100%; color: var(--ink); background: #fff; border: 1px solid #cfd9e7; border-radius: 11px; padding: 11px 12px; outline: none; transition: .2s; }
.admin-form input:focus, .admin-form textarea:focus, .admin-form select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,118,0,.12); }
.admin-form textarea { resize: vertical; }
.form-grid { display: grid; gap: 16px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }
.narrow { max-width: 560px; }
.compact-form { margin-top: 20px; }
.form-help { margin: -4px 0 0; color: var(--muted); font-size: .82rem; }
.source-line { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .82rem; }
.source-line code { color: #34425d; }

.color-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.color-field { display: grid !important; grid-template-columns: 1fr auto; align-items: center; gap: 8px !important; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcff; }
.color-field span { grid-column: 1 / -1; }
.color-field input { width: 44px; height: 34px; padding: 0; border: 0; background: transparent; }
.color-field code { color: var(--muted); font-size: .78rem; }

.switch-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.switch { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 10px !important; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcff; cursor: pointer; }
.switch.inline { display: inline-flex !important; width: fit-content; padding: 8px 10px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 40px; height: 22px; border-radius: 999px; background: #c9d2df; position: relative; transition: .2s; flex: 0 0 auto; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }

.btn { display: inline-flex; align-items: center; justify-content: center; width: fit-content; border: 0; border-radius: 11px; padding: 11px 16px; font-weight: 850; cursor: pointer; transition: .2s; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { color: #fff; background: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.btn.danger { color: #fff; background: var(--danger); }
.btn.small { padding: 8px 12px; font-size: .84rem; }
.btn.wide { width: 100%; }

.alert { max-width: 1250px; margin: 0 auto 20px; padding: 14px 16px; border-radius: 12px; font-weight: 700; }
.alert.success { color: #12613f; background: #e6f7ef; border: 1px solid #b7e5d0; }
.alert.danger { color: #8c1c1c; background: #ffeaea; border: 1px solid #f3bcbc; }
.alert.warning { color: #805200; background: #fff4d8; border: 1px solid #f3d899; }

.media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.media-uploader { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #fbfcff; }
.media-uploader > span { font-size: .95rem; color: var(--ink); }
.media-uploader img { width: 100%; height: 200px; object-fit: contain; border-radius: 12px; background: #eef2f7; border: 1px solid #e2e8f0; }
.media-uploader small { color: var(--muted); font-weight: 500; }

.create-box { margin-bottom: 22px; border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: #fafcff; }
.create-box summary { cursor: pointer; font-weight: 900; color: var(--primary-dark); }
.item-list { display: grid; gap: 18px; }
.manage-card { position: relative; display: grid; grid-template-columns: 250px 1fr; gap: 20px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.manage-thumb { width: 100%; height: 170px; object-fit: cover; border-radius: 13px; background: #eef2f7; }
.manage-form { align-content: start; }
.delete-form { position: absolute; right: 18px; bottom: 18px; }
.video-preview { min-height: 170px; display: grid; place-items: center; position: relative; border-radius: 13px; overflow: hidden; background: #0d1428; color: #fff; }
.video-preview img { width: 100%; height: 170px; object-fit: cover; }
.video-preview > span { font-size: 3rem; opacity: .9; }
.video-preview small { position: absolute; left: 10px; bottom: 10px; padding: 4px 7px; border-radius: 6px; background: rgba(0,0,0,.7); }
.empty-state { padding: 30px; text-align: center; color: var(--muted); border: 1px dashed #b9c5d5; border-radius: 16px; background: #fbfcff; }

@media (max-width: 1050px) {
    .admin-sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; gap: 16px; }
    .admin-sidebar nav { display: flex; flex-wrap: wrap; }
    .admin-sidebar nav a { padding: 8px 10px; }
    .sidebar-actions { margin: 0 0 0 auto; display: flex; }
    .admin-brand { margin: 0; }
    .admin-main { margin-left: 0; width: 100%; }
    .color-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 780px) {
    .admin-sidebar { display: block; }
    .admin-brand { margin-bottom: 12px; }
    .admin-sidebar nav { display: grid; grid-template-columns: repeat(2, 1fr); }
    .sidebar-actions { display: flex; margin-top: 12px; }
    .admin-main { padding: 18px 12px; }
    .admin-header, .panel-heading { display: block; }
    .admin-header .btn { margin-top: 14px; }
    .panel { padding: 18px; border-radius: 18px; }
    .panel-heading p { margin-top: 10px; }
    .form-grid.cols-2, .media-grid, .switch-grid, .color-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .manage-card { grid-template-columns: 1fr; padding-bottom: 72px; }
    .manage-thumb, .video-preview, .video-preview img { height: 220px; }
}

/* Controles adicionales de noticias y ranking */
.admin-sidebar { overflow-y: auto; }
.switch-row { display: flex; flex-wrap: wrap; gap: 10px; }
.manage-card .switch-row { padding-right: 92px; }
@media (max-width: 780px) {
    .manage-card .switch-row { padding-right: 0; }
}
.ranking-reset-form { margin: -8px 0 18px; }
