/* SRT Cloud Manager — Dark mode, estética minimalista estilo Apple */
:root {
  --bg: #000;
  --bg-elev: #0d0d0f;
  --card: #151517;
  --card-2: #1c1c1f;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --blue: #0a84ff;
  --blue-soft: rgba(10, 132, 255, 0.16);
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.15);
  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.16);
  --orange: #ff9f0a;
  --orange-soft: rgba(255, 159, 10, 0.16);
  --purple: #bf5af2;
  --gray-soft: rgba(142, 142, 147, 0.16);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { font-size: 14px; line-height: 1.45; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--text-2); margin: 2px 0 0; }
.mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 26px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
a { color: var(--blue); text-decoration: none; }

/* ------------------------------------------------------------ brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: url(/favicon.svg) center/cover; flex: none; }
.brand-mark.big { width: 56px; height: 56px; border-radius: 15px; margin: 0 auto 16px; }

/* ------------------------------------------------------------ buttons */
.btn {
  border: 0; border-radius: 999px; padding: 8px 16px; background: var(--card-2); color: var(--text);
  cursor: pointer; font-weight: 500; transition: background .15s, transform .08s, opacity .15s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn:hover { background: #2a2a2e; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: #2690ff; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.danger:hover { background: rgba(255, 69, 58, .26); }
.btn.success { background: var(--green-soft); color: var(--green); }
.btn.success:hover { background: rgba(48, 209, 88, .25); }
.btn.warn { background: var(--orange-soft); color: var(--orange); }
.btn.ghost { background: transparent; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.xs { padding: 3px 10px; font-size: 12px; }
.btn.block { width: 100%; padding: 11px; }
.icon-btn { border: 0; background: transparent; color: var(--text-2); cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, .06); }

/* ------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field small { color: var(--text-3); font-size: 12px; }
input, select, textarea {
  background: #0b0b0c; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px;
  outline: none; transition: border-color .15s, box-shadow .15s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.error-text { color: var(--red); min-height: 18px; font-size: 13px; margin: 0 0 10px; }
.search { width: 240px; border-radius: 999px; padding: 8px 14px; }

/* switch */
.switch-label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text-2); user-select: none; }
.switch-label input { display: none; }
.switch { width: 38px; height: 22px; border-radius: 999px; background: #39393d; position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.switch-label input:checked + .switch { background: var(--green); }
.switch-label input:checked + .switch::after { transform: translateX(16px); }

/* ------------------------------------------------------------ login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(10,132,255,.18), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 360px; background: rgba(28, 28, 31, .7); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--line); border-radius: 22px; padding: 32px 28px; text-align: center; box-shadow: var(--shadow); }
.login-card h1 { font-size: 22px; }
.login-card .muted { margin-bottom: 22px; }
.login-card .field { text-align: left; }

/* ------------------------------------------------------------ topbar */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(0, 0, 0, .72); backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1440px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
.metrics { flex: 1; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.metric { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; min-height: 38px; }
.metric .label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.metric .value { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; white-space: nowrap; }
.metric .sub { white-space: nowrap; }
.metric .sub { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.bar { width: 46px; height: 5px; border-radius: 99px; background: #2c2c2e; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--green); transition: width .6s ease, background .3s; }
.bar.wide { width: 90px; }
.metric.capacity.alert { border-color: rgba(255,159,10,.45); background: linear-gradient(0deg, var(--orange-soft), var(--orange-soft)), var(--card); }
.metric.capacity.full { border-color: rgba(255,69,58,.5); background: linear-gradient(0deg, var(--red-soft), var(--red-soft)), var(--card); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.health { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); box-shadow: 0 0 0 3px rgba(255,255,255,.05); }
.health.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.health.bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.capacity-alert { text-align: center; font-size: 13px; padding: 7px 16px; background: var(--orange-soft); color: var(--orange); border-top: 1px solid rgba(255,159,10,.25); font-weight: 500; }
.capacity-alert.full { background: var(--red-soft); color: var(--red); }

/* ------------------------------------------------------------ tabs */
.tabs-wrap { max-width: 1440px; margin: 0 auto; padding: 20px 20px 0; display: flex; justify-content: center; }
.segmented { display: inline-flex; background: var(--card); border: 1px solid var(--line); padding: 3px; border-radius: 12px; gap: 2px; overflow-x: auto; max-width: 100%; }
.segmented button { border: 0; background: transparent; color: var(--text-2); padding: 7px 16px; border-radius: 9px; cursor: pointer; font-weight: 500; white-space: nowrap; transition: color .15s, background .15s; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: #3a3a3d; color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.35); }

/* ------------------------------------------------------------ layout */
.content { max-width: 1440px; margin: 0 auto; padding: 22px 20px 60px; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.empty { text-align: center; color: var(--text-3); padding: 50px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }

/* ------------------------------------------------------------ pills */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; letter-spacing: .01em; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.orange { background: var(--orange-soft); color: var(--orange); }
.pill.blue { background: var(--blue-soft); color: #64b5ff; }
.pill.gray { background: var(--gray-soft); color: var(--text-2); }
.pill.purple { background: rgba(191,90,242,.16); color: #d68cff; }
.pill.live { background: var(--red); color: #fff; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }
.pill.live .dot { animation: pulse 1.6s infinite; background: #fff; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ------------------------------------------------------------ multiviewer */
.mv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.mv-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform .15s, border-color .15s; }
.mv-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.mv-card.offline { cursor: default; }
.mv-card.offline:hover { transform: none; }
.mv-screen { position: relative; aspect-ratio: 16 / 9; background: #070708; overflow: hidden; }
.mv-screen img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mv-card.offline .mv-screen { background: repeating-linear-gradient(135deg, #0c0c0d 0 12px, #101012 12px 24px); }
.mv-nosignal { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); font-size: 12.5px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.mv-badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 6px; justify-content: space-between; }
.mv-badges .left { display: flex; gap: 6px; }
.mv-badges .pill { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.mv-badges .pill.gray, .mv-badges .pill.blue, .mv-badges .pill.purple, .mv-badges .pill.orange { background: rgba(0,0,0,.62); }
.mv-stats { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 7px; display: flex; gap: 12px; font-size: 12px; font-variant-numeric: tabular-nums;
  background: linear-gradient(transparent, rgba(0,0,0,.78)); color: #e5e5ea; font-weight: 500; }
.mv-stats .warn { color: var(--orange); }
.mv-play { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .2s; background: rgba(0,0,0,.25); }
.mv-play span { width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.18); backdrop-filter: blur(12px); display: grid; place-items: center; font-size: 18px; }
.mv-card:not(.offline):hover .mv-play { opacity: 1; }
.mv-foot { padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mv-foot .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-foot .meta { color: var(--text-3); font-size: 12px; font-family: var(--mono); }

/* ------------------------------------------------------------ client list */
.list { display: flex; flex-direction: column; gap: 10px; }
.client { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid;
  grid-template-columns: minmax(200px, 1.4fr) minmax(170px, 1fr) minmax(120px, .7fr) auto; gap: 14px; align-items: center; }
.client .title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.client .sub { color: var(--text-2); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client .col-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.client .col-val { font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.live-mini { display: inline-flex; gap: 10px; color: var(--text-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* cuentas de cliente */
.account { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.acc-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 16px; flex-wrap: wrap; }
.acc-head .title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; flex-wrap: wrap; }
.acc-head .sub { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.acc-keys { border-top: 1px solid var(--line); background: #111113; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.acc-keys .client { background: #18181b; border-radius: 12px; padding: 12px 14px; }
.acc-keys .client .title { font-size: 14px; }
.cred-box { border: 1px solid rgba(10,132,255,.35); background: var(--blue-soft); border-radius: 12px; padding: 12px; }

/* cams */
.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.cam { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.cam-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cam-key { font-family: var(--mono); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.copy-line { display: flex; align-items: center; gap: 8px; background: #0b0b0c; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 8px 8px 12px; }
.copy-line code { flex: 1; font-family: var(--mono); font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade .15s ease; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow: auto; background: #1a1a1c; border: 1px solid var(--line-strong);
  border-radius: 20px; box-shadow: var(--shadow); animation: pop .18s ease; }
.modal.wide { max-width: 860px; }
.modal.player { max-width: 1100px; background: #0a0a0b; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 12px 20px 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } }

/* ficha */
.ficha { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 20px; }
.ficha > div, .kv > *, .copy-line { min-width: 0; }
.ficha-section { margin-bottom: 16px; }
.ficha-section h4 { margin: 0 0 8px; font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; display: flex; gap: 8px; align-items: center; }
.kv { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 6px 10px; align-items: center; margin-bottom: 6px; font-size: 13px; }
.kv .k { color: var(--text-3); font-size: 12px; }
.qr-box { background: #fff; border-radius: 14px; padding: 10px; aspect-ratio: 1; display: grid; place-items: center; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-side { display: flex; flex-direction: column; gap: 10px; }
.qr-side small { color: var(--text-3); font-size: 11.5px; text-align: center; }

/* destinos */
.dest { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: #141416; }
.dest .d-title { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.dest .d-url { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 460px; }
.dest .d-err { font-size: 11.5px; color: var(--orange); margin-top: 3px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 460px; }
.dest-form { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.platform-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; }
.p-youtube { background: #ff0033; } .p-facebook { background: #1877f2; } .p-twitch { background: #9146ff; } .p-kick { background: #53fc18; color: #000; } .p-custom { background: #3a3a3c; }

/* player */
.player-wrap { position: relative; background: #000; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; }
.player-wrap video { width: 100%; height: 100%; display: block; background: #000; }
.player-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-2); font-size: 13px; pointer-events: none; text-align: center; padding: 20px; }
.player-stats { display: flex; gap: 18px; flex-wrap: wrap; padding: 12px 2px 0; color: var(--text-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.player-stats b { color: var(--text); font-weight: 600; }

/* ------------------------------------------------------------ history */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; color: var(--text-3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.events { display: flex; flex-direction: column; gap: 2px; max-height: 640px; overflow: auto; }
.event { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.event time { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.event .t-online { color: var(--green); } .event .t-offline { color: var(--text-2); } .event .t-kick, .event .t-auth_denied { color: var(--red); }
.event .t-restream { color: var(--orange); }

/* ------------------------------------------------------------ settings */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.info-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.info-list dt { color: var(--text-3); } .info-list dd { margin: 0; font-family: var(--mono); font-size: 12.5px; }
.plan { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.plan:last-of-type { border-bottom: 0; }

/* ------------------------------------------------------------ toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; pointer-events: none; }
.toast { background: rgba(44, 44, 46, .92); backdrop-filter: blur(20px); border: 1px solid var(--line-strong); padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow); font-weight: 500; animation: pop .2s ease; max-width: 90vw; }
.toast.error { color: #ff8a80; } .toast.ok::before { content: "✓  "; color: var(--green); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .client { grid-template-columns: 1fr 1fr; }
  .client .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .metrics { order: 3; flex-basis: 100%; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .metric { flex: none; }
  .brand span { display: none; }
  .top-actions { margin-left: auto; }
  .content, .tabs-wrap { padding-left: 14px; padding-right: 14px; }
  .client { grid-template-columns: 1fr; }
  .ficha { grid-template-columns: 1fr; }
  .row, .row3 { grid-template-columns: 1fr; }
  .search { width: 100%; }
  .head-actions { width: 100%; }
  .dest { grid-template-columns: auto 1fr; }
  .dest > :last-child { grid-column: 1 / -1; }
}
