/* Konkurent — shadcn-inspired (zinc) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.5rem;
  --sidebar: 240 5.9% 10%;
  --sidebar-fg: 240 4.8% 95.9%;
  --sidebar-muted: 240 3.7% 55%;
  --sidebar-active: 240 3.7% 15.9%;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: hsl(var(--foreground));
  background: hsl(var(--muted) / 0.35);
}

a { color: hsl(var(--foreground)); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Auth */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, hsl(var(--muted)) 0%, hsl(var(--background)) 45%);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-brand { display: block; text-align: center; font-weight: 700; font-size: 1.35rem; margin-bottom: 20px; color: hsl(var(--foreground)); text-decoration: none; letter-spacing: -0.02em; }
.auth-brand:hover { text-decoration: none; opacity: 0.85; }
.auth-subtitle { margin: 0 0 16px; font-size: 14px; color: hsl(var(--muted-foreground)); text-align: center; }
.auth-footer { margin-top: 20px; text-align: center; font-size: 13px; }

/* Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: hsl(var(--sidebar));
  color: hsl(var(--sidebar-fg));
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}
.sidebar-brand {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  padding: 8px 12px 20px;
  color: #fff;
}
.sidebar-brand span { color: hsl(var(--sidebar-muted)); font-weight: 500; font-size: 12px; display: block; margin-top: 2px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--sidebar-fg) / 0.85);
  font-weight: 500;
  font-size: 13px;
  text-decoration: none !important;
  transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: hsl(var(--sidebar-active)); color: #fff; }
.sidebar-link.active { background: hsl(var(--sidebar-active)); color: #fff; }
.sidebar-footer { padding: 12px; border-top: 1px solid hsl(0 0% 100% / 0.08); margin-top: 8px; }
.sidebar-user { font-size: 12px; color: hsl(var(--sidebar-muted)); line-height: 1.4; }
.sidebar-user strong { color: hsl(var(--sidebar-fg)); display: block; font-size: 13px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  min-height: 56px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { min-width: 0; }
.topbar h1 { margin: 0; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.02em; }
.topbar-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  padding: 0;
  font: inherit;
}
.icon-btn:hover {
  background: hsl(var(--accent));
  text-decoration: none;
  color: hsl(var(--foreground));
}
.logout-form { margin: 0; display: inline-flex; }
.content { padding: 24px; flex: 1; max-width: 1400px; width: 100%; }

/* Card */
.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.04);
  margin-bottom: 20px;
}
.card-header { padding: 20px 24px 0; }
.card-header h2 { margin: 0 0 4px; font-size: 1rem; font-weight: 600; }
.card-header p { margin: 0 0 16px; font-size: 13px; color: hsl(var(--muted-foreground)); }
.card-body { padding: 20px 24px 24px; }
.card-body > h2 { margin: 0 0 16px; font-size: 1rem; font-weight: 600; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.04);
}
.stat-card .label { font-size: 12px; font-weight: 500; color: hsl(var(--muted-foreground)); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; margin-top: 4px; line-height: 1.1; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  align-items: end;
}
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 500; color: hsl(var(--foreground)); }
.field-hint { font-size: 12px; color: hsl(var(--muted-foreground)); }

input, select, textarea {
  height: 40px;
  width: 100%;
  padding: 8px 12px;
  font: inherit;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { height: auto; min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
}
input::placeholder, textarea::placeholder { color: hsl(var(--muted-foreground)); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover { background: hsl(var(--primary) / 0.9); }
.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}
.btn-secondary:hover { background: hsl(var(--accent)); }
.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-destructive:hover { background: hsl(var(--destructive) / 0.9); }
.btn-ghost { background: transparent; color: hsl(var(--foreground)); border-color: hsl(var(--border)); }
.btn-ghost:hover { background: hsl(var(--accent)); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn-icon { width: 40px; padding: 0; }

.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid hsl(var(--border)); border-radius: var(--radius); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 500;
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / 0.5);
  border-bottom: 1px solid hsl(var(--border));
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: top;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: hsl(var(--muted) / 0.35); }
.cell-actions { display: flex; flex-direction: column; gap: 8px; min-width: 280px; }
.cell-actions form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.cell-actions .field { min-width: 120px; flex: 1; }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--secondary));
}
.badge-success { background: hsl(142 76% 36% / 0.12); color: hsl(142 72% 29%); border-color: transparent; }
.badge-danger { background: hsl(var(--destructive) / 0.12); color: hsl(var(--destructive)); border-color: transparent; }
.badge-muted { color: hsl(var(--muted-foreground)); }

/* Alert */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  margin-bottom: 20px;
  font-size: 13px;
}
.alert-error {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  border: 1px solid hsl(var(--destructive) / 0.25);
}
.alert-success {
  background: hsl(142 76% 36% / 0.08);
  border-color: hsl(142 76% 36% / 0.25);
  color: hsl(142 72% 25%);
}

.text-muted { color: hsl(var(--muted-foreground)); font-size: 13px; }
.page-desc { margin: 4px 0 0; font-size: 13px; color: hsl(var(--muted-foreground)); font-weight: 400; }

/* Tabs */
.tabs { margin-bottom: 20px; }
.tabs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: hsl(var(--muted));
  border-radius: var(--radius);
  width: fit-content;
  max-width: 100%;
  margin-bottom: 20px;
}
.tabs-trigger {
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tabs-trigger:hover { color: hsl(var(--foreground)); }
.tabs-trigger.active {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.06);
}
.tabs-panel { display: none; }
.tabs-panel.active { display: block; }

code, .code-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: hsl(var(--muted));
  padding: 2px 6px;
  border-radius: 4px;
}
.code-block {
  display: block;
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
  border: 1px solid hsl(var(--border));
}

