:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent2: #22c55e;
  --danger: #ef4444;
  --radius: 10px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid #2a3a52;
  padding: 1rem 0;
  flex-shrink: 0;
}
.sidebar .brand {
  padding: 0 1.25rem 1rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
}
.nav-item {
  display: block;
  padding: 0.6rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
}
.nav-item.active, .nav-item:hover { color: var(--text); background: var(--surface2); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid #2a3a52;
  background: var(--surface);
}
.header .meta { color: var(--muted); font-size: 0.85rem; }

#step-bar {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid #2a3a52;
}
.step {
  flex: 1;
  min-width: 72px;
  text-align: center;
  padding: 0.5rem 0.35rem;
  border-radius: var(--radius);
  font-size: 0.7rem;
  color: var(--muted);
  cursor: pointer;
}
.step:hover { background: var(--surface2); }
.step .num {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
  line-height: 1.5rem;
  margin: 0 auto 0.25rem;
  border-radius: 50%;
  background: var(--surface2);
  font-size: 0.75rem;
}
.step.active { color: var(--text); background: #1e3a5f; }
.step.active .num { background: var(--accent); color: #fff; }
.step.done .num { background: var(--accent2); color: #fff; }
.step .step-kicker {
  display: block;
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.1rem;
}
.step.active .step-kicker { color: #85B7EB; }

.content { padding: 1.5rem; flex: 1; }

.login-box {
  max-width: 380px;
  margin: 10vh auto;
  padding: 2rem;
  background: var(--surface);
  border-radius: var(--radius);
}
.login-box h1 { margin-top: 0; }
label { display: block; margin: 0.75rem 0; font-size: 0.9rem; color: var(--muted); }
input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-top: 0.35rem;
  border: 1px solid #334155;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
}
button.secondary { background: var(--surface2); color: var(--text); }
button.danger { background: var(--danger); }
button:hover { filter: brightness(1.08); }

.project-list { display: grid; gap: 0.75rem; max-width: 720px; }

.project-card-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.project-card-row .project-card {
  flex: 1;
  min-width: 0;
}

.project-card-del {
  flex-shrink: 0;
  align-self: center;
  padding: 0.45rem 0.65rem;
  font-size: 0.72rem;
  background: transparent;
  border: 1px solid #4a2030;
  color: #f8a0a0;
  border-radius: var(--radius);
}

.project-card-del:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.project-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid #2a3a52;
  padding: 1rem;
  border-radius: var(--radius);
  color: var(--text);
}
.project-card .badge {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  background: var(--surface2);
  border-radius: 4px;
}
.muted { color: var(--muted); }

.workflow-history {
  margin: 0.5rem 0 1rem;
  padding-left: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.workflow-history li {
  margin-bottom: 0.35rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 260px 1fr 320px;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 1100px) {
  .workspace-grid { grid-template-columns: 1fr; }
}
.panel-chat, .panel-main, .panel-side {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid #2a3a52;
  min-height: 320px;
}
.chat-log {
  font-size: 0.85rem;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}
.chat-msg { margin: 0.4rem 0; padding: 0.4rem 0.6rem; border-radius: 6px; background: var(--bg); }
.chat-msg.ai { border-left: 3px solid var(--accent); }
.chat-input-row { display: flex; gap: 0.5rem; }
.chat-input-row input { flex: 1; margin-top: 0; }
.media-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.media-thumb {
  width: 72px; height: 72px; object-fit: cover; border-radius: 6px;
  background: var(--bg);
}
.upload-zone {
  border: 2px dashed #334155;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.panel-main label { display: block; margin: 0.5rem 0; font-size: 0.85rem; color: var(--muted); }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 1rem 0;
}
.kpi {
  background: var(--bg);
  padding: 0.75rem;
  border-radius: 8px;
  text-align: center;
}
.kpi-val { display: block; font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.kpi-label { font-size: 0.75rem; color: var(--muted); }
.social-card {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
}
.social-card pre { white-space: pre-wrap; margin: 0.35rem 0 0; color: var(--muted); font-size: 0.8rem; }

.preview-json {
  font-size: 0.8rem;
  overflow: auto;
  max-height: 420px;
  color: var(--muted);
}
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.step1-card {
  background: var(--surface2);
  border: 1px solid #2a3a52;
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1rem 0;
  max-width: 420px;
}
.step1-card #btn-continue-upload {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  background: var(--accent2);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-inner {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  max-width: 520px;
  width: 90%;
}

.delete-confirm-target {
  margin: 0.75rem 0 1rem;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border: 1px solid #2a3a52;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.45;
}

.delete-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
#website-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}
.website-card {
  background: var(--bg);
  border: 2px solid var(--accent, var(--surface2));
  padding: 1rem;
  text-align: left;
  color: var(--text);
}
.website-card span { display: block; font-weight: 700; }
.website-card small { color: var(--muted); }

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--accent2);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  z-index: 200;
}
.toast.error { background: var(--danger); }

.rtl-field {
  direction: rtl;
  text-align: right;
  font-family: inherit;
}

[hidden] { display: none !important; }
