/* ======================================
   Global Theme Tokens
====================================== */
:root {
  --bg: #0b1020;
  --bg-alt: #11172a;
  --bg-soft: rgba(255, 255, 255, 0.04);
  --card: #151c30;
  --card-soft: rgba(17, 23, 42, 0.92);
  --text: #ecf2ff;
  --text-strong: #f8fbff;
  --muted: #94a3c2;
  --muted-strong: #bac8e8;
  --border: rgba(148, 163, 194, 0.16);
  --border-strong: rgba(148, 163, 194, 0.28);
  --accent: #7c7cff;
  --accent-strong: #5e5ef9;
  --accent-soft: rgba(124, 124, 255, 0.16);
  --accent2: #ef476f;
  --accent2-soft: rgba(239, 71, 111, 0.18);
  --success: #2dd4bf;
  --warning: #f97316;
  --danger: #ef4444;
  --focus-ring: rgba(124, 124, 255, 0.28);
  --shadow-lg: 0 18px 45px rgba(7, 8, 20, 0.65);
  --shadow-md: 0 12px 32px rgba(7, 8, 20, 0.45);
  --shadow-sm: 0 6px 20px rgba(7, 8, 20, 0.35);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --transition: 0.28s ease;
  --blur: saturate(140%) blur(18px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7ff;
    --bg-alt: #eef1ff;
    --card: #ffffff;
    --card-soft: rgba(255, 255, 255, 0.92);
    --text: #162036;
    --text-strong: #0f172a;
    --muted: #5f6b85;
    --muted-strong: #394364;
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.18);
    --accent: #4f46e5;
    --accent-strong: #4338ca;
    --accent-soft: rgba(79, 70, 229, 0.18);
    --accent2: #ec4899;
    --accent2-soft: rgba(236, 72, 153, 0.14);
    --success: #0ea5e9;
    --warning: #f97316;
    --danger: #ef4444;
    --focus-ring: rgba(79, 70, 229, 0.25);
    --shadow-lg: 0 18px 40px rgba(30, 64, 175, 0.12);
    --shadow-md: 0 10px 28px rgba(30, 64, 175, 0.08);
    --shadow-sm: 0 6px 18px rgba(30, 64, 175, 0.08);
  }
}

:root[data-theme="light"] {
  --bg: #f5f7ff;
  --bg-alt: #eef1ff;
  --card: #ffffff;
  --card-soft: rgba(255, 255, 255, 0.92);
  --text: #162036;
  --text-strong: #0f172a;
  --muted: #5f6b85;
  --muted-strong: #394364;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.18);
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.18);
  --accent2: #ec4899;
  --accent2-soft: rgba(236, 72, 153, 0.14);
  --success: #0ea5e9;
  --warning: #f97316;
  --danger: #ef4444;
  --focus-ring: rgba(79, 70, 229, 0.25);
  --shadow-lg: 0 18px 40px rgba(30, 64, 175, 0.12);
  --shadow-md: 0 10px 28px rgba(30, 64, 175, 0.08);
  --shadow-sm: 0 6px 18px rgba(30, 64, 175, 0.08);
}

:root[data-theme="dark"] {
  /* dark theme inherits default :root values */
}

/* Light theme overrides for surfaces & form fields */
:root[data-theme="light"] body {
  background: radial-gradient(circle at 18% 18%, rgba(79, 70, 229, 0.18), transparent 52%), radial-gradient(circle at 82% -4%, rgba(236, 72, 153, 0.14), transparent 54%), var(--bg);
}

:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea {
  background: color-mix(in srgb, var(--card) 92%, #ffffff 8%);
  color: var(--text);
}

:root[data-theme="light"] input:focus,
:root[data-theme="light"] select:focus,
:root[data-theme="light"] textarea:focus {
  background: color-mix(in srgb, var(--card) 96%, #ffffff 4%);
}

:root[data-theme="light"] .list-row {
  background: color-mix(in srgb, var(--card) 92%, var(--bg) 8%);
  border-color: var(--border);
}

:root[data-theme="light"] .list-row:hover {
  background: color-mix(in srgb, var(--accent-soft, rgba(79,70,229,0.14)) 80%, var(--card) 20%);
}

:root[data-theme="light"] .checkbox-card,
:root[data-theme="light"] .result-card,
:root[data-theme="light"] .prompt-form,
:root[data-theme="light"] .prompt-sidebar,
:root[data-theme="light"] .prompt-hero,
:root[data-theme="light"] .card.soft {
  background: color-mix(in srgb, var(--card) 96%, #ffffff 4%);
  border-color: var(--border);
}

:root[data-theme="light"] .table thead {
  background: color-mix(in srgb, var(--card) 90%, var(--accent-soft, rgba(79,70,229,0.08)) 10%);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', 'SF Pro Display', 'Segoe UI', Roboto, Arial, sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(124, 124, 255, 0.25), transparent 60%), radial-gradient(circle at 80% 0, rgba(239, 71, 111, 0.2), transparent 60%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding: 0;
}

img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent2);
}

p {
  margin: 0 0 1rem;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.02em;
}

.page-shell {
  width: calc(100% - 48px);
  max-width: none;
  margin: 0 24px 72px;
  padding: 32px 0 72px;
}

.page-shell-wide {
  width: calc(100% - 48px);
  max-width: none;
  margin: 0 24px 72px;
  padding: 0 0 72px;
}

.dashboard-page .page-shell-wide {
  width: calc(100% - 48px);
  margin: 0 24px 72px;
  padding-top: 0;
}

.workflow-page {
  width: auto;
  max-width: none;
  margin: 0 24px 72px;
  padding: 0;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.page-header .title {
  font-size: 28px;
}

.page-header .subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
}

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

/* --------------------------------------
   Layout building blocks
-------------------------------------- */
.layout {
  display: grid;
  gap: 24px;
}

.admin-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

.admin-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel {
  display: none;
}

.panel.is-active {
  display: block;
}

.sticky-card {
  position: sticky;
  top: 24px;
}

.layout-split {
  display: grid;
  grid-template-columns: minmax(0, 2.5fr) minmax(0, 1fr);
  gap: 22px;
}

.layout-split.swap-columns {
  grid-template-columns: minmax(0, 0.6fr) minmax(0, 0.4fr);
  align-items: start;
}

.dashboard-page .layout-split {
  display: block;
}

.workflow-page .layout-split {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) minmax(260px, 0.8fr);
  gap: 32px;
  align-items: stretch;
}

.workflow-page .layout-split > .card {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

.workflow-page .layout-split > .card > .card-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

@media (max-width: 1100px) {
  .workflow-page .layout-split {
    grid-template-columns: 1fr;
  }
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid.three {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

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

.flex {
  display: flex;
  gap: 12px;
  align-items: center;
}

.flex.wrap {
  flex-wrap: wrap;
}

.flex.between {
  justify-content: space-between;
}

.flex.end {
  justify-content: flex-end;
}

.flex.stretch > * {
  flex: 1;
}

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  backdrop-filter: var(--blur);
  transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-meta {
  color: var(--muted);
  font-size: 14px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.section {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.section + .section {
  margin-top: 20px;
}

.pill-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 13px;
}

.badge.success {
  background: rgba(45, 212, 191, 0.12);
  color: var(--success);
  border-color: rgba(45, 212, 191, 0.3);
}

.badge.warning {
  background: rgba(249, 115, 22, 0.12);
  color: var(--warning);
  border-color: rgba(249, 115, 22, 0.3);
}

.badge.danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(124, 124, 255, 0.15), rgba(239, 71, 111, 0.15));
  padding: 18px 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
}

.stat-label {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
}

.divider {
  height: 1px;
  border: 0;
  background: var(--border);
  margin: 18px 0;
}

.empty-state {
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  padding: 22px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  color: var(--text-strong);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-row {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  transition: border var(--transition), background var(--transition);
}

.list-row:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.list-row .meta {
  color: var(--muted);
  font-size: 14px;
}

.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 16px;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px dashed var(--border);
}

.info-grid .icon {
  font-size: 20px;
}

.checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  transition: border var(--transition), background var(--transition), transform var(--transition);
}

.checkbox-card:hover {
  border-color: var(--accent);
  background: rgba(124, 124, 255, 0.08);
  transform: translateY(-1px);
}

.checkbox-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.info-box {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 6px;
}

.history-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.history-checkbox {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  min-width: 60px;
}

.history-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-actions .btn.tiny {
  padding: 4px 8px;
}

body.no-scroll {
  overflow: hidden;
}

.topic-history-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.topic-history-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
}

