/* ==========================================================================
   POLSKA AGENCJA SEO // PRZEJRZYSTY INTERFEJS DESKTOP & MOBILE v8.0
   Czysta typografia, duża czytelność, responsywność mobilna, 100% SVG
   ========================================================================== */

:root,
[data-theme="dark"] {
  --bg-canvas: #090d16;
  --bg-panel: #111827;
  --bg-elevated: #182234;
  --bg-interactive: #1e293b;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-accent: rgba(16, 185, 129, 0.5);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --accent-emerald: #10b981;
  --accent-emerald-dim: rgba(16, 185, 129, 0.14);
  --accent-cyan: #06b6d4;
  --accent-cyan-dim: rgba(6, 182, 212, 0.14);
  --accent-amber: #f59e0b;
  --accent-amber-dim: rgba(245, 158, 11, 0.14);
  --accent-crimson: #f43f5e;
  --accent-crimson-dim: rgba(244, 63, 94, 0.14);

  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.32);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

[data-theme="light"] {
  --bg-canvas: #f1f5f9;
  --bg-panel: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-interactive: #e2e8f0;

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-accent: #059669;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --accent-emerald: #059669;
  --accent-emerald-dim: rgba(5, 150, 105, 0.1);
  --accent-cyan: #0284c7;
  --accent-cyan-dim: rgba(2, 132, 199, 0.1);
  --accent-amber: #d97706;
  --accent-amber-dim: rgba(217, 119, 6, 0.1);
  --accent-crimson: #e11d48;
  --accent-crimson-dim: rgba(225, 29, 72, 0.1);

  --shadow-card: 0 6px 20px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.mono,
code,
.mono-tag {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   1. EKRAN LOGOWANIA (CZYSTY, BEZ DANYCH NA EKRANIE, RESPONSYWNY)
   ========================================================================== */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background:
    radial-gradient(circle at 50% 0%, rgba(16, 185, 129, 0.14), transparent 55%),
    var(--bg-canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.auth-gate.hidden {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 36px 32px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.auth-logo-mark {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent-emerald-dim);
  border: 1px solid var(--border-accent);
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-kicker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-emerald);
}

.auth-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.auth-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label,
.arch-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-icon-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  min-height: 46px;
  transition: border-color 0.15s ease;
}

.input-icon-wrap:focus-within {
  border-color: var(--accent-emerald);
}

.input-icon-wrap svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.input-icon-wrap input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  padding: 11px 0;
  outline: none;
}

.auth-error {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-crimson-dim);
  border: 1px solid var(--accent-crimson);
  color: var(--accent-crimson);
  font-size: 13px;
  font-weight: 600;
}

/* ==========================================================================
   2. GŁÓWNY UKŁAD APLIKACJI (HEADER + NAWIGACJA + OBSZAR ROBOCZY)
   ========================================================================== */
.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: 1380px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent-emerald-dim);
  border: 1px solid var(--border-accent);
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 16.5px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.client-picker-box,
.model-picker-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  min-height: 38px;
}

.client-picker-box svg {
  color: var(--accent-emerald);
  flex-shrink: 0;
}

.clean-select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  max-width: 240px;
}

.clean-select option {
  background: var(--bg-panel);
  color: var(--text-primary);
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  flex-shrink: 0;
}

.icon-btn,
.logout-btn {
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.logout-btn:hover {
  background: var(--accent-crimson-dim);
  color: var(--accent-crimson);
  border-color: var(--accent-crimson);
}

/* Pasek zakładek */
.app-nav {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-subtle);
}

.nav-container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-container::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  min-height: 46px;
  padding: 0 14px;
  border: none;
  border-bottom: 2.5px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
}

.nav-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.06);
}

.nav-tab.active svg {
  color: var(--accent-emerald);
}

.tab-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--accent-emerald-dim);
  color: var(--accent-emerald);
}

/* ==========================================================================
   3. PRZESTRZEŃ ROBOCZA, KARTY I KOMPONENTY
   ========================================================================== */
.main-container {
  flex: 1;
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.module-hero-strip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 24px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-emerald);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.module-kicker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-emerald);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.module-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 23px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.25;
}

.module-subtitle {
  font-size: 14.5px;
  color: var(--text-secondary);
  margin-top: 6px;
  max-width: 820px;
}

.module-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Siatki */
.arch-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.arch-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.arch-split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.arch-split-sidebar {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 22px;
  align-items: start;
}

/* Karty i Panele */
.arch-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.arch-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.arch-panel-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 9px;
}

.arch-panel-title svg {
  color: var(--accent-emerald);
  flex-shrink: 0;
}

/* Karty statystyk */
.telemetry-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.telemetry-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.telemetry-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.telemetry-icon-box {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
}

.telemetry-value {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
}

.telemetry-foot {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* Przyciski */
.btn-primary,
.btn-primary-arch,
.btn-secondary-arch,
.btn-cyan-arch,
.btn-ghost-xs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  min-height: 42px;
  padding: 9px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  border: 1px solid transparent;
}

.btn-full {
  width: 100%;
  min-height: 46px;
  font-size: 15px;
}

