:root {
  --primary: #2563eb;
  --primary-dark: #1e3a8a;
  --primary-light: #dbeafe;
  --primary-50: #eff6ff;
  --foreground: #111827;
  --heading: #0f172a;
  --muted: #6b7280;
  --muted-light: #9ca3af;
  --border: #e5e7eb;
  --surface: #ffffff;
  --success: #198754;
  --warning: #ff9500;
  --danger: #dc3545;
  --info: #2563eb;
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-island: 0 8px 30px rgba(0, 0, 0, 0.06);
  --glass: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.55);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 100vw;
  min-height: 100vh;
  overflow: hidden;
  color: var(--foreground);
  background:
    radial-gradient(60% 50% at 85% 5%, rgba(255, 200, 220, 0.55), transparent 60%),
    radial-gradient(55% 50% at 5% 25%, rgba(180, 215, 255, 0.55), transparent 65%),
    radial-gradient(55% 50% at 95% 95%, rgba(200, 230, 255, 0.50), transparent 60%),
    radial-gradient(70% 60% at 0% 100%, rgba(230, 215, 255, 0.50), transparent 65%),
    linear-gradient(180deg, #f6f7fb 0%, #eef0f7 100%);
}

button,
textarea,
select,
input {
  font: inherit;
}

button {
  border: 0;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
}

.title-gradient {
  margin: 0;
  line-height: 1;
  font-size: 28px;
  font-weight: 820;
  letter-spacing: 0;
  color: transparent;
  background: linear-gradient(to right, #0f172a 0%, #2563eb 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-shell {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 18px;
  width: 100vw;
  height: 100vh;
  padding: 18px 18px 18px 14px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 14px 10px;
  border-radius: 24px;
}

.brand {
  display: grid;
  place-items: center;
  gap: 4px;
  width: 54px;
  height: 64px;
  color: var(--primary-dark);
  font-weight: 800;
}

.brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.nav-item,
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #3c3c43;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.nav-item svg,
.icon-button svg,
.pill-button svg,
.metric svg,
.feature-tile svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
}

.icon-button.small {
  width: 34px;
  height: 34px;
  border-radius: 12px;
}

.icon-button.small svg {
  width: 17px;
  height: 17px;
}

.nav-item:hover,
.icon-button:hover,
.pill-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.82);
}

.nav-item.active,
.icon-button.primary,
.pill-button.primary {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.nav-item.bottom {
  margin-top: auto;
}

.workspace {
  display: grid;
  grid-template-rows: 86px minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
  padding: 16px 20px;
  border-radius: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.top-actions,
.tool-row,
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  color: var(--heading);
  font-size: 18px;
  line-height: 1.2;
}

.panel-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.view {
  display: none;
  min-height: 0;
  overflow: hidden;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 4px 12px;
  min-height: 94px;
  padding: 18px;
  border-radius: 24px;
}

.metric svg {
  grid-row: span 2;
  align-self: center;
  width: 42px;
  height: 42px;
  padding: 10px;
  border-radius: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  min-width: 0;
  overflow: hidden;
  color: var(--heading);
  font-size: 24px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.accent-input svg,
.feature-tile.accent-input svg {
  color: #1f7d38;
  background: #e8f8ec;
}

.accent-video svg,
.feature-tile.accent-video svg {
  color: #a11d38;
  background: #fce5eb;
}

.accent-output svg,
.feature-tile.accent-output svg {
  color: #3c3c43;
  background: #efeff4;
}

.accent-debug svg,
.feature-tile.accent-debug svg {
  color: #a86200;
  background: #fff1dd;
}

.dashboard-grid,
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  gap: 18px;
  min-height: 0;
}

.panel {
  min-height: 0;
  padding: 18px;
  border-radius: 24px;
  box-shadow: var(--shadow-island);
}

.tall-panel {
  height: calc(100vh - 122px);
  overflow: hidden;
}

.progress-shell {
  width: 100%;
  height: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #34c759);
  border-radius: inherit;
  transition: width 220ms ease;
}

.pill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 98px;
  height: 42px;
  padding: 0 16px;
  color: var(--foreground);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  cursor: pointer;
}