.topic-history-card {
  position: relative;
  width: min(720px, 92vw);
  max-height: 80vh;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 1201;
}

.topic-history-modal.is-open {
  display: flex;
}

.topic-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.workflow-page .option-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}

.step-card {
  min-height: 140px;
  cursor: pointer;
}

.workflow-page .step-card {
  min-height: auto;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  align-items: center;
  gap: 10px;
}

.workflow-page .step-card input[type="checkbox"] {
  margin-top: 0;
}

.workflow-page .step-card > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workflow-page .step-card strong {
  font-size: 14px;
  font-weight: 600;
}

.step-icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.workflow-page .step-icon {
  margin-bottom: 0;
  font-size: 18px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(124, 124, 255, 0.12);
}

.card.soft {
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.doc-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.doc-card {
  flex-direction: column;
}

.sheet-url {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sheet-url input {
  width: 100%;
}

.hint {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
}

.hint.danger {
  color: var(--danger);
}

.result-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.result-block:last-of-type {
  border-bottom: none;
}

.result-block h3 {
  margin-bottom: 12px;
}

.result-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  margin-bottom: 12px;
}

.workflow-page .result-card {
  background: transparent;
  border-color: var(--border-strong);
}

.result-card.brief-card {
  padding: 18px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--border-strong);
}

