:root {
  --bg: #080b12;
  --bg-soft: #0c111b;
  --panel: #101724;
  --panel-2: #0d1420;
  --panel-3: #16202f;
  --border: rgba(148, 163, 184, .14);
  --border-strong: rgba(148, 163, 184, .28);
  --text: #e7eefb;
  --muted: #8b99b0;
  --brand: #e11d48;
  --brand-2: #fb7185;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --info: #38bdf8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px rgba(0, 0, 0, .35);
  --sidebar-w: 244px;
  color-scheme: dark;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(225, 29, 72, .16), transparent 60%),
    radial-gradient(700px 380px at 92% 0%, rgba(56, 189, 248, .08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.02rem; }
h3 { font-size: .95rem; }

p { margin: 0 0 .6rem; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

code {
  background: rgba(148, 163, 184, .12);
  padding: .1rem .35rem;
  border-radius: 6px;
  font-size: .85em;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.right { text-align: right; }
.mt { margin-top: .9rem; }
.gap { gap: .5rem; }

/* -------- shell -------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  background: linear-gradient(180deg, rgba(16, 23, 36, .96), rgba(9, 13, 21, .98));
  border-right: 1px solid var(--border);
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 2px 6px 22px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--brand), #7f1030);
  color: #fff;
  font-weight: 800;
  font-size: .95rem;
  letter-spacing: -.03em;
  box-shadow: 0 10px 24px rgba(225, 29, 72, .35);
}
.brand-mark.big { width: 54px; height: 54px; font-size: 1.15rem; border-radius: 16px; }
.brand-text { display: flex; flex-direction: column; font-weight: 700; line-height: 1.1; }
.brand-text small { color: var(--muted); font-weight: 500; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #b9c5d8;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(148, 163, 184, .08); color: #fff; text-decoration: none; }
.nav-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(225, 29, 72, .24), rgba(225, 29, 72, .06));
  box-shadow: inset 2px 0 0 var(--brand);
}
.nav-link svg { width: 18px; height: 18px; fill: currentColor; opacity: .85; }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 8px 2px;
  color: var(--muted);
  font-size: .76rem;
  border-top: 1px solid var(--border);
}
.dot-sep { margin: 0 5px; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky; top: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 26px;
  background: rgba(8, 11, 18, .78);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.topbar-title { display: flex; flex-direction: column; }
.topbar-sub { color: var(--muted); font-size: .76rem; letter-spacing: .02em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { background: rgba(148, 163, 184, .12); }

.content { padding: 24px 26px 44px; max-width: 1400px; width: 100%; }

.menu-btn { display: none; }

/* -------- cards & grid -------- */
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  background: linear-gradient(180deg, rgba(22, 32, 47, .55), rgba(13, 20, 32, .85));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px;
}
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; }

.kpi { display: flex; flex-direction: column; gap: 4px; padding: 18px 18px 16px; }
.kpi-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .09em; }
.kpi-value { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.kpi-sub { color: var(--muted); font-size: .8rem; }

/* -------- forms -------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; color: #b7c3d6; font-weight: 500; }

input[type="text"], input[type="url"], input[type="password"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%;
  background: #0a111c;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 11px;
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(251, 113, 133, .7);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, .16);
}
input::placeholder { color: #5b687c; }
input[readonly] { color: #c9d4e6; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
select.compact { width: auto; min-width: 150px; padding: 7px 30px 7px 10px; font-size: .82rem; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field-grid .span2 { grid-column: span 2; }
.align-end { display: flex; align-items: flex-end; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: .5rem; }

.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar input { flex: 1; }
.searchbar select { width: 220px; }

.switch { flex-direction: row; align-items: center; gap: 9px; cursor: pointer; }
.switch input { width: auto; accent-color: var(--brand); }
.switch.inline { font-size: .82rem; }

/* -------- buttons -------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(148, 163, 184, .08);
  color: var(--text);
  font-size: .85rem;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: rgba(148, 163, 184, .16); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(140deg, var(--brand), #b3123a);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px rgba(225, 29, 72, .28);
}
.btn.primary:hover { background: linear-gradient(140deg, #ef2a53, #c4153f); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.danger { border-color: rgba(239, 68, 68, .5); color: #fda4af; background: rgba(239, 68, 68, .1); }
.btn.danger:hover { background: rgba(239, 68, 68, .18); }
.btn.small { padding: 6px 10px; font-size: .78rem; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* -------- tables -------- */
.table-wrap { overflow-x: auto; }
.table-wrap.scroll { max-height: 340px; overflow-y: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table th, .table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; }
.table tbody tr:hover td { background: rgba(148, 163, 184, .05); }
.table td.right, .table th.right { text-align: right; }
.table .name { font-weight: 550; color: #eaf1fc; }

/* -------- chips, badges -------- */
.chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .12);
  color: #c6d2e4;
  font-size: .74rem;
  font-weight: 550;
}
.badge { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge.ok { background: rgba(34, 197, 94, .14); color: #86efac; }
.badge.warn { background: rgba(245, 158, 11, .14); color: #fcd34d; }
.badge.err { background: rgba(239, 68, 68, .16); color: #fca5a5; }
.badge.info { background: rgba(56, 189, 248, .14); color: #7dd3fc; }
.badge.muted { background: rgba(148, 163, 184, .12); color: #a8b6c9; }

/* -------- meters -------- */
.meter {
  height: 9px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .13);
  overflow: hidden;
  margin-bottom: 6px;
}
.meter.large { height: 12px; }
.meter-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  transition: width .5s ease, background .3s;
}
.meter-fill.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.meter-fill.err { background: linear-gradient(90deg, #ef4444, #f87171); }

.progress { height: 6px; border-radius: 999px; background: rgba(148, 163, 184, .13); overflow: hidden; margin: 6px 0 10px; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--info), #60a5fa); transition: width .4s; }

/* -------- lists -------- */
.copybox { display: flex; gap: 8px; margin: 8px 0 14px; }
.copybox input { font-family: ui-monospace, monospace; font-size: .8rem; color: var(--text); background: #0a111c; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; }
.facts dd { margin: 2px 0 0; font-weight: 600; font-size: .88rem; }

.rank { margin: 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: 7px; }
.rank li { color: #d4deee; }
.rank li::marker { color: var(--brand-2); font-weight: 700; }

.loglist { list-style: none; margin: 0; padding: 0; font-size: .84rem; display: flex; flex-direction: column; gap: 2px; max-height: 520px; overflow-y: auto; }
.loglist li {
  display: flex; gap: 10px; align-items: baseline;
  padding: 6px 8px;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .79rem;
  border-bottom: 1px solid rgba(148, 163, 184, .07);
}
.loglist li:hover { background: rgba(148, 163, 184, .05); }
.loglist .time { color: #64748b; flex: 0 0 auto; }
.loglist .lvl { flex: 0 0 auto; font-weight: 700; text-transform: uppercase; font-size: .68rem; letter-spacing: .05em; }
.loglist .lvl.info { color: var(--info); }
.loglist .lvl.warn { color: var(--warn); }
.loglist .lvl.error { color: var(--err); }
.loglist .lvl.debug { color: #94a3b8; }
.loglist .msg { color: #dbe5f3; word-break: break-word; }
.loglist .attrs { color: #7c8aa0; font-size: .74rem; }
.loglist.compact li { padding: 5px 6px; }

/* -------- remotes -------- */
.remote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.remote {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: rgba(10, 17, 28, .55);
  display: flex; flex-direction: column; gap: 9px;
}
.remote h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.remote .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.remote .meta { color: var(--muted); font-size: .78rem; }

/* -------- poster grid -------- */
.poster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; margin-top: 12px; }
.poster { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #0a111c; }
.poster img { width: 100%; height: 158px; object-fit: cover; display: block; background: #111a29; }
.poster .p-body { padding: 7px 8px; }
.poster .p-title { font-size: .75rem; font-weight: 600; line-height: 1.25; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.poster .p-meta { color: var(--muted); font-size: .68rem; margin-bottom: 6px; }
.poster .btn { width: 100%; padding: 4px 6px; font-size: .7rem; }

/* -------- misc -------- */
.resultbox {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0a111c;
  padding: 12px;
  font-family: ui-monospace, monospace;
  font-size: .78rem;
  white-space: pre-wrap;
  color: #c9d6e8;
  max-height: 260px;
  overflow: auto;
}
.steps { margin: 0; padding-left: 1.2rem; color: #c2cfdf; font-size: .85rem; display: flex; flex-direction: column; gap: 7px; }

.savebar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 14px;
  margin-top: 8px;
  padding: 12px 16px;
  background: rgba(8, 11, 18, .9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.alert { padding: 10px 12px; border-radius: 10px; font-size: .86rem; margin-bottom: 12px; }
.alert.error { background: rgba(239, 68, 68, .14); border: 1px solid rgba(239, 68, 68, .35); color: #fecdd3; }
.alert.ok { background: rgba(34, 197, 94, .12); border: 1px solid rgba(34, 197, 94, .3); color: #bbf7d0; }

.toast {
  position: fixed;
  right: 22px; bottom: 22px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #16202f;
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  font-size: .86rem;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { border-color: rgba(239, 68, 68, .6); }

/* -------- login -------- */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(800px 500px at 20% 0%, rgba(225, 29, 72, .2), transparent 60%),
    radial-gradient(700px 480px at 90% 100%, rgba(56, 189, 248, .1), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, rgba(22, 32, 47, .8), rgba(13, 20, 32, .95));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 26px 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.login-brand h1 { font-size: 1.2rem; }
.login-brand p { margin: 2px 0 0; color: var(--muted); font-size: .8rem; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .btn { margin-top: 4px; padding: 11px; }
.login-foot { margin: 20px 0 0; text-align: center; color: #64748b; font-size: .74rem; }

/* -------- responsive -------- */
@media (max-width: 1100px) {
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .grid.two { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
  .topbar-sub { display: none; }
}
@media (max-width: 620px) {
  .grid.kpis { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .field-grid .span2 { grid-column: auto; }
  .searchbar { flex-wrap: wrap; }
  .searchbar select { width: 100%; }
  .facts { grid-template-columns: 1fr; }
  .kpi-value { font-size: 1.7rem; }
}
