:root {
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --surface-subtle: #F4F1EC;
  --border: #E7E3DC;
  --border-strong: #D6D0C6;
  --text: #111111;
  --muted: #78716C;
  --soft: #57534E;
  --accent: #EA580C;
  --emerald: #059669;
  --emerald-bg: #ECFDF5;
  --red: #DC2626;
  --red-bg: #FEF2F2;
  --amber: #D97706;
  --amber-bg: #FFFBEB;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

[hidden] {
  display: none !important;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.88em;
  background: var(--surface-subtle);
  padding: 2px 6px;
  border-radius: 6px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  pointer-events: none;
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
}

.toast.error {
  background: var(--red);
}

/* Brand & Typography */
.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(234, 88, 12, 0.55);
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1rem;
}

.dual-heading {
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.18;
  color: var(--text);
}

.dual-heading span {
  color: var(--muted);
  font-weight: 500;
}

.muted-copy {
  color: var(--soft);
  font-size: 0.95rem;
  margin-top: 6px;
}

.muted-small {
  color: var(--muted);
  font-size: 0.82rem;
}

.micro-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.pill-soft {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--soft);
  font-weight: 500;
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--text);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.88;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--soft);
}

.btn-ghost:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

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

.field label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--soft);
}

input[type="text"],
input[type="email"],
input[type="password"],
.select-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.92rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

input:focus,
.select-input:focus {
  outline: 2px solid rgba(17, 17, 17, 0.18);
  border-color: var(--text);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

/* Auth Shell */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 12px 40px rgba(17, 17, 17, 0.05);
}

.auth-card .brand-row {
  margin-bottom: 18px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface-subtle);
  padding: 4px;
  border-radius: 10px;
  margin: 18px 0;
}

.tab-btn {
  border: 0;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* App Shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.site-switcher {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  text-align: left;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 9px 12px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--soft);
  cursor: pointer;
}

.nav-item:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.nav-item.active {
  background: var(--text);
  color: #fff;
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.org-pill {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.org-name {
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-plan {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
}

.main-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: rgba(250, 248, 245, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.content-area {
  padding: 28px;
  max-width: 1020px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.row-between {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.row-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.form-card {
  max-width: 680px;
}

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

.card-head h3 {
  font-size: 1rem;
  font-weight: 600;
}

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

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-value {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Audit Checks */
.checks-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.check-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.check-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.check-title {
  font-weight: 600;
  font-size: 0.94rem;
}

.check-detail {
  font-size: 0.88rem;
  color: var(--soft);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}

.status-pass {
  background: var(--emerald-bg);
  color: var(--emerald);
}

.status-fail {
  background: var(--red-bg);
  color: var(--red);
}

.status-review {
  background: var(--amber-bg);
  color: var(--amber);
}

.status-info {
  background: var(--surface-subtle);
  color: var(--soft);
}

.limitations-list {
  margin-top: 14px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-list,
.prompts-list,
.keys-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

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

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form input {
  flex: 1 1 260px;
}

.inline-form .select-input {
  width: 160px;
}

.banner-highlight {
  border-color: var(--accent);
  background: #FFF7ED;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.key-copy-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* AI Visibility */
.provider-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.provider-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

.provider-pill.active {
  border-color: rgba(5, 150, 105, 0.35);
  background: var(--emerald-bg);
  color: var(--emerald);
}

.provider-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.chart-box {
  width: 100%;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-svg {
  width: 100%;
  height: 170px;
  display: block;
}

.result-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.result-link-chip {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--soft);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  text-decoration: none;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-link-chip:hover {
  border-color: var(--text);
  color: var(--text);
}

.snapshot-dialog {
  margin: auto;
  width: min(760px, 94vw);
  max-height: 84vh;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.snapshot-dialog::backdrop {
  background: rgba(17, 17, 17, 0.42);
  backdrop-filter: blur(3px);
}

.snapshot-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.snapshot-header h3 {
  font-size: 1rem;
  margin-top: 4px;
}

.snapshot-citations {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.snapshot-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font);
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  max-height: 52vh;
  overflow-y: auto;
}

/* Content Calendar, Settings & Article Editor */
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.92rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}

textarea:focus,
.date-input:focus {
  outline: 2px solid rgba(17, 17, 17, 0.18);
  border-color: var(--text);
}

.date-input {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.mono-textarea {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.5;
}

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

.chip-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--soft);
  padding: 5px 10px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

.chip-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--soft);
  cursor: pointer;
}

.article-dialog {
  width: min(920px, 95vw);
  max-height: 90vh;
}

.editor-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  background: var(--surface-subtle);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 14px;
}

.article-preview-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  max-height: 54vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.94rem;
}

.article-preview-box table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.86rem;
}

.article-preview-box th,
.article-preview-box td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

.article-preview-box ul,
.article-preview-box ol {
  padding-left: 20px;
}

/* Onboarding Checklist & MCP Code Box */
.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-subtle);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--emerald);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.onboarding-step {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.onboarding-step.done {
  background: #FAFDFB;
  border-color: rgba(5, 150, 105, 0.28);
}

.mcp-code-box {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  overflow-x: auto;
  color: var(--text);
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .kpi-grid,
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .content-area {
    padding: 18px;
  }
}