.health-ok { color: hsl(142 72% 29%); font-weight: 500; }
.health-fail { color: hsl(var(--destructive)); font-weight: 500; }
.health-unknown { color: hsl(var(--muted-foreground)); }

.copy-toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 16px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 40px hsl(0 0% 0% / 0.15);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  transform: translateY(8px);
}
.copy-toast.show { opacity: 1; transform: translateY(0); }

.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid hsl(var(--border)); }

.collect-runner .inline-form { display: inline-flex; margin: 0; }
.collect-progress { margin-top: 16px; }
.collect-progress-bar {
  height: 8px;
  background: hsl(var(--muted));
  border-radius: 999px;
  overflow: hidden;
}
.collect-progress-fill {
  height: 100%;
  width: 0;
  background: hsl(var(--primary));
  transition: width 0.25s ease;
}
.collect-status { margin: 10px 0 0; font-size: 13px; color: hsl(var(--muted-foreground)); }

.post-preview-cell { max-width: 280px; }
.post-actions-cell { white-space: nowrap; }
.post-detail-card { max-width: 900px; }
.post-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 24px;
  margin: 0 0 24px;
  padding: 16px;
  background: hsl(var(--muted) / 0.45);
  border-radius: var(--radius);
  font-size: 13px;
}
.post-meta dt { color: hsl(var(--muted-foreground)); font-weight: 500; margin: 0 0 4px; }
.post-meta dd { margin: 0; }
.post-body {
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 24px;
}
.post-media h3, .post-embeds h3 { font-size: 14px; margin: 0 0 12px; }
.post-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.post-media-item img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
}
.post-vk-video-frame {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: #000;
  margin-bottom: 20px;
}
.post-vk-video-frame iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}
.post-saved-note { margin-top: 24px; font-size: 12px; }

.media-preview-trigger {
  display: inline-block;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  line-height: 0;
  border-radius: 6px;
}
.media-preview-trigger:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}
.post-media-img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  display: block;
}

.media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.media-lightbox[hidden] { display: none !important; }
.media-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: hsl(0 0% 0% / 0.82);
  cursor: zoom-out;
}
.media-lightbox-panel {
  position: relative;
  z-index: 1;
  max-width: min(96vw, 1100px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.media-lightbox-image {
  max-width: 100%;
  max-height: calc(92vh - 64px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px hsl(0 0% 0% / 0.45);
}
.media-lightbox-close {
  position: absolute;
  top: -44px;
  right: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius);
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.media-lightbox-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
}
body.lightbox-open { overflow: hidden; }

.strategy-block {
  padding: 16px 0;
  border-bottom: 1px solid hsl(var(--border));
}
.strategy-block:last-child { border-bottom: none; }
.strategy-block h3 { margin: 0 0 8px; font-size: 16px; }
.strategy-block h4 { margin: 16px 0 8px; font-size: 14px; color: hsl(var(--muted-foreground)); }
.strategy-points { margin: 8px 0 0 18px; font-size: 14px; }
.strategy-compare { background: hsl(var(--muted) / 0.35); padding: 16px; border-radius: var(--radius); border: none; margin-bottom: 16px; }

.card-accent { border-color: hsl(var(--ring) / 0.25); box-shadow: 0 1px 3px hsl(0 0% 0% / 0.04); }
.card-competitor .card-header h2 { color: hsl(var(--destructive)); }

.perm-panel { display: flex; flex-direction: column; gap: 12px; min-width: 280px; }
.perm-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 12px; background: hsl(var(--muted) / 0.5); border-radius: var(--radius); border: 1px solid hsl(var(--border)); }
.perm-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; width: 100%; }
.perm-chk { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

.icon-btn .theme-icon-light,
.icon-btn .theme-icon-dark { font-size: 18px; line-height: 1; }
html.dark .theme-icon-light { display: none; }
html:not(.dark) .theme-icon-dark { display: none; }

html.dark {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 3.9%;
  --card-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --sidebar: 240 5.9% 6%;
  --sidebar-active: 240 3.7% 12%;
}

.landing { min-height: 100vh; display: flex; flex-direction: column; background: linear-gradient(165deg, hsl(var(--muted)) 0%, hsl(var(--background)) 50%); }
.landing-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 32px; max-width: 1100px; margin: 0 auto; width: 100%; }
.landing-logo { font-weight: 700; font-size: 1.25rem; letter-spacing: -0.02em; }
.landing-nav { display: flex; gap: 12px; align-items: center; }
.landing-hero { flex: 1; max-width: 720px; margin: 0 auto; padding: 48px 32px 64px; text-align: center; }
.landing-kicker { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: hsl(var(--muted-foreground)); margin: 0 0 12px; }
.landing-hero h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); line-height: 1.15; letter-spacing: -0.03em; margin: 0 0 16px; font-weight: 700; }
.landing-lead { font-size: 1.0625rem; color: hsl(var(--muted-foreground)); margin: 0 0 28px; line-height: 1.6; }
.landing-cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.landing-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; max-width: 1100px; margin: 0 auto; padding: 0 32px 48px; width: 100%; }
.landing-feature { padding: 20px; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); }
.landing-feature h3 { margin: 0 0 8px; font-size: 15px; }
.landing-feature p { margin: 0; font-size: 13px; color: hsl(var(--muted-foreground)); }
.landing-footer { display: flex; justify-content: space-between; padding: 24px 32px; font-size: 13px; color: hsl(var(--muted-foreground)); border-top: 1px solid hsl(var(--border)); max-width: 1100px; margin: 0 auto; width: 100%; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-footer { border-top: 0; margin-top: 0; }
}
