:root {
  --bg-deep: #070b16;
  --bg-mid: #10182c;
  --bg-panel: rgba(16, 24, 44, 0.82);
  --bg-panel-solid: #141e36;
  --ink: #e7eefc;
  --muted: #93a0bd;
  --amber: #e0a04a;
  --amber-soft: #f0c27a;
  --indigo: #3a568f;
  --indigo-deep: #24365f;
  --line: rgba(224, 160, 74, 0.2);
  --ok: #6ecf9a;
  --err: #e87a7a;
  --warn: #e0c14a;
  --radius: 12px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
  --sidebar: 268px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1000px 600px at 8% -8%, rgba(58, 86, 143, 0.4), transparent 55%),
    radial-gradient(800px 500px at 92% 0%, rgba(224, 160, 74, 0.14), transparent 50%),
    linear-gradient(165deg, var(--bg-deep), var(--bg-mid) 50%, #0c1324);
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--amber-soft); }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-atmosphere {
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(500px 300px at 50% 30%, rgba(224, 160, 74, 0.12), transparent 60%),
    radial-gradient(700px 400px at 30% 80%, rgba(58, 86, 143, 0.25), transparent 55%);
  animation: drift 12s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translateY(0); opacity: 0.85; }
  to { transform: translateY(-12px); opacity: 1; }
}
.login-shell {
  position: relative; z-index: 1; width: min(420px, 100%);
  padding: 2.2rem 1.8rem 2rem;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  animation: rise 0.7s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.eyebrow {
  margin: 0 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--amber);
}
.login-brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  line-height: 1.1;
}
.login-lead { color: var(--muted); margin: 0.6rem 0 1.4rem; }
.login-form label { display: block; margin: 0.8rem 0 0.3rem; color: var(--muted); font-size: 0.92rem; }
.login-form input, .panel input, .panel select, .panel textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(147, 160, 189, 0.25);
  background: rgba(7, 11, 22, 0.55);
}
.login-form .primary-btn { width: 100%; margin-top: 1.2rem; }

.primary-btn, .ghost-btn, .danger-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.primary-btn {
  background: linear-gradient(135deg, rgba(224, 160, 74, 0.95), rgba(196, 128, 48, 0.95));
  color: #1a1208;
  border-color: transparent;
  font-weight: 700;
}
.primary-btn:hover { transform: translateY(-1px); }
.ghost-btn:hover { border-color: var(--amber); color: var(--amber-soft); }
.danger-btn { border-color: rgba(232, 122, 122, 0.5); color: var(--err); }
.hint { color: var(--muted); font-size: 0.9rem; }
.hint.err { color: var(--err); }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: rgba(10, 15, 28, 0.92);
  border-right: 1px solid rgba(58, 86, 143, 0.35);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  z-index: 20;
}
.sidebar-brand {
  padding: 1.3rem 1.1rem 1rem;
  border-bottom: 1px solid rgba(58, 86, 143, 0.3);
}
.brand-glow {
  display: block;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.15rem;
  color: var(--amber-soft);
  letter-spacing: 0.02em;
}
.sidebar-brand small { color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.68rem; }
.nav { padding: 0.75rem 0.55rem 1rem; display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.nav-item, .nav-group-title {
  text-align: left;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
}
.nav-item:hover, .nav-group-title:hover { background: rgba(58, 86, 143, 0.2); color: var(--ink); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(224, 160, 74, 0.18), transparent);
  color: var(--amber-soft);
  box-shadow: inset 3px 0 0 var(--amber);
}
.nav-group-title {
  font-weight: 700;
  color: var(--ink);
  margin-top: 0.45rem;
}
.nav-sub { display: none; padding-left: 0.45rem; }
.nav-sub.open { display: flex; flex-direction: column; gap: 0.1rem; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sidebar-foot {
  padding: 0.9rem 1rem 1.2rem;
  border-top: 1px solid rgba(58, 86, 143, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.main-col { flex: 1; min-width: 0; }
.mobile-top { display: none; }
.content { padding: 1.5rem 1.6rem 3rem; width: min(1180px, 100%); margin: 0 auto; }

.page-head { margin-bottom: 1.25rem; animation: rise 0.45s ease both; }
.page-head h1 {
  margin: 0.15rem 0;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: clamp(1.5rem, 3vw, 2rem);
}
.page-head p { margin: 0.35rem 0 0; color: var(--muted); max-width: 60ch; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.panel, .stat-card {
  background: var(--bg-panel);
  border: 1px solid rgba(58, 86, 143, 0.28);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  animation: rise 0.5s ease both;
}
.stat-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--amber-soft);
  margin-top: 0.25rem;
}
.stat-card span { color: var(--muted); font-size: 0.88rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.9rem; }
.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--amber-soft);
}
.badge.ok { color: var(--ok); border-color: rgba(110, 207, 154, 0.4); }
.badge.err { color: var(--err); border-color: rgba(232, 122, 122, 0.4); }
.badge.warn { color: var(--warn); border-color: rgba(224, 193, 74, 0.4); }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid rgba(58, 86, 143, 0.25);
  vertical-align: top;
}
table.data th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
table.data tr:hover td { background: rgba(58, 86, 143, 0.12); }

.progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(58, 86, 143, 0.35);
  overflow: hidden;
  margin: 0.5rem 0;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--indigo), var(--amber));
  transition: width 0.35s ease;
}

