:root {
  --bg1: #f9fafb;
  --bg2: #fefce8;
  --bg3: #e0f2fe;
  --accent-green: #22c55e;
  --accent-yellow: #eab308;
  --accent-orange: #f97316;
  --card-bg: rgba(255, 255, 255, 0.92);
  --card-border: rgba(15, 23, 42, 0.06);
  --card-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  --text-main: #0f172a;
  --text-muted: #6b7280;
  --input-bg: #eef4fc;
  --input-border: #111827;
  --btn-bg: #ececec;
  --chip-bg: rgba(255, 255, 255, 0.9);
  --chip-border: rgba(15, 23, 42, 0.08);
  --chip-icon: #0f172a;
  --error: #dc2626;
}

:root[data-theme="dark"] {
  --bg1: #020617;
  --bg2: #020617;
  --bg3: #020617;
  --card-bg: rgba(15, 23, 42, 0.96);
  --card-border: rgba(148, 163, 184, 0.28);
  --card-shadow: 0 26px 70px rgba(0, 0, 0, 0.9);
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --input-bg: #1e293b;
  --input-border: #94a3b8;
  --btn-bg: #334155;
  --chip-bg: rgba(30, 41, 59, 0.96);
  --chip-border: rgba(148, 163, 184, 0.55);
  --chip-icon: #e2e8f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  position: relative;
  background: linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 45%, var(--bg3) 100%);
  min-height: 100%;
}

body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

body.panel-page {
  overflow-x: auto;
  overflow-y: auto;
}

.spot {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  animation: float 18s ease-in-out infinite alternate;
  pointer-events: none;
}
.spot.green {
  width: 420px; height: 420px;
  background: var(--accent-green);
  top: 5%; left: 10%;
}
.spot.yellow {
  width: 380px; height: 380px;
  background: var(--accent-yellow);
  bottom: 10%; right: 10%;
  animation-delay: 2s;
}
.spot.orange {
  width: 320px; height: 320px;
  background: var(--accent-orange);
  top: 60%; left: 50%;
  animation-delay: 4s;
}
@keyframes float {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.03); opacity: 0.45; }
  100% { transform: translateY(20px) scale(1.08); opacity: 0.3; }
}

.theme-toggle {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--chip-icon);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  user-select: none;
}
.theme-toggle svg {
  width: 16px;
  height: 16px;
  color: inherit;
  stroke: currentColor;
  opacity: 0.45;
  transition: opacity 0.2s;
}
.theme-toggle[data-mode="light"] .icon-sun,
.theme-toggle[data-mode="dark"] .icon-moon {
  opacity: 1;
}
.theme-toggle .divider {
  width: 1px;
  height: 12px;
  background: var(--chip-border);
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 32px));
  padding: 36px 32px 32px;
  border-radius: 18px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
  text-align: center;
}

.login-card h1 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.login-card .subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.4;
}

.login-form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1.5px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.field input:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.btn-login {
  margin-top: 6px;
  width: 100%;
  height: 46px;
  border-radius: 10px;
  border: 1.5px solid var(--input-border);
  background: var(--btn-bg);
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, filter 0.12s;
}
.btn-login:hover { filter: brightness(0.97); }
.btn-login:active { transform: translateY(1px); }

.error {
  margin-bottom: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(220, 38, 38, 0.08);
  color: var(--error);
  font-size: 0.88rem;
  text-align: center;
}

.panel-wrap {
  position: relative;
  z-index: 1;
  min-height: 100%;
  height: 100%;
  padding: 16px 0 30px;
  display: flex;
  justify-content: center;
}

.workspace {
  width: 1280px;
  max-width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.panel-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  min-height: 40px;
  padding: 0 26px;
}

.panel-brand {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-main);
  white-space: nowrap;
}

.panel-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.panel-username {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-main);
}

.btn-logout {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--input-border);
  background: var(--btn-bg);
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}

.panel-card {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  padding: 28px;
  border-radius: 18px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
}

.panel-card p { color: var(--text-muted); }

.projects-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 18px;
  margin-bottom: 24px;
}

.projects-empty {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding-bottom: 8px;
}

.project-select-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: min(320px, 100%);
  flex: 1 1 240px;
}

.project-select-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.project-select {
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1.5px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1.5px solid var(--input-border);
  background: var(--btn-bg);
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn-secondary:hover { filter: brightness(0.97); }

.project-form {
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.project-form-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.project-form textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
}

.project-form textarea:focus,
.project-select:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.project-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.project-current {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.project-current-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.project-current-url-wrap {
  font-weight: 500;
  margin-left: 0.25em;
}

.project-current-desc {
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 640px;
}

.project-current-url {
  color: var(--text-muted);
  word-break: break-all;
  text-decoration: none;
}

.project-current-url:hover {
  color: var(--text-main);
  text-decoration: underline;
}

.service-tabs {
  display: flex;
  gap: 6px;
  margin: 22px 0 18px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0;
}

.service-tab {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 10px 10px 0 0;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
}

.service-tab:hover {
  color: var(--text-main);
}

.service-tab.is-active {
  color: var(--text-main);
  background: var(--input-bg);
  border-color: var(--card-border);
}

.service-panel {
  padding-top: 4px;
}

.engine-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.engine-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1.5px solid var(--input-border);
  background: var(--input-bg);
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}

.engine-option input {
  accent-color: #2563eb;
}

.settings-hint {
  margin: 8px 0 22px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.url-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.protocol-select {
  flex: 0 0 auto;
  width: 118px;
  height: 44px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1.5px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
}

.url-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.search-target-form {
  margin-bottom: 16px;
}

.search-target-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.search-target-row .field {
  flex: 1 1 160px;
  min-width: 140px;
}

.search-target-row .field-grow {
  flex: 2 1 220px;
}

.search-target-row .field-action {
  flex: 0 0 auto;
}

.settings-queries-form {
  margin-top: 28px;
}

.settings-project-form {
  max-width: 640px;
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--card-border);
}

.query-list {
  list-style: none;
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 720px;
}

.query-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--input-bg);
}

.query-text {
  color: var(--text-main);
  word-break: break-word;
}

.btn-link-danger {
  border: 0;
  background: transparent;
  color: var(--error);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 4px 2px;
}

.btn-link-danger:hover {
  text-decoration: underline;
}

.positions-meta {
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.positions-table-wrap {
  overflow-x: auto;
}

.positions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.positions-table th,
.positions-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--card-border);
  vertical-align: top;
}

.positions-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.positions-table td.pos-empty {
  color: var(--text-muted);
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  padding: 0 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.panel-footer a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.panel-footer a:hover {
  color: var(--text-main);
}

.panel-footer-version {
  white-space: nowrap;
  margin-left: auto;
}
