:root {
  --bg: #f3f5f8; --panel: #fff; --text: #1b2430; --muted: #6b7a8c; --line: #e2e7ee;
  --primary: #1d6fe0; --primary-dark: #1558b8; --danger: #d33; --ok: #2aa852; --sidebar: #0f1b2d;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
.hidden { display: none !important; }
a { color: var(--primary); }
h1 { font-size: 1.6em; margin: 0 0 18px; }
h3 { margin: 0; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin-top: 8px; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar); }
.login-box { background: var(--panel); padding: 36px; border-radius: 12px; width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.login-box .logo { font-size: 1.5em; font-weight: 700; }
.login-box label { display: block; margin: 18px 0 12px; font-weight: 600; }
.login-box input { width: 100%; margin-top: 6px; }
.login-box .btn { width: 100%; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--sidebar); color: #cbd5e1; display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: 0; height: 100vh; }
.sidebar .logo { color: #fff; font-weight: 700; font-size: 1.2em; margin-bottom: 26px; }
.sidebar nav a { display: block; padding: 10px 12px; border-radius: 8px; color: #cbd5e1; text-decoration: none; margin-bottom: 4px; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: .95em; }
.sidebar-footer a { color: #9fc1f3; text-decoration: none; }
.content { flex: 1; padding: 30px 36px; max-width: 1200px; }

/* Componentes */
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; font-size: 14px; font-weight: 600; }
.btn:hover { border-color: #c9d2de; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }
button.link { background: none; border: 0; color: inherit; cursor: pointer; font-size: inherit; padding: 0; }
input, select, textarea { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff; color: var(--text); font-family: inherit; }
input:focus, select:focus { outline: 2px solid #bcd3f5; border-color: var(--primary); }
label { font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat .label { color: var(--muted); font-size: .9em; }
.stat .value { font-size: 2em; font-weight: 700; margin-top: 4px; }
.stat .value.ok { color: var(--ok); }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfd; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: .8em; font-weight: 600; }
.badge.on { background: #e3f6e9; color: #1d7a3b; }
.badge.off { background: #fde8e8; color: #a12; }
.badge.gray { background: #eef1f5; color: #556; }
.code { font-family: ui-monospace, Consolas, monospace; font-weight: 700; letter-spacing: .1em; }
.thumb { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; background: #000; display: block; }
.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; }
.help { background: #eef5ff; border: 1px solid #cfe0fa; border-radius: 10px; padding: 14px 16px; margin-bottom: 18px; font-size: .95em; }
.help code { background: #fff; padding: 1px 5px; border-radius: 4px; }
.progress { height: 8px; background: #e5eaf1; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--primary); width: 0; transition: width .2s; }

/* Editor de playlist */
.editor { display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; min-height: 300px; }
.list-head { padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: .85em; color: var(--muted); }
.item input[type=number] { width: 70px; padding: 5px 7px; }
.item input[type=date] { padding: 5px 7px; font-size: 13px; }
.item .thumb { width: 64px; height: 36px; }
.item .opts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: .85em; color: var(--muted); }

/* Modal / toast */
.modal { position: fixed; inset: 0; background: rgba(10,20,35,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-box { background: var(--panel); border-radius: 14px; width: 520px; max-width: 100%; padding: 22px 24px; max-height: 90vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1b2430; color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 60; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--danger); }

@media (max-width: 800px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; }
  .sidebar nav { display: flex; gap: 4px; flex-wrap: wrap; }
  .content { padding: 18px; }
  .editor { grid-template-columns: 1fr; }
}

/* Visualizador de mídia */
.thumb-btn { position: relative; background: none; border: 0; padding: 0; cursor: pointer; display: block; }
.thumb-btn .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; text-shadow: 0 1px 6px rgba(0,0,0,.8); }
.thumb-btn:hover .thumb { outline: 2px solid var(--primary); }
.modal-box.wide { width: 900px; }
.preview-stage { background: #000; border-radius: 10px; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.preview-stage img, .preview-stage video { width: 100%; height: 100%; object-fit: contain; }

/* Seleção múltipla de mídias */
.selbar { display: flex; gap: 12px; align-items: center; background: #fff7e6; border: 1px solid #f3dcae; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.selbar .link { color: var(--muted); }
tr.hidden { display: none; }

/* Unidades / grade */
.unit-card { margin-bottom: 14px; }
table.inner { border: 0; margin-top: 10px; }
table.inner td { padding: 6px 8px; }
.item.slot { flex-wrap: wrap; gap: 8px; }
.item.slot select { max-width: 220px; }
.item.slot input[type=time] { padding: 5px 7px; }
.days { display: flex; gap: 3px; }
.day { font-size: 12px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; user-select: none; color: var(--muted); }
.day input { display: none; }
.day.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.week-grid { display: grid; grid-template-columns: 44px repeat(7, 1fr); gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.week-grid .wh { font-size: 12px; font-weight: 600; text-align: center; color: var(--muted); padding-bottom: 4px; }
.week-grid .wt { font-size: 11px; color: var(--muted); line-height: 14px; }
.week-grid .wc { height: 14px; border-radius: 3px; }
.week-grid .wc.def, .legend i.def { background: #e5eaf1; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Programas */
.prog-thumb { display: inline-flex; align-items: center; justify-content: center; font-size: 20px; background: #1E3A8A; color: #fff; width: 64px; height: 36px; border-radius: 6px; flex: none; }
table .prog-thumb { width: 96px; height: 54px; font-size: 28px; }
.city-res button { display: block; width: 100%; text-align: left; margin-top: 6px; }
.checks { display: flex; flex-direction: column; gap: 6px; }
.checks label { font-weight: normal; }
textarea { width: 100%; min-height: 110px; resize: vertical; }
.type-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 20px; }
.type-card { text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); cursor: pointer; }
.type-card:hover { border-color: var(--primary); }
.type-card b { display: block; margin-bottom: 4px; }
.type-card span { font-size: 13px; color: var(--muted); }

.badge.warn { background: #fff3cd; color: #7a5a00; }
.stat .value.bad { color: #a12; }
.stat .value.warn { color: #a66d00; }
.help.warn-box { background: #fff7e6; border-color: #f3dcae; }
textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