.brief-text {
  font-family: 'JetBrains Mono', 'SFMono-Regular', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 0;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.result-card ul {
  padding-left: 18px;
  margin: 8px 0;
}

.badge.status-approved {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.badge.status-awaiting {
  background: rgba(249, 115, 22, 0.15);
  color: #fb923c;
}

.badge.status-pending {
  background: rgba(148, 163, 184, 0.2);
  color: var(--muted-strong);
}

.approval-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.approval-actions .revise-form textarea {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 10px;
  background: rgba(15, 23, 42, 0.3);
  color: var(--text);
}

.revision-history {
  margin-top: 12px;
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}

.revision-history ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.code-block {
  background: rgba(15, 23, 42, 0.65);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'JetBrains Mono', 'SFMono-Regular', monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.section-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-item {
  padding-left: 12px;
  border-left: 2px solid var(--border);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.image-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  margin: 0;
}

.image-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.image-card figcaption {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.table thead {
  background: rgba(255, 255, 255, 0.02);
}

.table th,
.table td {
  padding: 14px 16px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.table tbody tr {
  background: var(--card);
  transition: background var(--transition);
}

.table tbody tr:nth-child(2n) {
  background: color-mix(in srgb, var(--card) 88%, var(--bg) 12%);
}

.table tbody tr:hover {
  background: color-mix(in srgb, var(--accent-soft, rgba(124,124,255,0.12)) 80%, var(--card) 20%);
}

.table .table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.role-edit {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(124, 124, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.role-select {
  min-width: 140px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.55);
  color: var(--text);
  padding: 8px 10px;
}

.role-edit .btn.small {
  white-space: nowrap;
}

.table caption {
  text-align: left;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.inline-form {
  display: inline;
}

.preview-placeholder {
  height: 320px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(124, 124, 255, 0.08), rgba(124, 124, 255, 0.02));
  color: var(--muted);
  border: 1px dashed var(--border);
  text-align: center;
  padding: 0 18px;
}

.action-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 18px;
}

/* --------------------------------------
   Forms
-------------------------------------- */
label {
  display: block;
  font-size: 14px;
  color: var(--muted-strong);
  font-weight: 500;
  margin-bottom: 6px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.4);
  color: var(--text);
  font-size: 15px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: rgba(148, 163, 194, 0.6);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
  background: rgba(15, 23, 42, 0.6);
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid.two {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.workflow-page .compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.workflow-page .compact-grid .form-row {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
}

.workflow-page .compact-grid label {
  font-size: 13px;
  font-weight: 600;
}

.workflow-page .compact-grid input,
.workflow-page .compact-grid #languageInput {
  width: 100%;
}

.assign-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 20px;
  align-items: flex-start;
}

.mini-list {
  max-height: 60vh;
  overflow-y: auto;
}

.callout {
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--border-strong);
  background: rgba(124, 124, 255, 0.1);
  color: var(--accent);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.helper-text {
  font-size: 13px;
  color: var(--muted);
}

.prompt-row.is-custom textarea {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.prompt-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.msg-success,
.msg-error,
.msg-info {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border-left: 4px solid transparent;
  font-weight: 600;
  margin-top: 12px;
}

.msg-success {
  background: rgba(45, 212, 191, 0.12);
  color: var(--success);
  border-color: rgba(45, 212, 191, 0.5);
}

.msg-error {
  background: rgba(239, 68, 68, 0.14);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.5);
}

.msg-info {
  background: rgba(124, 124, 255, 0.14);
  color: var(--accent);
  border-color: rgba(124, 124, 255, 0.45);
}

.alert-banner {
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  gap: 14px;
  align-items: center;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger);
  margin-bottom: 20px;
}

.alert {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.alert.danger {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.alert.info {
  border-color: rgba(124, 124, 255, 0.35);
  background: rgba(124, 124, 255, 0.12);
  color: var(--accent);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted-strong);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted-strong);
}

.chip.highlight {
  background: rgba(124, 124, 255, 0.22);
  border-color: rgba(124, 124, 255, 0.35);
  color: var(--accent);
}

.form-disabled {
  opacity: 0.55;
  pointer-events: none;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

/* --------------------------------------
   Buttons
-------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 12px 25px rgba(124, 124, 255, 0.3);
  transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(124, 124, 255, 0.3);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 8px 22px rgba(124, 124, 255, 0.25);
}

.btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.btn.small {
  padding: 8px 12px;
  font-size: 13px;
}

.btn.block {
  width: 100%;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-strong);
}

.btn.secondary {
  background: linear-gradient(135deg, rgba(124, 124, 255, 0.2), rgba(94, 94, 249, 0.25));
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  background: linear-gradient(135deg, rgba(124, 124, 255, 0.28), rgba(94, 94, 249, 0.32));
}

.btn.danger {
  background: linear-gradient(135deg, #ef4444, #ef476f);
  box-shadow: 0 12px 30px rgba(239, 68, 68, 0.28);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--accent);
  font-weight: 600;
  padding: 0;
}

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

.button-set {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* --------------------------------------
   Tabs, sidebar and navigation
-------------------------------------- */
.tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.tab {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 600;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.tab.active {
  background: linear-gradient(135deg, rgba(124, 124, 255, 0.22), rgba(239, 71, 111, 0.18));
  border-color: var(--border-strong);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-md);
  margin: 24px auto 18px;
  border: 1px solid var(--border);
  max-width: none;
  width: calc(100% - 48px);
}

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

.topbar .brand h1 {
  font-size: 24px;
}

.topbar .muted {
  font-size: 14px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tool-launcher {
  position: relative;
}

.tool-launcher-menu {
  position: absolute;
  right: 0;
  top: 110%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  display: none;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
}

.tool-launcher-menu.open {
  display: block;
}

.tool-group + .tool-group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.tool-group-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-strong);
  margin-bottom: 6px;
}

.tool-link {
  display: block;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text);
}

.customer-switcher {
  position: relative;
}

.customer-switcher-menu {
  position: absolute;
  right: 0;
  top: 110%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  display: none;
  min-width: 420px;
  max-width: 540px;
  z-index: 120;
}

.customer-switcher-menu.open {
  display: block;
}

.customer-menu-columns {
  display: flex;
  gap: 12px;
}

.customer-list {
  min-width: 180px;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 8px;
  border-right: 1px solid var(--border);
}

.customer-option {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.12s ease, background 0.12s ease;
}

.customer-option:hover {
  border-color: var(--accent);
}

.customer-option.active {
  background: rgba(124, 124, 255, 0.14);
  border-color: var(--accent-strong);
}

.customer-title {
  font-weight: 600;
}

.customer-tools {
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.customer-tool-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.customer-tool-link:hover {
  border-color: var(--accent);
}

.tool-link:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.chevron {
  font-size: 12px;
  margin-left: 6px;
}

.sidebar {
  border-radius: var(--radius-lg);
  background: var(--card);
  border: 1px solid var(--border);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-md);
  min-width: 220px;
}

.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.sidebar .nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.sidebar .nav-item.active {
  background: linear-gradient(135deg, rgba(124, 124, 255, 0.18), rgba(239, 71, 111, 0.12));
  color: var(--text);
  border: 1px solid var(--border-strong);
}

/* --------------------------------------
   Auth and modal layout
-------------------------------------- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.auth-card {
  background: var(--card-soft);
  border-radius: 24px;
  padding: 40px 36px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  text-align: left;
  backdrop-filter: var(--blur);
}

.auth-card .logo {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 10px;
}

.auth-card h1 {
  font-size: 26px;
  margin-bottom: 10px;
}

.auth-card .muted {
  margin-bottom: 28px;
}

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

.auth-card .form-row {
  margin-bottom: 4px;
}

.auth-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 18, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 28px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  max-width: 900px;
  max-height: 90vh;
  overflow: auto;
  width: 100%;
  position: relative;
}

.modal .modal-actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.close-button {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* --------------------------------------
   Toasts
-------------------------------------- */
.toast-stack {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1200;
}

.toast {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(124, 124, 255, 0.2), rgba(94, 94, 249, 0.24));
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  min-width: 240px;
}

.toast.success {
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.25), rgba(45, 212, 191, 0.35));
  border-color: rgba(45, 212, 191, 0.4);
}

