:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --ink: #172026;
  --muted: #63717a;
  --line: #dce4e8;
  --panel: #ffffff;
  --accent: #0d766e;
  --accent-dark: #085f59;
  --warn: #a15c00;
  --bad: #b3261e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

button, input, select {
  font: inherit;
}

button, .export {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover, .export:hover {
  background: var(--accent-dark);
}

button.danger {
  background: var(--bad);
}

button.danger:hover {
  background: #8f1d17;
}

button.secondary {
  background: #415a66;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

input, select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

h1, h2, p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef4f2, #f7f0e7 55%, #edf2f7);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(25, 41, 52, .12);
}

.creator-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.telegram-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #197fae;
  font-weight: 600;
  text-decoration: none;
}

.telegram-link:hover {
  color: #126b94;
}

.telegram-link svg {
  width: 24px;
  height: 24px;
  padding: 5px;
  border-radius: 50%;
  fill: #fff;
  background: #229ed9;
}

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

.sidebar {
  background: #162126;
  color: #fff;
  padding: 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 26px;
}

.sidebar .eyebrow, .sidebar .muted {
  color: #aebbc1;
}

.sidebar nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav, .ghost {
  justify-content: flex-start;
  background: transparent;
  color: #dce4e8;
  border: 1px solid transparent;
}

.nav.active, .nav:hover, .ghost:hover {
  background: #24343b;
  border-color: #30464f;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 84px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.85);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.view {
  padding: 24px 26px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
}

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

.error {
  color: var(--bad);
  min-height: 20px;
}

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

.stat, .panel, .source, .item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat {
  padding: 18px;
}

.stat strong {
  display: block;
  font-size: 30px;
  line-height: 1.1;
}

.source, .item {
  padding: 16px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
  align-items: end;
}

.form-grid.compact {
  grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.section-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.seller-results {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.seller-results strong {
  font-size: 15px;
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 10px;
}

.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1550px;
  border-collapse: collapse;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: #f9fbfb;
  position: sticky;
  top: 0;
}

.list {
  display: grid;
  gap: 10px;
}

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

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

.item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.item-actions button {
  min-width: 140px;
}

.badge {
  border-radius: 999px;
  padding: 4px 9px;
  background: #e6f4f1;
  color: #075d55;
  font-size: 12px;
}

.badge.failed {
  background: #fdebea;
  color: var(--bad);
}

.badge.limited {
  background: #fff2d7;
  color: var(--warn);
}

.proxy-marketplace-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.proxy-marketplace {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 12px;
}

.proxy-marketplace.active {
  border-color: #b7ddd6;
  color: #075d55;
}

.proxy-marketplace.blocked,
.proxy-marketplace.off {
  border-color: #f0c7c3;
  color: var(--bad);
}

.browser-modal {
  position: fixed;
  inset: 16px;
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.browser-modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.browser-modal-actions,
.browser-modal-toolbar > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.browser-screen-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: auto;
  background: #24282d;
}

.browser-screen {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  max-height: 100%;
}

#ozonBrowserScreen {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 100px);
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  touch-action: none;
  cursor: crosshair;
}

.browser-pointer {
  position: absolute;
  z-index: 3;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(16, 108, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(16, 108, 255, 0.8);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.browser-loading {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 6px;
  background: #fff;
  color: #17242a;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
}

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

  .sidebar {
    position: static;
    grid-template-rows: auto;
  }

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

  .stats, .source-grid, .form-grid, .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
  }

  .seller-results {
    align-items: stretch;
    flex-direction: column;
  }

  .browser-modal {
    inset: 4px;
  }

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