@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&display=swap");

:root {
  --bg: #060606;
  --bg-2: #0c0c0c;
  --card: #101010;
  --line: #252525;
  --line-2: #3a3a3a;
  --text: #f2f2f2;
  --muted: #a1a1a1;
  --danger: #ff7474;
  --warn: #ffd67f;
  --ok: #9ff6bc;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.46);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Manrope", "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 95% -10%, rgba(255, 255, 255, 0.09), transparent 55%),
    radial-gradient(900px 420px at 0% -10%, rgba(255, 255, 255, 0.05), transparent 45%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}

.hidden {
  display: none !important;
}

.kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #151515, #090909 70%);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.auth-logo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 2px;
}

.auth-logo {
  width: 78px;
  height: 78px;
  object-fit: contain;
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(1.9rem, 2.6vw, 2.3rem);
}

.auth-card p {
  margin: 0;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #111, #0a0a0a);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand h2 {
  margin: 6px 0 0;
  font-size: 1.5rem;
  text-transform: uppercase;
}

.menu {
  display: grid;
  gap: 8px;
}

.menu-bottom {
  margin-top: auto;
}

.menu-btn {
  width: 100%;
  border: 1px solid var(--line);
  background: #141414;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 38px 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  position: relative;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  font-size: 0.78rem;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.menu-btn:hover {
  border-color: var(--line-2);
  background: #1a1a1a;
}

.menu-btn.active {
  border-color: #fff;
  background: #1e1e1e;
}

.menu-count {
  border-radius: 999px;
  min-width: 24px;
  text-align: center;
  padding: 2px 8px;
  font-size: 0.72rem;
  color: #111;
  background: #f0f0f0;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

#sidebarAccountBtn {
  color: var(--text);
  font-weight: 700;
  background: #141414;
  border-color: var(--line);
  min-height: 40px;
  padding: 6px 10px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  flex: 1;
  justify-content: flex-start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebarAccountBtn:hover {
  border-color: var(--line-2);
  background: #1a1a1a;
}

.main {
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.topbar {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, #111, #0d0d0d);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.3vw, 1.95rem);
  text-transform: uppercase;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.top-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #151515;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel {
  display: none;
  gap: 10px;
}

.panel.active {
  display: grid;
}

.card {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px;
  background: linear-gradient(180deg, #121212, #0e0e0e);
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.95rem;
  line-height: 1.2;
}

.row-form,
.stack-form {
  display: grid;
  gap: 8px;
}

.row-form {
  grid-template-columns: 160px 1fr auto;
}

.row-form-admin {
  grid-template-columns: 1fr 1fr 160px auto;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.settings-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #0f0f0f;
  display: grid;
  gap: 8px;
}

.settings-group h4 {
  margin: 0 0 2px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.downloads-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.downloads-spacer {
  flex: 1;
}

.downloads-search {
  display: flex;
  align-items: center;
  gap: 6px;
}

.downloads-search input {
  width: 200px;
  min-width: 140px;
}

.downloads-pager {
  display: flex;
  justify-content: flex-end;
  margin-left: auto;
}

.pager {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
}

.pager-label {
  min-width: 58px;
  text-align: center;
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
}

.pager-btn {
  min-height: 28px;
  min-width: 28px;
  padding: 4px 8px;
  border-radius: 8px;
}

.pager.small .pager-btn {
  min-height: 26px;
  min-width: 26px;
  padding: 3px 7px;
  font-size: 0.74rem;
}

.pager.small .pager-label {
  font-size: 0.7rem;
}

.downloads-recent-wrap #downloadsRecent {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.downloads-recent-wrap #downloadsRecent .item {
  padding: 8px;
}

.downloads-toolbar #downloadsRefreshBtn {
  margin-left: auto;
}

[data-panel="queue"] {
  align-content: start;
  grid-auto-rows: max-content;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #131313;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #fff;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.check-row input {
  width: auto;
}

.btn {
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #191919;
  color: var(--text);
  min-height: 38px;
  padding: 9px 12px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.74rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-align: center;
  transition: transform 0.12s ease, border-color 0.2s ease, background 0.2s ease;
}

#logoutBtn {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
}

#downloadsSearchBtn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 10px;
}

#downloadsSearchBtn > span:last-child {
  display: none;
}

#downloadsSearchBtn .btn-ico {
  display: inline-flex;
}

#downloadsClearSearchBtn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 999px;
}