.toast.error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.28), rgba(239, 71, 111, 0.32));
  border-color: rgba(239, 68, 68, 0.4);
}

.limit-card {
  max-width: 420px;
  text-align: center;
}

.limit-card .stack p {
  margin: 0;
}

.limit-card .button-set {
  justify-content: center;
}

/* --------------------------------------
   Utility classes
-------------------------------------- */
.muted {
  color: var(--muted);
  font-size: 14px;
}

.muted-strong {
  color: var(--muted-strong);
  font-weight: 600;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.w-100 {
  width: 100%;
}

.input-compact {
  width: auto;
  min-width: 180px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-20 {
  margin-top: 20px;
}

.mt-24 {
  margin-top: 24px;
}

.mt-32 {
  margin-top: 32px;
}

.mb-0 {
  margin-bottom: 0;
}

.small {
  font-size: 13px;
  line-height: 1.4;
}

/* --------------------------------------
   Responsive tweaks
-------------------------------------- */
@media (max-width: 1024px) {
  .layout-split {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    flex-direction: column;
  }

  .assign-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .tabs {
    gap: 8px;
  }

  .tab {
    flex: 1 1 calc(50% - 8px);
  }

  .workflow-page {
    margin: 0 24px 56px;
  }
}

@media (max-width: 768px) {
  .page-shell {
    padding: 24px 18px 56px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .tabs {
    overflow-x: visible;
    padding-bottom: 8px;
  }

  .tab {
    flex: 1 1 calc(50% - 6px);
  }

  .topbar {
    width: calc(100% - 28px);
    margin: 12px auto 16px;
    padding: 14px 16px;
  }

  .workflow-page {
    margin: 0 16px 48px;
  }

  .assign-layout {
    gap: 18px;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    min-width: auto;
  }

  .auth-card {
    padding: 32px 24px;
  }
}

@media (max-width: 520px) {
  .card {
    padding: 20px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .assign-layout {
    gap: 16px;
  }

  .btn {
    width: 100%;
  }

  .button-set {
    flex-direction: column;
  }

  .topbar {
    width: calc(100% - 20px);
    margin: 10px auto 14px;
    padding: 12px 14px;
  }

  .tabs {
    flex-wrap: wrap;
    gap: 6px;
  }

  .tab {
    flex: 1 1 100%;
  }
}

/* --------------------------------------
   Overlays & Modals
-------------------------------------- */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 18, 0.72);
  z-index: 1400;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.loading-overlay.active {
  display: flex;
}

.loading-box {
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 20% 20%, rgba(124, 124, 255, 0.24), transparent 35%), radial-gradient(circle at 80% 0, rgba(239, 71, 111, 0.2), transparent 32%), linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(124, 124, 255, 0.12));
  padding: 28px 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  min-width: 280px;
}

.loading-visual {
  position: relative;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
}

.loading-pulse {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 124, 255, 0.4), transparent 60%);
  animation: pulse 1.4s ease-in-out infinite;
  filter: blur(6px);
}