.pill-button.danger,
.icon-button.danger {
  color: #ffffff;
  background: #dc3545;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  height: 30px;
  padding: 0 12px;
  color: var(--primary-dark);
  background: var(--primary-50);
  border: 1px solid var(--primary-light);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-chip.success {
  color: #0f4f1f;
  background: #dcf4e2;
  border-color: #b7ebc4;
}

.status-chip.warning {
  color: #a86200;
  background: #fff1dd;
  border-color: #ffd7a4;
}

.status-chip.error {
  color: #a11d38;
  background: #fce5eb;
  border-color: #fac1cf;
}

.soft-input,
.soft-control,
.select-field select {
  width: 100%;
  color: var(--foreground);
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  outline: 0;
}

.soft-input {
  min-height: 140px;
  padding: 14px;
  resize: none;
}

.soft-control {
  height: 44px;
  padding: 0 12px;
}

.soft-input.large {
  min-height: 170px;
}

.soft-input:focus,
.soft-control:focus,
.select-field select:focus {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.list,
.table,
.log-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 390px);
  overflow: auto;
  padding-right: 4px;
}

.product-table-head,
.product-row {
  display: grid;
  grid-template-columns:
    minmax(130px, 0.95fr)
    minmax(190px, 1.35fr)
    minmax(86px, 0.55fr)
    minmax(96px, 0.55fr)
    minmax(150px, 1fr)
    minmax(118px, 0.7fr);
  gap: 10px;
}

.product-table-head {
  padding: 0 12px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.product-table {
  max-height: calc(100vh - 220px);
}

.product-table .table-row {
  align-items: center;
}

.product-source {
  white-space: nowrap;
}

.log-toolbar {
  display: grid;
  grid-template-columns: minmax(150px, 0.35fr) minmax(220px, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.library-toolbar {
  margin-bottom: 14px;
}

.library-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  min-height: 0;
}

.library-column {
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-head h3 {
  margin: 0;
  color: var(--heading);
  font-size: 14px;
  line-height: 1.2;
}

.library-list {
  max-height: calc(100vh - 300px);
}

.library-row {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  width: 100%;
  color: inherit;
  text-align: left;
}

.library-row > svg {
  width: 24px;
  height: 24px;
  padding: 5px;
  color: var(--primary-dark);
  background: var(--primary-50);
  border-radius: 10px;
}

.extension-list {
  max-height: calc(100vh - 220px);
}

.extension-card {
  grid-template-columns: minmax(0, 1fr) auto;
  width: 100%;
  color: inherit;
  text-align: left;
}

.extension-card.selected {
  border-color: rgba(37, 99, 235, 0.42);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.extension-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.extension-meta-row .status-chip {
  min-width: 0;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.extension-error {
  margin-top: 6px;
  color: var(--danger);
}

.extension-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.log-toolbar .wide-field {
  grid-column: auto;
}

.log-list {
  max-height: calc(100vh - 420px);
}

.log-entry {
  width: 100%;
  color: inherit;
  text-align: left;
}

.log-details {
  min-height: 120px;
  max-height: 170px;
  margin: 12px 4px 0 0;
  overflow: auto;
  padding: 12px;
  color: var(--heading);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.list-row,
.table-row,
.log-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 16px;
}

.product-table .product-row {
  grid-template-columns:
    minmax(130px, 0.95fr)
    minmax(190px, 1.35fr)
    minmax(86px, 0.55fr)
    minmax(96px, 0.55fr)
    minmax(150px, 1fr)
    minmax(118px, 0.7fr);
}

.schedule-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

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

.row-title {
  min-width: 0;
  overflow: hidden;
  color: var(--heading);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-subtitle {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.telegram-card {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.52);
}

.telegram-card > svg {
  width: 58px;
  height: 58px;
  padding: 14px;
  color: #3e3ca8;
  background: #ececfb;
  border-radius: 20px;
}

.telegram-card h3 {
  margin: 0 0 4px;
}

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

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.feature-tile {
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 20px;
}

.feature-tile svg {
  width: 44px;
  height: 44px;
  padding: 10px;
  border-radius: 16px;
}

.feature-tile span {
  color: var(--muted);
  font-size: 13px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.schedule-form {
  align-items: end;
}

.wide-field {
  grid-column: span 2;
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  color: var(--heading);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 16px;
  font-size: 13px;
  font-weight: 800;
}

.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.select-field {
  display: grid;
  gap: 8px;
}

.select-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.select-field select {
  height: 44px;
  padding: 0 12px;
}

.version-badge {
  position: fixed;
  right: 18px;
  bottom: 14px;
  z-index: 20;
  min-width: 74px;
  height: 34px;
  color: var(--primary-dark);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.16);
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(520px, calc(100vw - 36px));
  padding: 20px;
  border-radius: 24px;
}

.update-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.update-grid div,
.changelog {
  padding: 14px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 16px;
}

.update-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.update-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.changelog {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 1100px) {
  .metric-grid,
  .feature-grid,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .split-grid,
  .library-grid {
    grid-template-columns: 1fr;
  }
}
