:root {
    --green: #1f7a3a;
    --green-dark: #145528;
    --leaf: #2e8f48;
    --gold: #e2b51a;
    --blue: #1a6fb3;
    --ink: #1c2a22;
    --muted: #5b6b62;
    --paper: #f4f7f2;
    --white: #ffffff;
    --line: #d5e0d6;
    --danger: #b42318;
    --shadow: 0 10px 30px rgba(20, 50, 28, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Segoe UI", Calibri, "Trebuchet MS", Arial, sans-serif;
    color: var(--ink);
    background: var(--paper);
}

img { max-width: 100%; display: block; }
button, input { font: inherit; }
a { color: var(--green-dark); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
}
.btn-primary {
    background: var(--green);
    color: #fff;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-ghost {
    background: transparent;
    color: var(--green-dark);
    border: 1px solid var(--line);
}
.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin: 0 0 16px;
}
.alert-error {
    background: #fdecea;
    color: #7a1c14;
}

/* Login */
.page-login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        linear-gradient(180deg, #eef6ea 0%, #f7f4e8 70%, #e7f0fb 100%);
}
.login-card {
    width: min(420px, 92vw);
    background: var(--white);
    padding: 32px 28px 22px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border-top: 6px solid var(--green);
}
.login-logo { height: 72px; width: auto; margin: 0 auto 12px; }
.login-kicker {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 12px;
    color: var(--blue);
    margin: 0;
    text-align: center;
}
.login-card h1 {
    margin: 6px 0 20px;
    text-align: center;
    font-size: 24px;
}
.login-card form { display: grid; gap: 12px; }
.login-card label, .panel label, .page-admin label {
    display: grid;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
}
.login-card input,
.panel input[type="text"],
.panel input[type="number"],
.panel input[type="password"] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
}
.login-foot { text-align: center; margin: 18px 0 0; font-size: 14px; }

/* Admin */
.page-admin {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.admin-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 4px solid var(--gold);
}
.admin-top img { height: 64px; width: auto; }
.admin-top-actions { display: flex; gap: 8px; }
.admin-wrap {
    width: min(1100px, 94vw);
    margin: 28px auto;
    display: grid;
    gap: 20px;
    flex: 1;
}
.panel {
    background: #fff;
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--shadow);
}
.panel-head h1, .panel h2 { margin: 0 0 6px; }
.panel-head p, .hint { margin: 0; color: var(--muted); }
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: stretch;
}
.grid-2 form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    align-content: stretch;
}
.grid-2 form .btn-primary {
    margin-top: auto;
    align-self: start;
}
.grid-2 form .form-status {
    min-height: 1.2em;
}

