:root {
    --pine-950: #06100e;
    --pine-900: #0a1916;
    --pine-800: #102720;
    --pine-700: #17382e;
    --pine-100: #dce9e3;
    --ivory: #f7f3e9;
    --paper: #fdfbf6;
    --gold: #c9a15b;
    --gold-light: #ead6a7;
    --ink: #14201d;
    --muted: #6c7773;
    --line: #e3e2dc;
    --danger: #a8413a;
    --success: #237051;
    --shadow: 0 18px 48px rgba(6, 25, 20, .10);
    color-scheme: light;
    font-family: Inter, Avenir, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #f2f2ed; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: #f2f2ed;
    -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.eyebrow {
    display: block;
    margin-bottom: 7px;
    color: #80632f;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}

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

.brand-mark {
    display: grid;
    width: 58px;
    height: 58px;
    place-items: center;
    border: 1px solid rgba(234, 214, 167, .65);
    border-radius: 50%;
    color: var(--gold-light);
    font-family: Georgia, serif;
    font-size: 28px;
    line-height: 1;
    box-shadow: inset 0 0 0 5px rgba(201, 161, 91, .08);
}

.brand-mark-small { width: 40px; height: 40px; font-size: 20px; }

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 750;
    transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid rgba(201, 161, 91, .3); outline-offset: 2px; }
.button-primary { color: white; background: var(--pine-800); box-shadow: 0 8px 22px rgba(12, 44, 35, .18); }
.button-primary:hover { background: var(--pine-700); }
.button-secondary { color: var(--pine-800); border-color: #ccd5d0; background: white; }
.button-secondary:hover { border-color: var(--gold); }
.button-ghost { color: inherit; border-color: rgba(128, 99, 47, .22); background: transparent; }
.button-ghost:hover { background: rgba(201, 161, 91, .08); }
.button-danger { color: white; background: var(--danger); }
.button-small { min-height: 35px; padding: 7px 12px; font-size: 13px; }
.button-wide { width: 100%; }

label { color: #33433e; font-size: 13px; font-weight: 700; }
input, select {
    width: 100%;
    min-height: 43px;
    margin-top: 7px;
    padding: 9px 11px;
    border: 1px solid #d7ddd9;
    border-radius: 9px;
    color: var(--ink);
    background: white;
}
input[type="color"] { padding: 4px; }
input[type="range"] { min-height: 28px; padding: 0; accent-color: var(--pine-700); }
label small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 500; }

.stack-form { display: grid; gap: 16px; }
.compact-form { display: grid; gap: 10px; padding-top: 12px; }

.notice {
    padding: 13px 16px;
    border: 1px solid;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.45;
}
.notice-error { color: #742a25; border-color: #edc3bf; background: #fff2f0; }
.notice-success { color: #18553d; border-color: #b9dfcf; background: #effaf5; }

/* Acceso */
.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(circle at 12% 12%, rgba(201, 161, 91, .16), transparent 27%),
        linear-gradient(125deg, var(--pine-950) 0 48%, #eef0e9 48% 100%);
}

.auth-shell {
    display: grid;
    width: min(100%, 940px);
    grid-template-columns: .9fr 1.1fr;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 22px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .26);
}

.auth-shell-compact { width: min(100%, 820px); }
.auth-brand { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 58px 48px; color: var(--ivory); background: linear-gradient(145deg, rgba(16,39,32,.78), rgba(5,15,13,.97)); }
.auth-brand > div { margin-top: 19px; }
.auth-brand strong { display: block; font-family: Georgia, serif; font-size: 33px; font-weight: 500; letter-spacing: .18em; }
.auth-brand small { display: block; margin-top: 5px; color: var(--gold-light); font-size: 10px; font-weight: 700; letter-spacing: .16em; }
.auth-brand p { max-width: 290px; margin: 35px 0 0; color: #b9c8c1; font-size: 14px; line-height: 1.7; }
.auth-card { padding: 48px; background: var(--paper); }
.auth-card h1 { margin: 0; font-family: Georgia, serif; font-size: 36px; font-weight: 500; }
.auth-card > p { margin: 10px 0 24px; line-height: 1.6; }
.auth-card .notice { margin-bottom: 18px; }
.requirements { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 0 0 22px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 11px; }
.requirements div { display: flex; align-items: center; gap: 7px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.status-dot.is-ok { background: var(--success); box-shadow: 0 0 0 3px rgba(35,112,81,.1); }
.status-dot.is-warn { background: var(--gold); box-shadow: 0 0 0 3px rgba(201,161,91,.12); }

/* Panel */
.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    height: 68px;
    align-items: center;
    justify-content: space-between;
    padding: 0 27px;
    color: var(--ivory);
    border-bottom: 1px solid rgba(234, 214, 167, .18);
    background: rgba(6, 16, 14, .96);
    backdrop-filter: blur(14px);
}

.wordmark { display: flex; align-items: center; gap: 12px; }
.wordmark strong { display: block; font-family: Georgia, serif; font-size: 20px; font-weight: 500; letter-spacing: .15em; }
.wordmark small { display: block; margin-top: 2px; color: var(--gold-light); font-size: 8px; letter-spacing: .14em; }
.topbar-actions { display: flex; align-items: center; gap: 13px; }
.topbar-actions form { margin: 0; }
.connection-pill { display: flex; align-items: center; gap: 7px; color: #c8d5d0; font-size: 12px; }
.connection-pill span { width: 7px; height: 7px; border-radius: 50%; background: #59c493; box-shadow: 0 0 0 4px rgba(89,196,147,.12); }

.flash { position: fixed; z-index: 50; top: 82px; right: 22px; display: flex; max-width: 520px; align-items: center; gap: 18px; box-shadow: var(--shadow); animation: slide-in .28s ease both; }
.flash button { margin-left: auto; border: 0; color: inherit; background: none; cursor: pointer; font-size: 22px; }
@keyframes slide-in { from { opacity: 0; transform: translateY(-10px); } }

.dashboard-shell { display: grid; min-height: calc(100vh - 68px); grid-template-columns: 270px minmax(0, 1fr); }
.sidebar { position: sticky; top: 68px; align-self: start; min-height: calc(100vh - 68px); padding: 28px 17px; color: #d6dfdb; background: var(--pine-900); }
.sidebar-heading { display: flex; align-items: end; justify-content: space-between; padding: 0 10px 17px; }
.sidebar-heading .eyebrow { margin: 0; color: var(--gold-light); }
.sidebar-heading strong { color: #9fb1aa; font-size: 11px; }
.channel-nav { display: grid; gap: 5px; }
.channel-link { display: grid; grid-template-columns: 28px 1fr; gap: 9px; padding: 12px 11px; border: 1px solid transparent; border-radius: 11px; transition: .16s ease; }
.channel-link:hover { background: rgba(255,255,255,.05); }
.channel-link.is-active { border-color: rgba(234,214,167,.2); color: white; background: linear-gradient(110deg, rgba(201,161,91,.18), rgba(255,255,255,.055)); }
.channel-icon { color: var(--gold); font-size: 15px; }
.channel-link strong, .channel-link small { display: block; }
.channel-link strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.channel-link small { margin-top: 4px; color: #8fa39b; font-size: 10px; }
.create-channel { margin-top: 12px; padding: 0 10px; }
.create-channel summary { cursor: pointer; color: var(--gold-light); font-size: 12px; font-weight: 750; list-style: none; }
.create-channel summary::-webkit-details-marker { display: none; }
.create-channel label { color: #cbd8d2; font-size: 11px; }
.create-channel input { min-height: 38px; border-color: #355047; color: white; background: #122c25; }
.sidebar-note { display: grid; grid-template-columns: 23px 1fr; gap: 10px; margin: 30px 9px 0; padding: 14px; border: 1px solid rgba(201,161,91,.16); border-radius: 11px; background: rgba(201,161,91,.06); }
.sidebar-note .note-icon { display: grid; width: 20px; height: 20px; place-items: center; border: 1px solid var(--gold); border-radius: 50%; color: var(--gold-light); font-family: Georgia,serif; font-size: 12px; }
.sidebar-note p { margin: 0; color: #92a69e; font-size: 10px; line-height: 1.45; }
.sidebar-note strong { display: block; margin-bottom: 3px; color: #d8e2de; font-size: 11px; }

.main-content { width: min(100%, 1380px); padding: 38px 42px 70px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 25px; margin-bottom: 25px; }
.page-heading h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(30px, 4vw, 43px); font-weight: 500; letter-spacing: -.02em; }
.page-heading p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 17px; }
.metric-card { position: relative; overflow: hidden; padding: 20px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.7); }
.metric-card span, .metric-card small { display: block; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.metric-card strong { display: block; margin: 9px 0 5px; font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.metric-card-accent { color: var(--ivory); border-color: var(--pine-800); background: var(--pine-800); }
.metric-card-accent span, .metric-card-accent small { color: #b7c8c1; }
.metric-card-accent::after { position: absolute; right: -19px; bottom: -34px; width: 95px; height: 95px; border: 1px solid rgba(201,161,91,.3); border-radius: 50%; content: ""; }

.panel { margin-top: 17px; padding: 24px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); box-shadow: 0 5px 20px rgba(6,25,20,.035); }
.panel-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 21px; }
.panel h2 { margin: 0; font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.endpoint-panel { display: flex; align-items: center; justify-content: space-between; gap: 22px; color: #dfe9e4; border-color: var(--pine-800); background: linear-gradient(110deg, var(--pine-800), #17382e); }
.endpoint-panel .eyebrow { color: var(--gold-light); }
.endpoint-panel code { display: block; overflow: hidden; max-width: min(70vw, 900px); color: white; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.endpoint-panel .button { color: white; border-color: rgba(255,255,255,.22); }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.settings-grid output { float: right; color: var(--gold); }

.drag-help, .storage-note { color: var(--muted); font-size: 11px; }
.playlist { display: grid; gap: 9px; }
.playlist-item { display: grid; grid-template-columns: 28px 92px minmax(250px, 1fr) auto; align-items: center; gap: 13px; padding: 11px; border: 1px solid #e0e3df; border-radius: 12px; background: white; transition: opacity .2s, border-color .2s, box-shadow .2s; }
.playlist-item.is-disabled { opacity: .55; }
.playlist-item.is-dragging { opacity: .38; border-color: var(--gold); }
.playlist-item.drag-over { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,161,91,.12); }
.drag-handle { padding: 5px; border: 0; color: #a5ada9; background: none; cursor: grab; font-size: 21px; }
.media-thumb { position: relative; display: grid; width: 92px; height: 64px; overflow: hidden; place-items: center; padding: 0; border: 0; border-radius: 8px; color: white; background: linear-gradient(145deg, var(--pine-700), var(--pine-950)); cursor: pointer; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb small { position: absolute; right: 4px; bottom: 4px; padding: 2px 5px; border-radius: 4px; color: white; background: rgba(0,0,0,.65); font-size: 8px; font-weight: 800; }
.play-symbol { display: grid; width: 30px; height: 30px; place-items: center; padding-left: 2px; border: 1px solid rgba(255,255,255,.7); border-radius: 50%; font-size: 10px; }
.item-fields { min-width: 0; }
.item-title { display: block; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.item-title input { min-height: 34px; margin: 2px 0 6px; padding: 5px 8px; border-color: transparent; font-size: 14px; font-weight: 700; }
.item-title input:hover, .item-title input:focus { border-color: #d7ddd9; }
.item-options { display: flex; align-items: center; gap: 11px; }
.item-options label { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 600; }
.item-options input, .item-options select { width: auto; min-height: 29px; margin: 0; padding: 3px 7px; font-size: 10px; }
.item-options input { width: 54px; }
.item-options label small { margin: 0; }
.media-badge { padding: 4px 7px; border-radius: 5px; color: #52615c; background: #edf1ef; font-size: 9px; font-weight: 800; }
.item-size { color: #8b9691; font-size: 10px; }
.item-actions { display: flex; align-items: center; gap: 7px; }
.switch { display: grid; grid-template-columns: 35px; justify-items: center; gap: 3px; color: var(--muted); font-size: 8px; cursor: pointer; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch span { position: relative; width: 35px; height: 19px; border-radius: 20px; background: #c8cfcc; transition: .2s; }
.switch span::after { position: absolute; top: 3px; left: 3px; width: 13px; height: 13px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.22); content: ""; transition: .2s; }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch small { margin: 0; font-size: 8px; }
.order-buttons { display: grid; }
.order-buttons button, .icon-button { display: grid; width: 28px; height: 26px; place-items: center; padding: 0; border: 1px solid #dde1df; color: #61706b; background: white; cursor: pointer; }
.order-buttons button:first-child { border-radius: 6px 6px 0 0; }
.order-buttons button:last-child { margin-top: -1px; border-radius: 0 0 6px 6px; }
.icon-button { height: 32px; border-radius: 7px; font-size: 17px; }
.icon-button-danger { color: var(--danger); }
.save-row { display: flex; justify-content: flex-end; margin-top: 20px; }
.empty-state { padding: 47px 20px; text-align: center; border: 1px dashed #d8dcd9; border-radius: 12px; background: #faf9f4; }
.empty-gem { display: block; color: var(--gold); font-family: Georgia,serif; font-size: 40px; }
.empty-state h3 { margin: 7px 0; font-family: Georgia,serif; font-size: 21px; font-weight: 500; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }

.tab-buttons { display: flex; gap: 4px; margin-bottom: 20px; padding: 4px; border-radius: 10px; background: #eeefea; }
.tab-buttons button { flex: 1; padding: 10px; border: 0; border-radius: 7px; color: #69746f; background: transparent; cursor: pointer; font-size: 12px; font-weight: 750; }
.tab-buttons button.is-active { color: var(--pine-800); background: white; box-shadow: 0 2px 9px rgba(0,0,0,.06); }
.upload-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 15px; }
.drop-zone { display: grid; min-height: 145px; place-items: center; align-content: center; padding: 20px; border: 1px dashed #bfcac5; border-radius: 12px; background: #f7f8f4; cursor: pointer; text-align: center; }
.drop-zone:hover { border-color: var(--gold); background: #fbf8f0; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone strong { margin: 4px 0; font-size: 14px; }
.drop-zone small { color: var(--muted); font-size: 11px; }
.upload-icon { display: grid; width: 35px; height: 35px; place-items: center; border: 1px solid var(--gold); border-radius: 50%; color: #8d6b31; font-size: 19px; }
.external-form { display: grid; grid-template-columns: 1fr 2fr .7fr .7fr 1fr auto; align-items: end; gap: 11px; }

.danger-panel summary { cursor: pointer; font-weight: 750; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 25px; padding-top: 25px; border-top: 1px solid var(--line); }
.admin-grid h3 { margin: 0 0 14px; }
.delete-channel-form { align-self: start; padding: 20px; border: 1px solid #edcfcc; border-radius: 11px; background: #fff7f6; }
.delete-channel-form p { color: #785450; font-size: 13px; }

.preview-dialog { width: min(92vw, 980px); max-width: none; padding: 0; overflow: visible; border: 0; border-radius: 14px; background: #030706; box-shadow: 0 30px 100px rgba(0,0,0,.5); }
.preview-dialog::backdrop { background: rgba(4,12,10,.78); backdrop-filter: blur(4px); }
.preview-close { position: absolute; z-index: 2; top: -14px; right: -14px; display: grid; width: 34px; height: 34px; place-items: center; border: 2px solid white; border-radius: 50%; color: white; background: var(--pine-800); cursor: pointer; font-size: 21px; }
.preview-dialog img, .preview-dialog video { display: block; width: 100%; max-height: 78vh; object-fit: contain; border-radius: 14px; }

@media (max-width: 1120px) {
    .dashboard-shell { grid-template-columns: 225px minmax(0,1fr); }
    .main-content { padding: 30px 25px 60px; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-grid { grid-template-columns: repeat(2, 1fr); }
    .playlist-item { grid-template-columns: 22px 78px minmax(210px, 1fr); }
    .media-thumb { width: 78px; }
    .item-actions { grid-column: 3; justify-content: flex-end; }
    .external-form { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
    .auth-page { padding: 15px; background: var(--pine-950); }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { padding: 30px; }
    .auth-brand p { margin-top: 15px; }
    .auth-card { padding: 30px; }
    .topbar { height: 62px; padding: 0 15px; }
    .connection-pill { display: none; }
    .wordmark small { display: none; }
    .dashboard-shell { display: block; }
    .sidebar { position: static; min-height: 0; padding: 14px; }
    .sidebar-heading, .sidebar-note { display: none; }
    .channel-nav { display: flex; overflow-x: auto; }
    .channel-link { min-width: 180px; }
    .create-channel { margin: 12px 0 0; }
    .main-content { padding: 24px 14px 50px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .panel { padding: 18px; }
    .settings-grid, .admin-grid { grid-template-columns: 1fr; }
    .playlist-item { grid-template-columns: 20px 68px 1fr; }
    .media-thumb { width: 68px; height: 58px; }
    .item-options { flex-wrap: wrap; }
    .item-actions { grid-column: 2 / 4; }
    .upload-form { grid-template-columns: 1fr; }
    .external-form { grid-template-columns: 1fr; }
    .endpoint-panel code { max-width: 60vw; }
}

@media (max-width: 470px) {
    .requirements { grid-template-columns: 1fr; }
    .auth-card h1 { font-size: 30px; }
    .metric-grid { grid-template-columns: 1fr; }
    .heading-actions { width: 100%; }
    .heading-actions .button { flex: 1; }
    .playlist-item { grid-template-columns: 20px 1fr; }
    .media-thumb { grid-row: 2; width: 100%; height: 120px; }
    .item-fields { grid-column: 2; grid-row: 1 / 3; }
    .item-actions { grid-column: 1 / 3; }
}