#downloadsClearSearchBtn > span:last-child {
  display: none;
}

#downloadsClearSearchBtn .btn-ico {
  display: inline-flex;
}

#importSearchBtn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 10px;
}

#importSearchBtn > span:last-child {
  display: none;
}

#importSearchBtn .btn-ico {
  display: inline-flex;
}

#importClearSearchBtn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 999px;
}

#importClearSearchBtn > span:last-child {
  display: none;
}

#importClearSearchBtn .btn-ico {
  display: inline-flex;
}

#logoutBtn > span:last-child {
  display: none;
}

#logoutBtn .btn-ico {
  display: inline-flex;
}

.btn:hover {
  border-color: #fff;
  background: #222;
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: #f4f4f4;
  border-color: #f4f4f4;
  color: #111;
}

.btn.primary:hover {
  background: #fff;
}

.btn.success {
  border-color: #74d39a;
  color: #9ff6bc;
  background: rgba(116, 211, 154, 0.17);
}

.btn.is-busy {
  opacity: 0.82;
}

.btn[disabled] {
  opacity: 0.56;
  cursor: not-allowed;
}

.btn-ico {
  width: 14px;
  height: 14px;
  display: inline-flex;
}

.inline-ico {
  display: inline-flex;
  width: 16px;
  height: 16px;
  vertical-align: -2px;
  margin-right: 6px;
}

.btn-ico svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.inline-ico svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #111;
  padding: 10px 12px;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.item:hover {
  border-color: #3f3f3f;
  background: #151515;
}

.row-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.item-main {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.item h4 {
  margin: 0;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.68rem;
  color: var(--muted);
  background: #151515;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge.running {
  border-color: #8fd6ff;
  color: #8fd6ff;
}

.badge.paused {
  border-color: var(--warn);
  color: var(--warn);
}

.badge.error {
  border-color: var(--danger);
  color: var(--danger);
}

.badge.completed {
  border-color: var(--ok);
  color: var(--ok);
}

.badge.ratelimit {
  border-color: #ffcc7a;
  color: #ffcc7a;
  background: rgba(255, 204, 122, 0.12);
}

.badge.pending,
.badge.stopping {
  border-color: #d9d9d9;
  color: #d9d9d9;
}

.badge.sync-age {
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge.sync-age.fresh-good {
  border-color: #76d79a;
  color: #76d79a;
  background: rgba(118, 215, 154, 0.12);
}

.badge.sync-age.fresh-warn {
  border-color: #f5d37a;
  color: #f5d37a;
  background: rgba(245, 211, 122, 0.12);
}

.badge.sync-age.fresh-old {
  border-color: #ff8e8e;
  color: #ff8e8e;
  background: rgba(255, 142, 142, 0.12);
}

.meta,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  word-break: break-word;
}

.meta a {
  color: #e6e6e6;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.meta a:hover {
  color: #ffffff;
}

.item-actions {
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.queue-details {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #0f0f0f;
  display: grid;
  gap: 8px;
}

.queue-subgroup ul {
  margin: 4px 0 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 0.8rem;
  max-height: 140px;
  overflow: auto;
}

.progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #1a1a1a;
  overflow: hidden;
}

.progress > div {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #cfcfcf, #fff);
  transition: width 1.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress.indeterminate > div {
  width: 35%;
  animation: indeterminate 1.25s infinite ease-in-out;
}

@keyframes indeterminate {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

.danger {
  color: var(--danger);
}

.console {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #080808;
  color: #ddd;
  padding: 10px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty {
  border: 1px dashed var(--line-2);
  border-radius: 12px;
  padding: 12px;
  color: var(--muted);
  background: #0f0f0f;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.74rem;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #111;
  color: var(--text);
  padding: 10px 13px;
  box-shadow: var(--shadow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-card {
  width: min(1100px, 100%);
  max-height: 86vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0c0c0c;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

@media (max-width: 1200px) {
  .row-form-admin {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .row-form,
  .row-form-admin {
    grid-template-columns: 1fr;
  }

  .downloads-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .downloads-toolbar #downloadsRefreshBtn {
    margin-left: 0;
  }

  .downloads-spacer {
    display: none;
  }

  .downloads-search input {
    width: 100%;
  }

  .downloads-pager {
    margin-left: 0;
    width: 100%;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .row-item {
    grid-template-columns: 1fr;
  }

  .item-actions {
    justify-content: flex-start;
  }
}