.dropzone {
    margin-top: 16px;
    border: 2px dashed #9dbea3;
    border-radius: 12px;
    background: #f7fbf6;
    padding: 28px 18px;
    text-align: center;
    position: relative;
    cursor: pointer;
}
.dropzone.dragover { background: #e8f6ea; border-color: var(--green); }
.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.dropzone-copy { display: grid; gap: 6px; color: var(--muted); pointer-events: none; }
.dropzone-copy strong { color: var(--ink); font-size: 18px; }
.upload-status { margin-top: 12px; font-weight: 600; }

.playlist { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.playlist-item {
    display: grid;
    grid-template-columns: 28px 72px minmax(0, 1fr) 110px auto auto;
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}
.playlist-item.dragging { opacity: 0.45; }
.drag-handle { cursor: grab; color: #8aa08d; font-weight: 700; letter-spacing: -2px; text-align: center; }
.thumb {
    width: 72px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    background: #e8eee8;
    display: grid;
    place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--blue);
}
.item-meta small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-title { border: 1px solid transparent; padding: 6px 8px; border-radius: 6px; width: 100%; }
.item-title:focus { border-color: var(--green); outline: none; }
.item-duration { width: 72px; }
.inline { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.item-actions { display: flex; gap: 4px; }
.icon-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
}
.icon-btn.danger { color: var(--danger); }
.empty-state {
    margin-top: 16px;
    padding: 28px;
    text-align: center;
    color: var(--muted);
    background: #f7faf6;
    border-radius: 12px;
}
.form-status { margin: 0; font-size: 14px; }
.admin-footer {
    margin-top: auto;
    width: 100%;
    line-height: 0;
    background: #000;
    overflow: hidden;
    flex-shrink: 0;
}
.admin-footer img {
    display: block;
    width: 110%;
    max-width: none;
    height: 15px;
    object-fit: cover;
    object-position: center;
}

@media (max-width: 860px) {
    .playlist-item {
        grid-template-columns: 24px 56px 1fr;
    }
    .item-actions, .inline, .switch { grid-column: 1 / -1; }
    .grid-2 { grid-template-columns: 1fr; }
    .admin-top { flex-direction: column; align-items: flex-start; }
}

/* TV kiosk */
html:has(.page-tv),
body.page-tv {
    height: 100%;
    margin: 0;
}
.page-tv {
    background: #0b1a10;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.tv {
    flex: 1;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.tv-header {
    flex: 0 0 auto;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    border-bottom: 4px solid var(--gold);
}
.tv-header img { height: 64px; width: auto; }
.tv-clock {
    flex: 1;
    min-width: 0;
    font-size: clamp(16px, 2.2vh, 26px);
    font-weight: 700;
    color: var(--green-dark);
    text-align: right;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tv-stage {
    position: relative;
    background: #08140c;
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 0;
}
.tv-empty,
.tv-frame {
    position: absolute;
    inset: 0;
}
.tv-empty {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 12px;
    color: #e8f3ea;
    text-align: center;
}
.tv-empty img { height: 90px; width: auto; background: #fff; padding: 10px 16px; border-radius: 8px; }
.tv-empty p { margin: 0; font-size: 28px; }
.tv-frame {
    background:
        radial-gradient(ellipse at center, #102418 0%, #08140c 72%);
    overflow: hidden;
}
.tv-slot {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    opacity: 0;
    transform: scale(1.015);
    transition: opacity 0.7s ease, transform 0.7s ease;
    z-index: 1;
}
.tv-slot.is-on {
    opacity: 1;
    transform: none;
    z-index: 2;
}
.tv-slot.is-leave {
    opacity: 0;
    transform: translateX(-4%) scale(0.985);
}
.tv-slot.is-enter {
    opacity: 0;
    transform: translateX(5%) scale(1.02);
}
.tv-slot img,
.tv-slot video,
.tv-slot embed,
.tv-slot iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    min-width: 0;
    min-height: 0;
    margin: 0;
    object-fit: contain;
    object-position: center center;
    image-orientation: from-image;
}
.tv-slot canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.pdf-ui {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
}
.pdf-badge {
    position: absolute;
    top: 14px;
    right: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--green-dark);
    border: 1px solid rgba(226, 181, 26, 0.85);
    border-radius: 999px;
    padding: 7px 14px 7px 10px;
    font-size: clamp(12px, 1.5vh, 16px);
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}
.pdf-badge::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 0 3px rgba(226, 181, 26, 0.25);
}
.tv-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 18px;
    margin: 0 auto;
    width: min(90%, 1100px);
    background: rgba(11, 36, 18, 0.78);
    color: #fff;
    padding: 10px 16px;
    border-left: 6px solid var(--gold);
    font-size: clamp(16px, 2.2vh, 28px);
    z-index: 5;
}
.tv-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 6px;
    background: rgba(255,255,255,0.15);
    z-index: 6;
}
.tv-progress span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--leaf), var(--gold), var(--blue));
}
.tv-header {
    width: 100%;
    max-width: none;
}
.tv-footer {
    flex: 0 0 auto;
    margin-top: auto;
    width: 100%;
    line-height: 0;
    background: #000;
    overflow: hidden;
    flex-shrink: 0;
}
.tv-footer img {
    display: block;
    width: 110%;
    max-width: none;
    height: 15px;
    object-fit: cover;
    object-position: center;
}