.cost-box {
  margin-top: 0.8rem;
  padding: 0.8rem;
  border-radius: 10px;
  border: 1px dashed var(--line);
}
.cost-box.blocked { border-color: rgba(232, 122, 122, 0.5); color: var(--err); }
.muted-box {
  margin-top: 0.8rem;
  padding: 0.85rem;
  border-radius: 10px;
  background: rgba(7, 11, 22, 0.45);
  white-space: pre-wrap;
  font-size: 0.88rem;
  max-height: 360px;
  overflow: auto;
}
.empty { color: var(--muted); padding: 1rem 0; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.form-grid input,
.form-grid select,
.form-grid textarea {
  background: rgba(7, 11, 22, 0.55);
  border: 1px solid rgba(58, 86, 143, 0.45);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}
.story-card video { max-height: 220px; object-fit: cover; }

.global-status {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin: 0.4rem 0 1rem;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(20, 30, 54, 0.9);
}
.global-status.WORKING { border-color: rgba(90, 160, 255, 0.5); color: #9ec4ff; }
.global-status.ERROR { border-color: rgba(232, 122, 122, 0.55); color: var(--err); }
.global-status.IDLE { border-color: rgba(110, 207, 154, 0.4); color: var(--ok); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.5rem; }
.primary-btn.huge, .ghost-btn.huge {
  font-size: 1.05rem;
  padding: 0.95rem 1.25rem;
  border-radius: 14px;
  display: inline-flex;
  margin: 0.35rem 0.35rem 0.35rem 0;
}
.storie-generate-hero {
  border: 1px solid rgba(212, 160, 80, 0.45);
  background:
    radial-gradient(ellipse at top right, rgba(212, 160, 80, 0.14), transparent 55%),
    rgba(14, 20, 36, 0.95);
}
.storie-generate-hero .primary-btn.huge {
  font-size: clamp(1.05rem, 3.2vw, 1.35rem);
  padding: 1.05rem 1.4rem;
  width: 100%;
  max-width: 420px;
  justify-content: center;
  text-align: center;
}
.storie-phases { columns: 1; }
@media (min-width: 720px) {
  .storie-phases { columns: 2; }
}
.drama-hero-card {
  border: 1px solid rgba(110, 180, 255, 0.35);
  background:
    radial-gradient(ellipse at top left, rgba(60, 110, 200, 0.18), transparent 55%),
    rgba(12, 18, 34, 0.92);
}
.drama-hero-card h2 { margin: 0.2rem 0 0.6rem; font-size: clamp(1.5rem, 3vw, 2.1rem); }
.badge.warn { background: rgba(232, 180, 90, 0.2); color: #f0c674; }
.active-job-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.active-job-meta { text-align: right; }
.progress.big { height: 12px; margin: 0.8rem 0 1rem; }
.checklist { list-style: none; padding: 0; margin: 0 0 1rem; columns: 2; gap: 1rem; }
.checklist li { margin: 0.2rem 0; color: var(--muted); }
.checklist li.done { color: var(--ok); }
.checklist li.active { color: var(--amber-soft); font-weight: 600; }
.job-stats { display: flex; flex-wrap: wrap; gap: 0.85rem; color: var(--muted); font-size: 0.92rem; margin-bottom: 0.8rem; }
.activity-list, .health-list { list-style: none; padding: 0; margin: 0; }
.activity-list li, .health-list li {
  display: flex; justify-content: space-between; gap: 0.75rem;
  padding: 0.35rem 0; border-bottom: 1px solid rgba(58, 86, 143, 0.25);
}
.slot-row { display: grid; gap: 0.55rem; }
.slot-chip {
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(58, 86, 143, 0.35);
  border-radius: 10px;
  background: rgba(7, 11, 22, 0.35);
}
.toast-host {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 50;
  display: flex; flex-direction: column; gap: 0.5rem; max-width: min(360px, 92vw);
}
.toast {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.35s ease both;
}
.toast.ok { border-color: rgba(110, 207, 154, 0.45); }
.toast.err { border-color: rgba(232, 122, 122, 0.55); }
.toast.warn { border-color: rgba(224, 193, 74, 0.5); }
.idea-box { margin-top: 0.75rem; }
.warn-text { color: var(--warn); }
.focus-row { outline: 1px solid rgba(224, 160, 74, 0.45); }
.yt-card h3 { font-family: var(--font-display); }

/* Intimavera concept review */
.iv-concept-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.iv-concept-card h3 { margin-top: 0; font-size: 1rem; }
.iv-concept-thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  background: #0a0a0a;
  cursor: zoom-in;
  text-align: center;
}
.iv-concept-thumb img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: cover;
  object-position: center top;
}
.iv-concept-thumb span { display: block; padding: 0.35rem; }
.iv-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.iv-lightbox[hidden] { display: none !important; }
.iv-lightbox img {
  max-width: min(100%, 420px);
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.iv-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 2rem;
  line-height: 1;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
}
.iv-lightbox-caption { margin-top: 0.75rem; color: #ddd; }
@media (max-width: 1100px) {
  .iv-concept-grid { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: none; }
  .mobile-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(7, 11, 22, 0.88);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(58, 86, 143, 0.3);
  }
  .brand-mark {
    font-family: var(--font-display);
    color: var(--amber-soft);
  }
  .content { padding: 1rem 1rem 2.5rem; }
}
