:root {
  color-scheme: dark;
  --bg: #0d0f13;
  --panel: #171a20;
  --panel-2: #1d2128;
  --line: #303641;
  --muted: #8c95a3;
  --text: #f2f5f8;
  --accent: #e62123;
  --accent-dark: #321416;
  --live: #f23c4f;
  --green: #35d07f;
  --danger: #ef5362;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 204, 0, .08), transparent 35rem),
    var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

button, input, textarea { font: inherit; }

button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: #242933;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .045em;
  cursor: pointer;
}

button:hover { border-color: #596273; background: #2c323d; }
button:disabled { cursor: wait; opacity: .45; }
button.take { color: #fff; background: var(--accent); border-color: var(--accent); }
button.take:hover { background: #ff3437; border-color: #ff3437; }
button.danger { color: #ff98a2; border-color: #68343b; background: #311c21; }
button.secondary { background: transparent; }

.app { width: min(1500px, 100%); margin: 0 auto; padding: 16px; }

.main-tabs {
  display: flex;
  gap: 0;
  margin: 10px 0;
  border-bottom: 1px solid var(--line);
}
.main-tab {
  min-height: 40px;
  border-radius: 0;
  border-bottom: 3px solid transparent;
  background: #111419;
}
.main-tab + .main-tab { margin-left: -1px; }
.main-tab.active {
  color: #fff;
  border-color: var(--line) var(--line) var(--accent);
  background: var(--panel-2);
}
.tab-view[hidden] { display: none !important; }

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: #111419;
}

.brand, .status-row, .mode-switch, .weather-preview, .row-actions, .row-compact {
  display: flex;
  align-items: center;
}

.brand { gap: 12px; }
.brand-logo {
  display: block;
  width: 142px;
  height: 42px;
  object-fit: contain;
  object-position: left center;
}
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: .14em; }
.status-row { gap: 8px; }
.status {
  padding: 7px 10px;
  border: 1px solid #245d43;
  border-radius: 3px;
  color: var(--green);
  background: #10281d;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
}
.status[data-state="offline"] { color: #ff8e99; border-color: #673039; background: #2d181c; }
.status.neutral { color: #b9c0ca; border-color: var(--line); background: var(--panel); }

.air-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 10px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--live);
  background: #181b21;
}
.air-strip strong { display: block; margin-top: 2px; font-size: 14px; }
.air-strip small { color: var(--muted); }
.section-kicker { color: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .14em; }
.mode-switch { gap: 0; }
.mode-switch button { border-radius: 0; }
.mode-switch button + button { margin-left: -1px; }
.mode-switch button.active { color: #fff; background: var(--accent); border-color: var(--accent); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}
.column { display: grid; align-content: start; gap: 10px; }
.panel { padding: 14px; border: 1px solid var(--line); background: var(--panel); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
h2 { margin: 2px 0 0; font-size: 17px; }

.weather-preview {
  gap: 12px;
  min-height: 70px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #111419;
}
.weather-preview strong { font-size: 30px; }
.weather-preview > span:nth-child(3) { flex: 1; color: var(--muted); }
.live-pill { padding: 5px 8px; color: white; background: var(--live); font-size: 10px; font-weight: 900; letter-spacing: .1em; }

.form-grid { display: grid; gap: 10px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wide { grid-column: 1 / -1; }
label { display: grid; gap: 5px; color: #aab2bd; font-size: 10px; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; }
input, textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  outline: none;
  color: var(--text);
  background: #101318;
  resize: vertical;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
[data-field="title"] { text-transform: uppercase; }

.list { display: grid; gap: 8px; }
.list:empty::after { content: "No hay elementos cargados."; display: block; padding: 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); }
.list-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 10px; border: 1px solid var(--line); background: var(--panel-2); }
.row-main { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.text-row .row-main { grid-template-columns: minmax(130px, .35fr) minmax(0, 1fr); }
.row-actions { align-self: start; gap: 5px; }
.row-actions .icon { width: 34px; padding: 0; font-size: 20px; }
.row-compact { gap: 10px; }
.row-compact > label:first-child { width: 100px; }
.check { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.check input { width: 16px; min-height: 16px; accent-color: var(--accent); }
.enabled { align-self: end; min-height: 36px; }
.days { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.day {
  display: grid;
  width: 31px;
  height: 27px;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #12151a;
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
}
.day input { position: absolute; opacity: 0; pointer-events: none; }
.day:has(input:checked) { color: #fff; border-color: var(--accent); background: var(--accent); }
.text-row .enabled { grid-column: 1 / -1; }

.automation-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; align-items: center; }
.automation-grid.compact { grid-template-columns: minmax(180px, 1fr) minmax(130px, .55fr); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 44px; }
.input-suffix span { position: absolute; top: 12px; right: 10px; color: var(--muted); font-size: 9px; }
.hint { margin: 10px 0 0; color: var(--muted); font-size: 11px; }
.settings-panel { padding: 0; }
.settings-panel summary { padding: 14px; color: #bcc3cc; font-size: 11px; font-weight: 800; cursor: pointer; }
.settings-body { padding: 0 14px 14px; }
.messages-panel { min-height: 520px; }
.message-row .enabled { grid-column: 1 / -1; }
.message-row.on-air {
  border-color: rgba(230, 33, 35, .9);
  box-shadow: inset 3px 0 0 var(--accent);
  background: #241c21;
}
.message-meta {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.air-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid rgba(230, 33, 35, .9);
  color: #fff;
  background: var(--accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .1em;
}
.message-actions { display: grid; grid-template-columns: auto 34px 34px 34px; }
.special-row.on-air {
  border-color: rgba(230, 33, 35, .9);
  box-shadow: inset 3px 0 0 var(--accent);
  background: #241c21;
}
.special-main {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 220px;
}
.special-main strong {
  font-size: 13px;
  line-height: 1.1;
  text-transform: uppercase;
}
.special-main small {
  color: var(--muted);
  font-size: 10px;
}
.special-main .air-badge {
  justify-self: start;
  margin-top: 3px;
}
.special-actions { display: grid; grid-template-columns: auto; }
.auto-summary {
  display: grid;
  min-height: 58px;
  place-content: center;
  text-align: center;
  border: 1px solid var(--line);
  background: #111419;
}
.timing-card {
  display: grid;
  min-height: 58px;
  place-content: center;
  text-align: center;
  border: 1px solid var(--line);
  background: #111419;
}
.timing-card strong { color: var(--text); font-size: 20px; line-height: 1; }
.timing-card span { margin-top: 4px; color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .1em; }
.auto-summary strong { color: var(--accent); font-size: 25px; line-height: 1; }
.auto-summary span { margin-top: 4px; color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .1em; }
.schedule-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #111419;
}
.schedule-card strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  line-height: 1.15;
}
.schedule-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}
.schedule-state {
  display: grid;
  min-width: 120px;
  gap: 5px;
  text-align: right;
}
.schedule-state span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .1em;
}
.schedule-state strong {
  margin: 0;
  color: var(--text);
  font-size: 20px;
}
.schedule-card[data-state="ready"] {
  border-color: rgba(230, 33, 35, .9);
  box-shadow: inset 3px 0 0 var(--accent);
}
.schedule-card[data-state="ready"] .schedule-state span,
.schedule-card[data-state="active"] .schedule-state span {
  color: #fff;
}
.schedule-card[data-state="ready"] .schedule-state strong,
.schedule-card[data-state="active"] .schedule-state strong {
  color: var(--accent);
}
.schedule-card[data-state="active"] {
  border-color: rgba(53, 208, 127, .8);
  box-shadow: inset 3px 0 0 var(--green);
}
.schedule-card[data-state="paused"],
.schedule-card[data-state="error"] {
  border-color: #68343b;
}
.output-url { display: grid; gap: 7px; padding: 12px; border: 1px solid var(--line); background: #111419; }
.output-url span { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .1em; }
.output-url code { overflow-wrap: anywhere; color: var(--accent); font-family: Consolas, monospace; font-size: 12px; }
.muted { margin: 4px 0 0; color: var(--muted); font-size: 10px; }

.results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 10px;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  background: #181b21;
}
.results-heading h1 { margin: 3px 0 0; font-size: 20px; }
.compact-url { min-width: min(480px, 45vw); }
.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .55fr);
  gap: 10px;
}
.admin-user { color: var(--muted); font-size: 10px; font-weight: 800; }
.banner-upload {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(240px, 1fr);
  gap: 14px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.banner-preview,
.banner-ratio-guide {
  display: grid;
  aspect-ratio: 320 / 100;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #596273;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 900;
}
.banner-preview img,
.banner-preview video { width: 100%; height: 100%; object-fit: fill; }
.banner-upload-fields { display: grid; align-content: start; gap: 8px; }
.banner-upload-fields .take { justify-self: start; }
.banner-list { display: grid; gap: 8px; }
.banner-list:empty::after {
  content: "No hay banners cargados.";
  display: block;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
}
.banner-row {
  display: grid;
  grid-template-columns: 192px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.banner-row > img,
.banner-row > video {
  width: 192px;
  height: 60px;
  object-fit: fill;
  border: 1px solid #3b424e;
  background: #fff;
}
.banner-row-main { display: grid; gap: 5px; }
.banner-row-main small { color: var(--muted); font-size: 10px; }
.banner-row-main .check { justify-self: start; }
.banner-actions { display: grid; grid-template-columns: repeat(3, 34px); }
.banner-ratio-guide { margin-top: 12px; }
#banner-save-btn { margin-top: 12px; }
.lp-services-toggle { margin-top: 12px; }
.lp-services-state {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid #77808f;
  background: var(--panel-2);
}
.lp-services-state span,
.lp-services-state small { color: var(--muted); font-size: 9px; }
.lp-services-state strong { font-size: 13px; }
.lp-services-state[data-state="waiting"] { border-left-color: var(--green); }
.lp-services-state[data-state="waiting"] strong { color: var(--green); }
.lp-services-state[data-state="disabled"] { border-left-color: var(--accent); }
.lp-services-state[data-state="disabled"] strong { color: var(--accent); }

@media (max-width: 1000px) {
  .workspace, .results-grid { grid-template-columns: 1fr; }
  .results-heading { align-items: stretch; flex-direction: column; }
  .compact-url { min-width: 0; }
}

@media (max-width: 680px) {
  .app { padding: 8px; }
  .topbar, .air-strip { align-items: stretch; flex-direction: column; }
  .status-row { flex-wrap: wrap; }
  .status-row .danger { flex: 1 0 100%; }
  .form-grid.two, .row-main, .text-row .row-main, .automation-grid { grid-template-columns: 1fr; }
  .wide, .days, .text-row .enabled { grid-column: auto; }
  .list-row { grid-template-columns: 1fr; }
  .row-actions { justify-content: flex-end; }
  .schedule-card { align-items: stretch; flex-direction: column; }
  .schedule-state { min-width: 0; text-align: left; }
  .main-tabs { overflow-x: auto; }
  .main-tab { flex: 0 0 auto; }
  .banner-upload, .banner-row { grid-template-columns: 1fr; }
  .banner-row > img, .banner-row > video { width: 100%; height: auto; aspect-ratio: 320 / 100; }
  .banner-actions { justify-content: end; }
}

.login-page {
  min-height: 100vh;
  background: radial-gradient(circle at 50% 20%, #252b35 0, #111419 46%, #090b0f 100%);
}
.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}
.login-card {
  display: grid;
  width: min(100%, 420px);
  gap: 18px;
  padding: 30px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  background: rgba(20, 23, 29, .96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}
.login-logo { width: 118px; max-height: 50px; object-fit: contain; object-position: left center; }
.login-card h1 { margin: 5px 0; font-size: 28px; }
.login-error {
  margin: 0;
  padding: 11px 12px;
  border: 1px solid rgba(230, 33, 35, .65);
  color: #fff;
  background: rgba(230, 33, 35, .16);
  font-size: 12px;
}
.login-submit { width: 100%; min-height: 44px; }
