:root {
  --bg: #0D1117; --panel: #161B22; --panel2: #1F2630; --line: #2B3441; --text: #F2F4F7; --muted: #9AA4AF;
  --u1: #FF7A7A; --u2: #FFB347; --u3: #7FB2FF; --u4: #7ED6A0;
  --cond: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --sans: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --badge-bg: #161B22;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; }
body.tv { font-size: clamp(16px, 1.05vw, 30px); }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; }
:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

#app { height: 100%; display: flex; flex-direction: column; padding: 18px 28px 20px; gap: 14px; min-height: 0; }

/* cabecera */
.top { display: flex; flex-direction: column; gap: 12px; }
.row1 { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.row2 { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.brand h1 { font-family: var(--cond); font-weight: 700; font-size: 2.9rem; line-height: 1; letter-spacing: .04em; text-transform: uppercase; }
.offline { font-size: .95rem; font-weight: 600; color: var(--u2); border: 1px solid var(--u2); border-radius: 999px; padding: 3px 12px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { white-space: nowrap; background: transparent; border: 1px solid var(--line); border-radius: 999px; min-height: 44px; padding: 0 18px; font-weight: 600; color: var(--muted); }
.tab.on { background: var(--text); color: #0D1117; border-color: var(--text); }
.right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.clock { display: flex; align-items: baseline; gap: 12px; }
.clock .cd { font-size: 1.2rem; font-weight: 600; color: var(--muted); text-transform: capitalize; }
.clock .ct { font-family: var(--cond); font-weight: 700; font-size: 3.4rem; line-height: 1; }
.tv-exit { display: none; }
body.tv .tv-exit { display: inline-block; position: fixed; top: 8px; right: 8px; width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--panel); opacity: 0; }
body.tv .tv-exit:hover, body.tv .tv-exit:focus-visible { opacity: 1; }
body.tv .notv, body.ro .notv { display: none !important; }
body.tv .jline, body.tv .urgent-card { pointer-events: none; }

/* botones y campos */
.btn { min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); font-weight: 600; }
.btn:hover { background: #28313e; }
.btn.primary { background: #F2F4F7; color: #0D1117; border-color: #F2F4F7; font-weight: 700; }
.btn.primary:hover { background: #fff; }
.btn.danger { border-color: var(--u1); color: var(--u1); background: transparent; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
input[type=text], input[type=search], input[type=date], input[type=password], input[type=email], textarea, select {
  width: 100%; min-height: 46px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 10px 12px; font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
label.lbl { display: block; font-weight: 700; font-size: .95rem; color: #C9D1DA; margin-bottom: 6px; }

/* barra de herramientas */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.client-pager { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.client-pager select { width: auto; min-width: 82px; }
.pager-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.toolbar input[type=search] { width: 280px; max-width: 100%; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { white-space: nowrap; flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: .95rem; font-weight: 600; }
.chip.on { background: #F2F4F7; color: #0D1117; border-color: #F2F4F7; }
.chip .n { color: var(--muted); font-weight: 700; }
.chip.on .n { color: #3C4651; }

/* iconos */
.ticon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ticon img { width: 100%; height: 100%; object-fit: contain; }
.badge-bg { fill: var(--badge-bg); }
.logo { position: relative; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: #F3F4F6; border-radius: 8px; overflow: hidden; }
.logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.logo.ph { background: transparent; }
.logo.ph svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.logo.ph span { position: relative; font-weight: 700; color: #C9D1DA; padding-bottom: 3px; }
.logo.ph svg path { fill: #F3F4F6; stroke: #9AA3AD; }
.logo.ph span { color: #5B6570; }

/* pizarra */
#content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.board { flex: 1; min-height: 0; display: flex; gap: 22px; }
.urgent { width: 30%; min-width: 320px; max-width: 520px; flex-shrink: 0; overflow: auto; background: #2A1315; border: 2px solid var(--u1); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.u-head { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--cond); font-weight: 700; font-size: 2.1rem; letter-spacing: .06em; text-transform: uppercase; color: #FF9A9A; }
.urgent-card { display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; background: #3A1B1E; border: 0; border-radius: 12px; padding: 12px; }
.urgent-card:hover { background: #46212a; }
.urgent-card .who { font-size: 1rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #FFB4B4; }
.urgent-card .what { font-size: 1.75rem; font-weight: 700; line-height: 1.12; color: #fff; }
.urgent-card .meta { display: flex; gap: 10px; align-items: center; margin-top: 4px; color: #FFB4B4; }
.grid { flex: 1; min-width: 0; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-content: start; scrollbar-width: thin; }
.tile { background: var(--panel); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.t-head { display: flex; align-items: center; gap: 12px; }
.t-name { flex: 1; min-width: 0; font-family: var(--cond); font-weight: 700; font-size: 1.7rem; letter-spacing: .02em; line-height: 1.05; overflow-wrap: anywhere; }
.t-count { font-family: var(--cond); font-weight: 700; font-size: 2.2rem; line-height: 1; }
.add { width: 44px; height: 44px; border-radius: 12px; border: 1px dashed var(--line); background: transparent; font-size: 1.6rem; line-height: 1; color: var(--muted); }
.add:hover { color: var(--text); border-color: var(--text); }
.t-jobs { display: flex; flex-direction: column; gap: 2px; }
.jline { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 6px 6px; min-height: 40px; font-size: 1.2rem; font-weight: 600; line-height: 1.2; }
.jline:hover { background: var(--panel2); }
.jline .mk { width: 1.6em; flex-shrink: 0; font-weight: 700; }
.jline .jt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.jline .jt .dl { display: block; margin-top: 2px; }
.jline.u1, .u1c { color: var(--u1); } .jline.u2 { color: var(--u2); } .jline.u3 { color: var(--u3); } .jline.u4 { color: var(--u4); }
.dl { font-size: .85rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.dl.late { color: #fff; background: #B3261E; border-radius: 6px; padding: 2px 8px; }
.empty { color: var(--muted); font-size: 1.1rem; padding: 12px 4px; }
.empty.big { grid-column: 1 / -1; font-size: 1.6rem; text-align: center; padding: 60px 0; }
.legend { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; font-size: 1.05rem; font-weight: 600; color: #B8C0CA; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 7px; margin-right: 8px; vertical-align: -1px; }

/* tablas y listas */
.scroll { flex: 1; min-height: 0; overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { position: sticky; top: 0; background: var(--bg); text-align: left; font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #1c2330; vertical-align: middle; }
.tbl tr:hover td { background: #121820; }
.tbl .act { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.muted { color: var(--muted); }
.type-list { display: flex; flex-direction: column; gap: 10px; max-width: 820px; }
.type-row { display: flex; align-items: center; gap: 14px; background: var(--panel); border-radius: 12px; padding: 10px 14px; }
.type-row .nm { flex: 1; font-size: 1.2rem; font-weight: 600; }
.type-row .sub { color: var(--muted); font-size: .9rem; font-weight: 500; }

/* diálogos */
dialog.dlg { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 0; width: min(680px, 94vw); max-height: 92vh; overflow: hidden; }
dialog.dlg::backdrop { background: rgba(0, 0, 0, .7); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px 8px; }
.dlg-head h2 { font-family: var(--cond); font-size: 2rem; letter-spacing: .03em; }
.dlg-head .x { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: transparent; }
.dlg-body { padding: 8px 22px 22px; overflow: auto; max-height: calc(92vh - 76px); display: flex; flex-direction: column; gap: 16px; }
.dlg-body > * { flex-shrink: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tipo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.urg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.opt { position: relative; display: block; }
.opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.opt .card { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-weight: 600; font-size: .95rem; line-height: 1.15; }
.opt input:checked + .card { border: 3px solid #fff; padding: 6px 10px; background: var(--panel2); }
.opt input:focus-visible + .card { outline: 3px solid #fff; outline-offset: 2px; }
.urg-grid .card { flex-direction: column; justify-content: center; text-align: center; gap: 4px; min-height: 64px; }
.urg-grid .dot { width: 14px; height: 14px; border-radius: 7px; }
.urg-grid .hint { font-size: .75rem; color: var(--muted); font-weight: 500; }
.icon-grid .card { justify-content: center; padding: 8px; min-height: 56px; }
.dlg-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.dlg-actions .sp { flex: 1; }
.err { color: #FF9A9A; font-weight: 600; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.logo-edit { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hint-text { color: var(--muted); font-size: .9rem; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 50; background: #222c38; border: 1px solid var(--line); border-radius: 12px; padding: 12px 18px; font-weight: 600; max-width: 90vw; }
.toast.err { border-color: var(--u1); color: #FFB4B4; }

/* acceso */
.login { margin: auto; width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-family: var(--cond); font-size: 2.4rem; letter-spacing: .04em; text-transform: uppercase; }

@media (max-width: 900px) {
  #app { padding: 12px; }
  .tabs, .chips { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .pager-actions { width: 100%; margin-left: 0; justify-content: space-between; }
  .row2 { flex-direction: column; align-items: stretch; }
  .right .btn { flex: 1; }
  .brand h1 { font-size: 1.9rem; }
  .clock .ct { font-size: 2.2rem; }
  .board { flex-direction: column; overflow: auto; }
  .urgent { width: auto; max-width: none; min-width: 0; overflow: visible; }
  .grid { overflow: visible; grid-template-columns: 1fr; }
  .toolbar input[type=search] { width: 100%; }
  .row2 { grid-template-columns: 1fr; }
  .urg-grid { grid-template-columns: repeat(2, 1fr); }
  .clock .cd { display: none; }
}