.spinner {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  border-right-color: var(--accent2);
  box-shadow: 0 0 28px rgba(124, 124, 255, 0.35);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-weight: 700;
  font-size: 16px;
  text-align: center;
}

.loading-sub {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  max-width: 360px;
}

@keyframes pulse {
  0% {
    transform: scale(0.92);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(0.92);
    opacity: 0.85;
  }
}

.loading-aurora {
  position: absolute;
  inset: -50%;
  background: radial-gradient(circle at 30% 30%, rgba(124, 124, 255, 0.2), transparent 40%), radial-gradient(circle at 70% 70%, rgba(239, 71, 111, 0.18), transparent 38%);
  filter: blur(30px);
  opacity: 0.8;
  animation: drift 9s ease-in-out infinite alternate;
}

.loading-aurora.aurora-2 {
  animation-delay: 1.8s;
  transform: rotate(12deg);
}

@keyframes drift {
  0% {
    transform: translate(-4%, -2%) rotate(0deg);
  }
  100% {
    transform: translate(6%, 5%) rotate(12deg);
  }
}
.loading-text {
  font-weight: 700;
  font-size: 16px;
}

.loading-sub {
  font-size: 13px;
  color: var(--muted);
}

.modal-backdrop.active {
  display: flex;
}

.hidden {
  display: none !important;
}
.page-shell-wide .layout-split > .card,
.page-shell-wide aside .card {
  margin: 0;
}
.prompt-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
}

.prompt-group + .prompt-group {
  margin-top: 12px;
}

.prompt-group summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.prompt-group[open] {
  background: rgba(124, 124, 255, 0.05);
}

/* Prompt full screen workspace */
.prompt-fullscreen {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.prompt-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 6px;
  background: linear-gradient(120deg, rgba(124,124,255,0.12), rgba(45,212,191,0.08));
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

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

.prompt-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.pill.subtle {
  background: rgba(255,255,255,0.08);
  color: var(--muted-strong);
}

.pill.muted {
  background: rgba(255,255,255,0.04);
  color: var(--muted);
}

.pill.tiny {
  padding: 2px 8px;
  font-size: 12px;
}

.prompt-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 16px;
}

.prompt-sidebar {
  position: sticky;
  top: 16px;
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.prompt-sidebar-stack {
  gap: 12px;
}

.prompt-sidebar .button-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prompt-main {
  min-height: 70vh;
}

.prompt-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.prompt-save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.02), var(--card));
}

.chip-set {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-set .chip.is-active,
.chip-set .chip.highlight {
  background: rgba(124, 124, 255, 0.22);
  border-color: rgba(124, 124, 255, 0.35);
  color: var(--accent);
}

.version-link:focus,
.version-link.highlight {
  box-shadow: 0 0 0 2px var(--accent);
}


.prompt-group summary .tiny {
  font-size: 12px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 6px;
}

@media (max-width: 960px) {
  .prompt-layout {
    grid-template-columns: 1fr;
  }
  .prompt-sidebar {
    position: relative;
    top: 0;
  }
  .prompt-hero {
    flex-direction: column;
  }
}