.btn-primary,
.btn-primary-arch {
  background: var(--accent-emerald);
  color: #04130d;
  font-weight: 700;
}

.btn-primary:hover,
.btn-primary-arch:hover {
  filter: brightness(1.08);
}

.btn-cyan-arch {
  background: var(--accent-cyan-dim);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-cyan-arch:hover {
  background: var(--accent-cyan);
  color: #03151c;
}

.btn-secondary-arch {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-ghost-xs {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 12px;
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

.btn-ghost-xs:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Pola formularzy */
.arch-input,
.arch-textarea,
.arch-select-box {
  width: 100%;
  min-height: 42px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.arch-input:focus,
.arch-textarea:focus,
.arch-select-box:focus {
  border-color: var(--accent-emerald);
}

/* Tabele */
.arch-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.arch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.arch-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  white-space: nowrap;
}

.arch-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

/* Pigułki statusu */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 600;
}

.pill-emerald {
  background: var(--accent-emerald-dim);
  color: var(--accent-emerald);
}

.pill-cyan {
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
}

.pill-amber {
  background: var(--accent-amber-dim);
  color: var(--accent-amber);
}

.pill-crimson {
  background: var(--accent-crimson-dim);
  color: var(--accent-crimson);
}

/* Elementy diagnostyczne Audytora */
.diag-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  margin-bottom: 10px;
  font-size: 13.5px;
}

.diag-item svg {
  flex-shrink: 0;
  margin-top: 3px;
}

.diag-critical { border-left: 4px solid var(--accent-crimson); }
.diag-critical svg { color: var(--accent-crimson); }

.diag-improve { border-left: 4px solid var(--accent-amber); }
.diag-improve svg { color: var(--accent-amber); }

.diag-quickwin { border-left: 4px solid var(--accent-cyan); }
.diag-quickwin svg { color: var(--accent-cyan); }

.diag-pass { border-left: 4px solid var(--accent-emerald); }
.diag-pass svg { color: var(--accent-emerald); }

/* Karty kroków Playbooka */
.sop-step-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  margin-bottom: 16px;
}

.sop-step-card.completed {
  border-left: 4px solid var(--accent-emerald);
}

.sop-step-card.pending {
  border-left: 4px solid var(--accent-cyan);
}

.sop-check-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid var(--border-strong);
  background: var(--bg-elevated);
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.sop-check-btn.checked {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #04130d;
}

.meter-track {
  height: 6px;
  border-radius: 99px;
  background: var(--bg-interactive);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-emerald), var(--accent-cyan));
  transition: width 0.3s ease;
}

/* Pusty stan (Empty State) */
.empty-state-box {
  text-align: center;
  padding: 38px 20px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

.empty-state-box svg {
  color: var(--accent-emerald);
  margin-bottom: 10px;
}

/* Wyjścia AI */
.ai-terminal-output {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  max-height: 500px;
  overflow-y: auto;
}

/* Dolny pasek mobilny (domyślnie ukryty na desktopie) */
.mobile-bottom-bar {
  display: none;
}

/* Powiadomienia Toast */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.arch-toast {
  background: var(--bg-panel);
  border: 1px solid var(--border-accent);
  border-left: 4px solid var(--accent-emerald);
  color: var(--text-primary);
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 600;
}

/* ==========================================================================
   4. WERSJA KOMÓRKOWA I TABLETOWA (MOBILE-FIRST RESPONSIVE)
   ========================================================================== */
@media (max-width: 1024px) {
  .arch-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .arch-grid-3,
  .arch-split-2,
  .arch-split-sidebar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .hide-mobile {
    display: none !important;
  }

  .header-inner {
    padding: 12px 16px;
  }

  .brand-title {
    font-size: 15px;
  }

  .brand-subtitle {
    display: none;
  }

  .client-picker-box {
    flex: 1;
    min-width: 150px;
  }

  .clean-select {
    max-width: 100%;
    font-size: 14px;
  }

  .nav-container {
    padding: 0 12px;
  }

  .nav-tab {
    padding: 0 11px;
    font-size: 13px;
    min-height: 42px;
  }

  .main-container {
    padding: 16px 14px 92px;
  }

  .module-hero-strip {
    padding: 18px 16px;
    margin-bottom: 16px;
  }

  .module-title {
    font-size: 19px;
  }

  .module-subtitle {
    font-size: 13.5px;
  }

  .arch-panel {
    padding: 16px;
  }

  .arch-grid-4 {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .telemetry-card {
    padding: 14px;
  }

  .telemetry-value {
    font-size: 20px;
  }

  .auth-card {
    padding: 26px 20px;
  }

  /* Zapobieganie przybliżaniu formularzy w iOS / Android */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Dolny pasek nawigacji na telefonie */
  .mobile-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-strong);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    z-index: 900;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mob-nav-item {
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
  }

  .mob-nav-item.active {
    color: var(--accent-emerald);
  }

  .toast-stack {
    left: 14px;
    right: 14px;
    bottom: 76px;
  }
}

@media (max-width: 420px) {
  .arch-grid-4 {
    grid-template-columns: 1fr;
  }
}
